| plotOptimalSegments | R Documentation |
Plot optimal segments resulting from the segmentation function.
plotOptimalSegments(
optimums,
x.s,
x.e,
w2y,
xlim = NULL,
wlim = NULL,
xlab = "",
add = F,
type = c("windows", "middles"),
...
)
optimums |
data.frame of segmentation results generated by the segmentation function. |
x.s |
vector of start coordinates (x axis) defining the represented genomic intervals. |
x.e |
vector of end coordinates (x axis) defining the represented genomic intervals. |
w2y |
coordinate mapping for window sizes (y axis) produced by the wSize2yAxis function. |
xlim |
range of the represented genomic region, which must be indicated as c(xmin, xmax). |
wlim |
range of represented window sizes, which must be indicated as c(wmin, wmax). |
xlab |
legend of the x axis. |
add |
logical, when set to TRUE the plot should overlay an existing multi-resolution plot. |
type |
either "windows" (default) or "middles". |
... |
optional parameters forwarded to the |
Benjamin Leblanc
visualizationCoordinates, wSize2yAxis, domainogram, segmentation, plotDomains
# Simulate enrichment signal
n <- 2000
Mi <- rep(0, n)
Mi <- Mi + dnorm(1:n, 2.5*n/20, n/40) + dnorm(1:n, 4*n/20, 50)
Mi <- Mi + 4 * dnorm(1:n, 5*n/10, n/10)
Mi <- Mi + dnorm(1:n, 16*n/20, n/40) + dnorm(1:n, 17.5*n/20, 50)
Mi <- (Mi/max(Mi))^4 + rnorm(n)/4
# Compute enrichment scores
Yi <- enrichmentScore(Mi)
# Multi-resolution segmentation
seg.c <- segmentation(Yi, name="MRA_demo", wmin=20)
# Load segmentation results
opts <- read.delim(seg.c$file.segments, stringsAsFactors=F, skip=1)
doms <- read.delim(seg.c$file.domains, stringsAsFactors=F)
doms.mr <- read.delim(seg.c$file.maxresolution, stringsAsFactors=F)
doms.ms <- read.delim(seg.c$file.maxscale, stringsAsFactors=F)
# Visualization coordinates
x.s <- 1:n - 0.5
x.e <- 1:n + 0.5
w2y <- wSize2yAxis(n, logscale=T)
layout(matrix(1:2, 2, 1), heights=c(3,1)/4)
par(mar=c(3, 4, 1, 2)) # default bottom, left, top, right = c(5, 4, 4, 2)
# Plot domainogram
domainogram(Yi, x.s, x.e, w2y)
plot(Mi, type='l')
# Visualize segmentation results
plotOptimalSegments(opts, x.s, x.e, w2y, col="black")
plot(Mi, type='l')
# Visualize multi-resolution domains
plotDomains(doms, x.s, x.e, w2y, col=rgb(0,0,0,0.5), border=rgb(0,0,0,0))
# Visualize max. resolution and max. scale domains
plotDomains(doms.mr, x.s, x.e, w2y, col=rgb(0,1,0,0.5), border=rgb(0,0,0,0), lwd=2, lty=1, add=T)
plotDomains(doms.ms, x.s, x.e, w2y, col=rgb(1,0,0,0.5), border=rgb(0,0,0,0), lwd=2, lty=1, add=T)
legend("topright", c("Max. resolution", "Max. scale", "Both"), fill=c("green", "red", "chocolate"), bty='n')
plot(Mi, type='l')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.