bam.cov.gr: Get coverage as GRanges from BAM on custom set of GRanges

View source: R/bamUtils.R

bam.cov.grR Documentation

Get coverage as GRanges from BAM on custom set of GRanges

Description

Gets coverage from BAM in supplied GRanges using 'countBam()', returning GRanges with coverage counts in each of the provided GRanges (different from 'bamUtils::bam.cov()') specified as the columns $file, $records, and $nucleotides in the values field

Basically a wrapper for 'Rsamtools::countBam()' with some standard settings for 'Rsamtools::ScanBamParams()'

Usage

bam.cov.gr(
  bam,
  bai = NULL,
  intervals = NULL,
  all = FALSE,
  count.all = FALSE,
  isPaired = TRUE,
  isProperPair = TRUE,
  isUnmappedQuery = FALSE,
  hasUnmappedMate = FALSE,
  isNotPassingQualityControls = FALSE,
  isDuplicate = FALSE,
  mc.cores = 1,
  chunksize = 10,
  verbose = FALSE,
  ...
)

Arguments

bam

string Input BAM file. Advisable to make the input BAM a BamFile instance instead of a plain string, so that the index does not have to be reloaded.

bai

string Input BAM index file

intervals

GRanges of intervals to retrieve

all

boolean Flag to read in all of BAM as a GRanges via 'si2gr(seqinfo())' (default = FALSE)

isPaired

boolean Flag indicates whether unpaired (FALSE), paired (TRUE), or any (NA) read should be returned. See documentation for Rsamtools::scanBamFlag(). (default = NA)

isProperPair

boolean Flag indicates whether improperly paired (FALSE), properly paired (TRUE), or any (NA) read should be returned. A properly paired read is defined by the alignment algorithm and might, e.g., represent reads aligning to identical reference sequences and with a specified distance. See documentation for Rsamtools::scanBamFlag(). (default = NA)

isUnmappedQuery

boolean Flag indicates whether unmapped (TRUE), mapped (FALSE), or any (NA) read should be returned. See documentation for Rsamtools::scanBamFlag(). (default = NA)

hasUnmappedMate

boolean Flag indicates whether reads with mapped (FALSE), unmapped (TRUE), or any (NA) mate should be returned. See documentation for Rsamtools::scanBamFlag(). (default = NA)

isNotPassingQualityControls

boolean Flag indicates whether reads passing quality controls (FALSE), reads not passing quality controls (TRUE), or any (NA) read should be returned. See documentation for Rsamtools::scanBamFlag(). (default = FALSE)

isDuplicate

boolean Flag indicates that un-duplicated (FALSE), duplicated (TRUE), or any (NA) reads should be returned. 'Duplicated' reads may represent PCR or optical duplicates. See documentation for Rsamtools::scanBamFlag(). (default = FALSE)

mc.cores

integer Number of cores in mclapply (default = 1)

chunksize

integer How many intervals to process per core (default = 10)

verbose

boolean "verbose" flag (default = FALSE)

...

futher arguments passed into Rsamtools::scanBamFlag()

Value

GRanges parallel to input GRanges, but with metadata filled in.


mskilab/bamUtils documentation built on Sept. 28, 2022, 3:45 p.m.