count_reads: Count reads in bam files using featureCounts

Description Usage Arguments Value Examples

View source: R/count_reads.R

Description

Function to count reads mapping to a reference genome. Users can either supply their own reference or use the built-in one for hg19.

Usage

1
2
3
4
5
6
count_reads(featurecounts = "featureCounts", annotationFile = NULL,
  annotationFormat = "SAF", requireBothEndsMapped = TRUE,
  excludeChimeric = TRUE, pairedEnd = TRUE, pairInsertRange = NULL,
  countMultiMapping = FALSE, multiFeatureReads = FALSE, minQual = 0,
  stranded = 0, groupBy = NULL, featureType = NULL, threads = 1,
  ignoreDup = FALSE, outname = NULL, alignments = NULL)

Arguments

featurecounts

Character string. Path to featureCounts

annotationFile

Character string. Path to annotation file. If NULL, the default hg19 genome is used.

annotationFormat

Specify the format of the annotation file. Acceptable formats include <e2><80><98>GTF<e2><80><99> and <e2><80><98>SAF<e2><80><99>. The in-built annotation is 'SAF'.

requireBothEndsMapped

Logical. If TRUE, only fragments that have both ends successfully aligned will be considered for summarization. This option should be used together with pairedEnd = TRUE.

excludeChimeric

Logical. If TRUE, the chimeric fragments (those fragments that have their two ends aligned to different chromosomes) will NOT be counted. This option should be used together with pairedEnd = TRUE.

pairedEnd

Logical. If TRUE, fragments (or templates) will be counted instead of reads. This option is only applicable for paired-end reads.

pairInsertRange

Vector of two integers specifying the minimum and maximum fragment/template lengths. The default values are c(50, 600). Must be used together with pairedEnd = TRUE.

countMultiMapping

If TRUE, multi-mapping reads/fragments will be counted.

multiFeatureReads

Reads/fragments overlapping with more than one meta-feature/feature will be counted more than once. Note that when performing meta-feature level summarization, a read (or fragment) will still be counted once if it overlaps with multiple features within the same meta-feature (as long as it does not overlap with other metafeatures).

minQual

The minimum mapping quality score a read must satisfy in order to be counted. For paired-end reads, at least one end should satisfy this criteria. 0 by default.

stranded

Indicate if strand-specific read counting should be performed. Acceptable values: 0 (unstranded), 1 (stranded) and 2 (reversely stranded). 0 by default. For paired-end reads, strand of the first read is taken as the strand of the whole fragment.

groupBy

Specify the attribute type used to group features (eg. exons) into meta-features (eg. genes) when GTF annotation is provided. Default is 'gene id<e2><80><99>.

featureType

Specify the feature type. Only rows which have the matched feature type in the provided GTF annotation file will be included for read counting. Default is <e2><80><98>exon<e2><80><99>.

threads

Number of the threads. The value should be between 1 and 32. 1 by default.

ignoreDup

Logical. If TRUE, reads that were marked as duplicates will be ignored. In paired end data, the entire read pair will be ignored if at least one end is found to be a duplicate read.

outname

Character string. Name of the output file. The output file contains the number of reads assigned to each meta-feature or feature.

alignments

Character vector. Paths to BAM files.

Value

Tab-delimited file containing the number of reads assigned to each meta-feature or feature and a matrix with the same.

Examples

1
2
3
4
5
6
7
## Not run: 
alignments <- list.files(path = "bam_files", pattern = "*.bam$")
threads <- parallel::detectCores() - 1
counts <- count_reads(featurecounts = "featureCounts", threads = threads,
                      alignments = alignments)

## End(Not run)

anilchalisey/parseR documentation built on May 7, 2019, 7:45 a.m.