bam_to_bins: create a tiled representation of a genome from the BAM/CRAM...

View source: R/bam_to_bins.R

bam_to_binsR Documentation

create a tiled representation of a genome from the BAM/CRAM file

Description

This function replaces a bedtools call: bedtools intersect -wao -a fragments.bed -b hg38_300bp_windows.bed > data.bed

Usage

bam_to_bins(x, width = 300, param = NULL, which = IRangesList(), ...)

Arguments

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)

which

an optional GRanges restricting the bins to certain locations

...

additional arguments to pass on to seqinfo_from_header

Details

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.

Value

   a GRangesList with y-base-pair-wide bins tiled across it

See Also

seqinfo_from_header

Examples

library(Rsamtools) 
fl <- system.file("extdata", "ex1.bam", package="Rsamtools", mustWork=TRUE)
bam_to_bins(fl) 


trichelab/spiky documentation built on Sept. 17, 2022, 8:44 a.m.