Question: ggbio - change transcript label sizes
0
23 days ago by
Kevin Blighe190
Kevin Blighe190 wrote:

It seems next to impossible to change the size of the geom_text() labels with autoplot() in ggbio. For example, take the reproducible code:

require(ggbio)
require(GenomicRanges)
require(Mus.musculus)

p <- autoplot(
Mus.musculus, # OrganismDb class
which = GRanges("chr12", IRanges(116052334, 116929233)),
columns = c("SYMBOL"),
gap.geom = 'chevron')
p


The label sizes are too small. So, I figured that something like this would work:

p + geom_text(size = 16)


However, that doesn't change the size.

I also tried (before running autoplot()) to set defaults for geom_text(), but that neither works:

update_geom_defaults("text", list(colour = "black", size = 20))


I also tried to create a custom function and specify label.text.cex, but it neither works:

theme_tracks_custom <- function (bg = "#fffedb", alpha = 1, ...) {
res <- theme_clear(grid.x.major = FALSE, ...)
attr(res, "track.plot.color") <- sapply(bg, scales::alpha, alpha)
attr(res, "track.bg.color") <- bg
attr(res, "label.text.color") <- "white"
attr(res, "label.bg.fill") <- "#a52a2a"
attr(res, 'label.text.cex') <- 3
res
}
p + theme_tracks_custom()


All of the autoplots that I have seen via Google Images have these small labels; so, I figured that nobody else neither found a way to change them.

One issue is that the global text size attribute for ggplot2's theme() is not carried through to geom_text(), which has its own text size attribute.

In the ideal situation, autoplot() would permit the user to specify the label size that is then passed to geom_text(), and also permit that check.overlap could be TRUE or FALSE

Kevin

annotation ggbio • 84 views
modified 23 days ago by Michael Lawrence11k • written 23 days ago by Kevin Blighe190
Answer: ggbio - change transcript label sizes
1
23 days ago by
United States
Michael Lawrence11k wrote:

The forthcoming version 1.33.2 supports a labels.size= argument for this purpose. Btw, you can always pass additional arguments that get passed down to different layers. Passing size= is problematic, because it also affects the lines. But you can pass check_overlap= without issues.