bam_to_bins | R Documentation |
This function replaces a bedtools call: bedtools intersect -wao -a fragments.bed -b hg38_300bp_windows.bed > data.bed
bam_to_bins(x, width = 300, param = NULL, which = IRangesList(), ...)
x |
a BAM or CRAM filename (or a BamFile object) |
width |
the width of the bins to tile (default is 300) |
param |
optional ScanBamParam (whence we attempt to extract |
which |
an optional GRanges restricting the bins to certain locations |
... |
additional arguments to pass on to seqinfo_from_header |
The idea is to skip the BED creation step for most runs, and just do it once. In order to count reads in bins, we need bins. In order to have bins, we need to know how long the chromosomes are. In order to have a BAM or CRAM file, we need to have those same lengths. This function takes advantage of all of the above to create binned ranges. Note that a very recent branch of Rsamtools is required for CRAM file bins.
a GRangesList with y-base-pair-wide bins tiled across it
seqinfo_from_header
library(Rsamtools) fl <- system.file("extdata", "ex1.bam", package="Rsamtools", mustWork=TRUE) bam_to_bins(fl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.