sampleBam: Extracting random samples from a BAM file

Description Usage Arguments Methods and Functions Author(s) See Also Examples

Description

This function extracts random samples from a BAM file. It uses the samtools view function, thus samtools have to be installed. Samtool's view -s option selects reads according to scores based on a hash calculated from their read names. Hence whether reads are sampled depends on the name of the read which means that read pairs are sampled together (if they have the same name).

Usage

1
2
3
4
5
6
7
## S4 method for signature 'character'
sampleBam( x, seed=sample( 1:1e+6, 1 ),
 fraction=0.001, outfile=tempfile(), ... )

## S4 method for signature 'BamFile'
sampleBam( x, seed=sample( 1:1e+6, 1 ),
fraction=0.001, outfile=tempfile(), ... )

Arguments

...

Additional arguments to be passed to the scanBam function.

fraction

The proportion of reads to be sampled from the BAM file.

outfile

The file name of the intermediate BAM file that is generated by the samtools view -s call. This file will be deleted once it is read.

seed

The seed for the random number generator.

x

The BAM file name or a BamFile object.

Methods and Functions

sampleBam

the function samples the specified fraction of reads from the Bam file. The returned object is a list of lists. For more details please see the help of the scanBam function.

Author(s)

Johannes Rainer

See Also

scanBam

Examples

1
2
3
4
5
6
7
8
9
#############
## Examples:
##
## Perform a quality assessment on a fastq file:
dirpath <- system.file( package="SeqUtils", "extdata" )
bamfile <- dir( dirpath, "example.bam", full=TRUE )

BamSample <- sampleBam( bamfile, fraction=0.01 )
BamSample

jotsetung/SeqUtils documentation built on May 19, 2019, 9:41 p.m.