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
Personally I firstly got the gene locacations from a file that I had locally:
and then I used the
geom_alignment()
command where I was able to specifylabel.size