This function computes histograms at pre-defined regions (peaks)
from mapped fragments, i.e. fragment counts at genomic position. Note,
in contrast to genomic coverage or density maps, this function uses a single
position per fragment (usually its center) rather than the whole extend of
the fragment. This results in a significant increase in resolution.
The parameter whichPos determines whether
fragment centers, start or end positions should be considered
('Center','Left','Right').
Results are stored as a list in the Hists slot of the DBAmmd Object,
with one entry per peak. For each peak i, a (n x L_i) matrix is generated,
where n is the number of samples and L_i is the number of bins used to cover
the extend of the peak. Note, L_i varies between peaks of different lengths.
DBAmmd Object. This Object can be created using DBAmmd().
bin.length
size of binning window (in bp)
(DEFAULT: 20)
whichPos
specifies which relative positions of mapped fragments
should to be considered.
Can be one of: 'Left.p', 'Right.p', 'Right.p' and 'Left.n':
Start and end positions of fragments mapping to positive or negative strand,
respectively ('Right.p' and 'Left.n' are not available for single-end reads).
Additionally inferred positions: 'Center.n','Center.p','Center','Left','Right'.
(DEFAULT: 'Center')
## Example using a small data set provided with this package:
data("MMD")
bin.length <- 20
MMD.1 <- compHists(MMD,bin.length)
# use code{plotPeak()} to plot indivdual peaks:
Peak.id <- '6'
plotPeak(MMD.1, Peak.id=Peak.id)
# or explicitly using the histograms:
H <- Hists(MMD.1, whichPos='Center')
Sample <- 'WT.AB2'
Peak.idx <- match(Peak.id, names(Regions(MMD.1)))
plot(H[[Peak.idx]][Sample,],t='l')
# add peak cooridnates:
Peak <- Regions(MMD.1)[Peak.idx]
meta <- metaData(MMD.1)
PeakBoundary <- meta$AnaData$PeakBoundary
x.coords <- as.integer(colnames(H[[Peak.idx]])) + start(Peak) - PeakBoundary
plot(x.coords,H[[Peak.idx]]['WT.AB2',],t='l',
xlab=names(H)[Peak.idx], ylab='counts', main=Sample)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(MMDiff2)
Loading required package: Rsamtools
Loading required package: GenomeInfoDb
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Loading required package: S4Vectors
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
Loading required package: IRanges
Loading required package: GenomicRanges
Loading required package: Biostrings
Loading required package: XVector
Loading required package: Biobase
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/MMDiff2/compHists.Rd_%03d_medium.png", width=480, height=480)
> ### Name: compHists
> ### Title: Compute Peak histograms
> ### Aliases: compHists
>
> ### ** Examples
>
>
> ## Example using a small data set provided with this package:
>
> data("MMD")
> bin.length <- 20
> MMD.1 <- compHists(MMD,bin.length)
checking parameters...
starting with Center.p
sample WT.AB2
sample Null.AB2
sample Resc.AB2
sample
starting with Center.n
sample WT.AB2
sample Null.AB2
sample Resc.AB2
sample
>
> # use code{plotPeak()} to plot indivdual peaks:
> Peak.id <- '6'
> plotPeak(MMD.1, Peak.id=Peak.id)
No Samples specified, plotting all samples
No Contrast specified, plotting all samples in one plot
No normalization factors applied
>
> # or explicitly using the histograms:
> H <- Hists(MMD.1, whichPos='Center')
> Sample <- 'WT.AB2'
> Peak.idx <- match(Peak.id, names(Regions(MMD.1)))
> plot(H[[Peak.idx]][Sample,],t='l')
>
> # add peak cooridnates:
> Peak <- Regions(MMD.1)[Peak.idx]
> meta <- metaData(MMD.1)
> PeakBoundary <- meta$AnaData$PeakBoundary
> x.coords <- as.integer(colnames(H[[Peak.idx]])) + start(Peak) - PeakBoundary
> plot(x.coords,H[[Peak.idx]]['WT.AB2',],t='l',
+ xlab=names(H)[Peak.idx], ylab='counts', main=Sample)
>
>
>
>
>
>
>
> dev.off()
null device
1
>