Here's a way to produce a similar plot using ggplot2
. I use the example data of IRanges
.
library(IRanges)
# example data
ir <- IRanges(c(1, 8, 14, 15, 19, 34, 40),
width = c(12, 6, 6, 15, 6, 2, 7))
# IRanges of length 7
# start end width
# [1] 1 12 12
# [2] 8 13 6
# [3] 14 19 6
# [4] 15 29 15
# [5] 19 24 6
# [6] 34 35 2
# [7] 40 46 7
bins <- disjointBins(IRanges(start(ir), end(ir) + 1))
# [1] 1 2 1 2 3 1 1
dat <- cbind(as.data.frame(ir), bin = bins)
library(ggplot2)
ggplot(dat) +
geom_rect(aes(xmin = start, xmax = end,
ymin = bin, ymax = bin + 0.9)) +
theme_bw()