variableWidthBins {chromstaR} | R Documentation |
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.
variableWidthBins(reads, binsizes, chromosomes = NULL)
reads |
A |
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. |
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.
A list()
of GRanges-class
objects with variable-width bins.
Aaron Taudt
## 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)