variableWidthBins: Make variable-width bins

Description Usage Arguments Details Value Author(s) Examples

View source: R/makeBins.R

Description

Make variable-width bins based on a reference BAM file. This can be a simulated file (produced by simulateReads and aligned with your favourite aligner) or a real reference.

Usage

1
variableWidthBins(reads, binsizes, stepsizes = NULL, chromosomes = NULL)

Arguments

reads

A GRanges-class with reads. See bam2GRanges and bed2GRanges.

binsizes

A vector with binsizes. Resulting bins will be close to the specified binsizes.

stepsizes

A vector of step sizes in base pairs, the same length as binsizes.

chromosomes

A subset of chromosomes for which the bins are generated.

Details

Variable-width bins are produced by first binning the reference BAM file with fixed-width bins and selecting the desired number of reads per bin as the (non-zero) maximum of the histogram. A new set of bins is then generated such that every bin contains the desired number of reads.

Value

A list() of GRanges-class objects with variable-width bins. If stepsizes is specified, a list() of GRangesList objects with one entry per step.

Author(s)

Aaron Taudt

Examples

1
2
3
4
5
6
7
8
9
## Get an example BED file with single-cell-sequencing reads
bedfile <- system.file("extdata", "KK150311_VI_07.bam.bed.gz", package="AneuFinderData")
## Read the file into a GRanges object
reads <- bed2GRanges(bedfile, assembly='mm10', chromosomes=c(1:19,'X','Y'),
                    min.mapq=10, remove.duplicate.reads=TRUE)
## Make variable-width bins of size 500kb and 1Mb
bins <- variableWidthBins(reads, binsizes=c(5e5,1e6))
## Plot the distribution of binsizes
hist(width(bins[['binsize_1e+06']]), breaks=50)

AneuFinder documentation built on Nov. 8, 2020, 7:44 p.m.