set.seed(1)
N <- 100
require(GenomicRanges)
## ======================================================================
## 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))
## ======================================================================
## default
## ======================================================================
ggplot(gr) + geom_arrow()
# or
ggplot() + geom_arrow(gr)
## ======================================================================
## facetting and aesthetics
## ======================================================================
ggplot(gr) + geom_arrow(facets = sample ~ seqnames, aes(color = strand, fill = strand))
## ======================================================================
## stat:identity
## ======================================================================
ggplot(gr) + geom_arrow(stat = "identity", aes(y = value))
## ======================================================================
## stat:stepping
## ======================================================================
ggplot(gr) + geom_arrow(stat = "stepping", aes(y = value, group = pair))
## ======================================================================
## group.selfish
## ======================================================================
ggplot(gr) + geom_arrow(stat = "stepping", aes(y = value, group = pair), group.selfish = FALSE)
## ======================================================================
## other options to control arrow angle, density, ...
## ======================================================================
library(grid)
ggplot(gr) + geom_arrow(stat = "stepping", aes(y = value, group = pair),
arrow.rate = 0.01, legnth = unit(0.3, "cm"), agnle = 45,
group.selfish = FALSE)
Run the code above in your browser using DataLab