read.bam: Read BAM file into GRanges or data.table

View source: R/bamUtils.R

read.bamR Documentation

Read BAM file into GRanges or data.table

Description

Wrapper around Rsamtools BAM scanning functions By default, returns GRangesList of read pairs for which <at least one> read lies in the supplied interval

Usage

read.bam(
  bam,
  intervals = NULL,
  gr = intervals,
  all = FALSE,
  bai = NULL,
  pairs.grl = TRUE,
  stripstrand = TRUE,
  what = scanBamWhat(),
  unpack.flag = FALSE,
  verbose = FALSE,
  tag = NULL,
  tagFilter = list(),
  isPaired = NA,
  isProperPair = NA,
  isUnmappedQuery = NA,
  hasUnmappedMate = NA,
  isNotPassingQualityControls = NA,
  isDuplicate = FALSE,
  isValidVendorRead = TRUE,
  pairs.grl.split = TRUE,
  as.data.table = FALSE,
  ignore.indels = FALSE,
  size.limit = 1e+06,
  ...
)

Arguments

bam

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

intervals

GRanges of intervals to retrieve. If left unspecified with 'all = TRUE', will try to pull down entire BAM file

gr

Granges (default = intervals)

all

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

bai

string Input BAM index file.

pairs.grl

boolean Flag if TRUE will return GRangesList of read pairs in which at least one read falls in the supplied interval (default = FALSE)

stripstrand

boolean Flag to ignore strand information on the query intervals (default = TRUE)

what

vector What fields to pull down from BAM. (default = scanBamWhat())

verbose

boolean verbose flag (default = FALSE)

tag

vector Additional tags to pull down from the BAM (e.g. 'R2')

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 = NA)

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)

pairs.grl.split

boolean Return reads as GRangesList. Controls whether get.pairs.grl() does split (default = TRUE)

as.data.table

boolean Return reads in the form of a data.table rather than GRanges/GRangesList (default = FALSE)

ignore.indels

boolean Flag messes with cigar to read BAM with indels removed. Useful for breakpoint mapping on contigs (default = FALSE)

...

futher arguments passed to Rsamtools::scanBamFlag()

Value

Reads in one of GRanges, GRangesList or data.table


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