Closed minalj365 closed 1 year ago
I haven't directly implemented that in gggenomes, but you can use ggrepel to do it:
library(gggenomes)
s0 <- tibble(
seq_id = "A",
length = 5000
)
g0 <- tibble(
seq_id = "A",
start=c(1000, 1500, 1550),
end=start+50,
gene=c("fooo", "baaar", "baaaz")
)
gggenomes(g0, s0) +
geom_seq() + geom_gene() +
geom_gene_tag(aes(label=gene))
library(ggrepel)
gggenomes(g0, s0) +
geom_seq() + geom_gene() +
geom_text(aes(x=(x+xend)/2, y=y+.1, label=gene, color="overlapping"), data=genes(),
hjust=0, vjust=0, angle=45) +
geom_text_repel(aes(x=(x+xend)/2, y=y+.2, label=gene, color="repelled"), data=genes(),
hjust=0, vjust=0, angle=45, direction = "x")
Check out https://ggrepel.slowkow.com/articles/examples.html#align-labels-on-the-top-or-bottom-edge-1 for additional ideas to draw lines between genes and tags, etc...
Thank you so much! Really helpful!
Hi there! Is there any way like geom_text_repel for overlapping labels? Here is the plot where I have overlapping labels:
And this is the code: