Skip to contents

A wrapper around Rsubread::featureCounts to quantify reads in the SAF segments generated by cacti_s_create_segments.

Usage

cacti_s_count(
  file_bams,
  file_saf,
  file_counts_out,
  threads = 1,
  isPairedEnd = FALSE,
  ...
)

Arguments

file_bams

Character vector of BAM file paths.

file_saf

Path to the SAF annotation file (from cacti_s_create_segments).

file_counts_out

Output path for the counts matrix.

threads

Number of threads for featureCounts.

isPairedEnd

Logical. If TRUE, fragments are counted instead of reads. Default is FALSE.

...

Additional arguments passed to Rsubread::featureCounts.

Value

Invisibly returns the counts matrix; writes file_counts_out.

Details

By default, this runs with settings optimized for CACTI-S:

  • -F SAF: Uses the SAF format provided.

  • --read2pos 5: Reduces reads to their 5' end.

  • --primary: Counts only primary alignments.

  • --ignoreDup: Ignores duplicate reads.

Examples

if (FALSE) { # \dontrun{
# Locate test data bundled in the package
file_saf <- system.file("extdata/test_results", "test_segments.saf", package = "cacti")
file_bam1 <- system.file("extdata", "Sample1.bam", package = "cacti")
file_bam2 <- system.file("extdata", "Sample2.bam", package = "cacti")
file_bam3 <- system.file("extdata", "Sample3.bam", package = "cacti")
file_bam4 <- system.file("extdata", "Sample4.bam", package = "cacti")

# Define output file
file_out <- "inst/extdata/test_results/test_raw_counts.txt"

# Run counting
if (file.exists(file_bam1) && file.exists(file_saf)) {
  cacti_s_count(
    file_bams = c(file_bam1, file_bam2, file_bam3, file_bam4),
    file_saf  = file_saf,
    file_counts_out = file_out
  )

  # Check result
  head(read.table(file_out, header = TRUE))
}
} # }