Labels seem to be problematic if you have many ranges. Color might be better?
## this is just the example GRanges object
> set.seed(1)
> N <- 100
> 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))
> seqlengths(gr) <- c(400, 1000, 500)
> autoplot(gr, aes(fill = sample))
Seems like a reasonable compromise. But these are just ggplot
objects, so you could use e.g., ggrepel
to make labels if you really wanted to.
Thank you so much for your comment. As you say, if I have more than 100 ranges, the color will not be as easy to recognize as the label. But at the most time ,label will be more usefull beacuse we can save the picture as PDF and modify it in Adobe Illustrate.
For the
ggreprl
, do you know how to add a label using it? If we usegeom_label
orgeom_text
, we need to know the X and Y, but ggbio will randomly make a Y value for eachGRange
. I can't have X and Y for the label.It uses biovizBase:::addStepping under the hood if you use the 'stepping ' argument. It's possible you could use that on the front end and use 'identity' instead.
Thank you so much, I will try it