Description Usage Arguments Value Author(s) Examples
Generates summaries on the specified windows
1 2 3 4 5 6 7 8 9 | ## S4 method for signature 'GRanges'
stat_aggregate(data, ..., xlab, ylab, main, by, FUN,
maxgap=-1L, minoverlap=0L,
type=c("any", "start", "end", "within", "equal"),
select=c("all", "first", "last", "arbitrary"),
y = NULL, window = NULL, facets = NULL,
method = c("mean", "median","max",
"min", "sum", "count", "identity"),
geom = NULL)
|
data |
A |
... |
Arguments passed to plot function. such as aes() and color. |
xlab |
Label for x |
ylab |
Label for y |
main |
Title for plot. |
by |
An object with 'start', 'end', and 'width' methods. Passed to |
FUN |
The function, found via 'match.fun', to be applied to each window of
'x'. Passed to |
maxgap, minoverlap, type |
Used in the internal call to |
select |
It passed to When If |
y |
A character indicate the varialbe column for which aggregation is taken on, same as aes(y = ). |
window |
Integer value indicate window size. |
facets |
Faceting formula to use. |
method |
customized method for aggregating, if FUN is not provided. |
geom |
The geometric object to use display the data. |
A 'Layer'.
Tengfei Yin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | library(GenomicRanges)
set.seed(1)
N <- 1000
## ======================================================================
## simmulated GRanges
## ======================================================================
gr <- GRanges(seqnames =
sample(c("chr1", "chr2", "chr3"),
size = N, replace = TRUE),
IRanges(
start = sample(1:300, size = N, replace = TRUE),
width = sample(70:75, size = N,replace = TRUE)),
strand = sample(c("+", "-", "*"), size = N,
replace = TRUE),
value = rnorm(N, 10, 3), score = rnorm(N, 100, 30),
sample = sample(c("Normal", "Tumor"),
size = N, replace = TRUE),
pair = sample(letters, size = N,
replace = TRUE))
ggplot(gr) + stat_aggregate(aes(y = value))
## or
## ggplot(gr) + stat_aggregate(y = "value")
ggplot(gr) + stat_aggregate(aes(y = value), window = 36)
ggplot(gr) + stat_aggregate(aes(y = value), select = "first")
## Not run:
## no hits
ggplot(gr) + stat_aggregate(aes(y = value), select = "first", type = "within")
## End(Not run)
ggplot(gr) + stat_aggregate(window = 30, aes(y = value),fill = "gray40", geom = "bar")
ggplot(gr) + stat_aggregate(window = 100, fill = "gray40", aes(y = value),
method = "max", geom = "bar")
ggplot(gr) + stat_aggregate(aes(y = value), geom = "boxplot")
ggplot(gr) + stat_aggregate(aes(y = value), geom = "boxplot", window = 60)
## now facets need to take place inside stat_* geom_* for an accurate computation
ggplot(gr) + stat_aggregate(aes(y = value), geom = "boxplot", window = 30,
facets = sample ~ seqnames)
## FIXME:
## autoplot(gr, stat = "aggregate", aes(y = value), window = 36)
## autoplot(gr, stat = "aggregate", geom = "boxplot", aes(y = value), window = 36)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.