View source: R/bamChrChunkApply.R
bamChrChunkApply | R Documentation |
Runs a function on reads/fragments from chunks of (chromosomes) of an indexed bam file. This is especially used by other functions to avoid loading all alignments into memory, or to parallelize reads processing.
bamChrChunkApply(
x,
FUN,
paired = FALSE,
keepSeqLvls = NULL,
nChunks = 4,
strandMode = 2,
flgs = scanBamFlag(),
exclude = NULL,
mapqFilter = NA_integer_,
BPPARAM = SerialParam(),
...
)
x |
A bam file. |
FUN |
The function to be run, the first argument of which should be a 'GRanges' |
paired |
Logical; whether to consider the reads as paired (fragments, rather than reads, will be returned) |
keepSeqLvls |
An optional vector of seqLevels to keep |
nChunks |
The number of chunks to use (higher will use less memory but increase overhead) |
strandMode |
Strandmode for paired data (see
|
flgs |
'scanBamFlag' for filtering the reads |
exclude |
An optional GRanges of regions for which overlapping reads should be excluded. |
mapqFilter |
Integer of the minimum mapping quality for reads to be included. |
BPPARAM |
A 'BiocParallel' parameter object for multithreading. Note that if used, memory usage will be high; in this context we recommend a high 'nChunks'. |
... |
Passed to 'FUN' |
A list of whatever 'FUN' returns
# as an example we'll use the function to obtain fragment sizes:
bam <- system.file("extdata", "ex1.bam", package="Rsamtools")
fragLen <- bamChrChunkApply(bam, paired=TRUE, FUN=function(x) width(x))
quantile(unlist(fragLen))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.