Calculate an approximate measure for a given region in a CRAM/BAM file.

depth(bam, index, reg)

Arguments

bam

the cram/bam/sam file

index

the index of the cram/bam/sam file

reg

the region of interest, typically in format of chr1:start-begin

Value

a dataframe with the chrom, position, and approximate depth (three columns)

Details

This is only an approximate depth, based on the 'fast mode' algorithm from mosdepth. It allocates an array for the entire chromosome, an increments each start site and decrements each end site, and then takes the cumulative sum. It does not account for mismatches in the alignment, hence, the reference to an 'approximate' depth.

Examples

# NOT RUN {
depth(bam, index, "chr1:10001-100050")
# }