thackl / gggenomes

A grammar of graphics for comparative genomics
https://thackl.github.io/gggenomes/
Other
581 stars 64 forks source link

Text associated with overlapping gene regions #52

Closed jchariker closed 3 years ago

jchariker commented 3 years ago

Hi Thomas, Thank you for letting me know about gggenomes for dealing with overlapping gene regions. I am having some trouble getting the gene labels to line up with the offset gene regions. I attached an image, and I have my code below. Is there a way to deal with this? It will be perfect if I can just get them lined up! Thanks for your help! Julia

library(gggenomes)
colourCount = 30
getPalette = colorRampPalette(brewer.pal(9, "Set1"))
genesDF<-read.table("sars-cov-2_Annotations_gggenomes.txt",sep="\t",header=TRUE)
gggenomes(genes=genesDF) +
  geom_gene(aes(fill=gene), position="pile",
            size = 4, shape = c(0), rna_size = 2, intron_shape = 0, stroke=0) +
  geom_gene_tag(aes(label=gene, check_overlap = TRUE)) +
  scale_fill_manual(values = getPalette(colourCount)) + 
  theme(legend.position = "none")
ggsave("gggenome.png", width=8, height=2)

gggenome

thackl commented 3 years ago

Try adding position="pile" to geom_gene_tag. That should fix it.

jchariker commented 3 years ago

Hi Thomas, This worked perfectly! Thank you so much!! Julia

thackl commented 3 years ago

Your welcome!

thackl commented 3 years ago

*You're ;)