binnedCounts: Counts reads mapped to genomic intervals

View source: R/preprocess-utils.R

binnedCountsR Documentation

Counts reads mapped to genomic intervals

Description

Utilizes the countBam() function in the Rsamtools package to count number of reads mapped to ranges determined by a ScanBamParams() object.

Usage

binnedCounts(object, scan_param)

Arguments

object

A BamViews object

scan_param

An optional ScanBamParam object specifying any parameters to consider when importing reads from bam files included in the BamViews object. If omitted, a scanBamParams object will automatically be created to include all ranges from the BamViews object and to ignore unmapped and duplicate reads.

Value

An integer-vector of counts corresponding to each interval in the BamViews object.

Examples

library(Rsamtools)
library(svbams)
library(svfilters.hg19)
data(bins1kb)
extdir <- system.file("extdata", package="svbams", mustWork=TRUE)
bamfile <- file.path(extdir, "cgov10t.bam")
bins <- keepSeqlevels(bins1kb, "chr3", pruning.mode = "coarse")
bins <- subsetByOverlaps(bins, GRanges("chr3", IRanges(59600000, 61000000)))
bviews <- BamViews(bamRanges=bins, bamPaths=bamfile)
counts <- binnedCounts(bviews)
head(counts)
length(bamRanges(bviews)) == length(counts) #TRUE

cancer-genomics/trellis documentation built on Aug. 20, 2024, 5:48 p.m.