BamSampler {Rsamtools}R Documentation

Sample from a BAM files

Description

Use BamSampler() to create a reference to a BAM file (and optionally its index). Calls to scanBam (and many functions that use scanBam) draw a random sample from the BAM file.

Usage


## Constructors

BamSampler(file, index = file, ..., yieldSize, obeyQname = FALSE) 

## S4 method for signature 'BamSampler'
scanBam(file, index=file, ..., param=ScanBamParam(what=scanBamWhat()))

Arguments

file

character(1); BAM file path for BamSampler, or BamSampler index for scanBam and other functions.

index

character(1); the BAM index file path (for BamFile); ignored for other methods.

...

Additional arguments; see BamFile-class.

yieldSize

integer(1); number of records to yield each time the file is read from using scanBam.

obeyQname

logical(1); indicating whether the file is sorted by qname and if so, that qnames are not split between yields.

param

An optional ScanBamParam instance to further influence scanning, counting, or filtering.

Objects from the Class

Objects are created by calls of the form BamSampler().

Fields

The BamSampler class inherits fields from the BamFile class.

Functions and methods

BamSampler inherits methods from BamFile and can be used in place of BamFile in many functions.

Author(s)

Martin Morgan

Examples


fl <- system.file("extdata", "ex1.bam", package="Rsamtools")
samp <- BamSampler(fl, yieldSize=1000)
## two independent samples
head(readBamGappedAlignments(samp))
head(readBamGappedAlignments(samp))


[Package Rsamtools version 1.12.0 Index]