variableWidthBins {AneuFinder} | R Documentation

## Make variable-width bins

### 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

    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

    ## 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)

[Package AneuFinder version 1.12.1 Index]