variableWidthBins {chromstaR} | 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 TODO: insert link and aligned with your favourite aligner) or a real reference.

### Usage

    variableWidthBins(reads, binsizes, chromosomes = NULL)

### Arguments

`reads` | A `GRanges-class` with reads. See `readBamFileAsGRanges` and `readBedFileAsGRanges`.
`binsizes` | A vector with binsizes. Resulting bins will be close to the specified 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.

### Author(s)

Aaron Taudt

### Examples

    ## Get an example BAM file with ChIP-seq reads
    bamfile <- system.file("extdata", "euratrans", "lv-H3K4me3-BN-female-bio1-tech1.bam",
                          package="chromstaRData")
    ## Read the file into a GRanges object
    reads <- readBamFileAsGRanges(bamfile, chromosomes='chr12', pairedEndReads=FALSE,
                        min.mapq=10, remove.duplicate.reads=TRUE)
    ## Make variable-width bins of size 1000bp
    bins <- variableWidthBins(reads, binsizes=1000)
    ## Plot the distribution of binsizes
    hist(width(bins[['1000']]), breaks=50)

[Package chromstaR version 1.20.2 Index]