count.reads {seqbias} | R Documentation

## Counting reads across intervals

### Description

Counts the number of reads starting at each position across given genomic intervals

### Usage

    count.reads(reads_fn, I, sb=NULL, binary=FALSE, sum.counts=FALSE)

### Arguments

`reads_fn` | filename of aligned reads in BAM format
`I` | a GRanges object giving valid genomic intervals
`sb` | a seqbias object
`binary` | if `TRUE`, return a 0-1 vector, otherwise return a vector counting the number of reads mapped to each position
`sum.counts` | if `TRUE` return the total read count for each interval

### Details

Given an indexed BAM file, this function counts the number of reads starting at each position of each provided interval. If a seqbias object is provided through the `sb` attribute, counts are corrected for sequence bias. The total read count for each interval is returned if `sum.counts` is `TRUE`.

If `binary` is `TRUE` a 0-1 vector is returned instead, where positions at which no reads are mapped are 0, and those with one or more are 1.

### Value

A list of numeric vectors is returned, one for each interval provided. Each vector gives an integer count of the number of reads beginning on that position.

### Note

The BAM file provided should be indexed with 'samtools index'.

### Author(s)

Daniel Jones dcjones@cs.washington.edu

### See Also

`seqbias.predict`

### Examples

      reads_fn <- system.file( "extra/example.bam", package = "seqbias" )

      I <- GRanges( c('seq1'), IRanges( c(1), c(5000) ), strand = c('-') )

      counts <- count.reads( reads_fn, I )

[Package seqbias version 1.32.0 Index]