thackl / gggenomes

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

Changing gene colours #152

Closed samrthakur closed 1 year ago

samrthakur commented 1 year ago

Hello, I'm trying to run this code chunk, where "name" is for the gene names, according to which I want to colour the names. When I run

gggenomes(g2, s2, links=e2_subset)+
  geom_seq()+
  geom_gene(aes(fill=name))+
  geom_bin_label() +
  geom_link(aes(fill=pident, color=pident))+
  scale_fill_continuous(high = "lightgrey", low = "navyblue", name="% identity")+
  scale_color_continuous(high = "lightgrey", low = "navyblue",name="% identity")

I get this: Error: Discrete value supplied to continuous scale

When I change the code to add ggnewscale::new_scale_fill() before geom_bin_label(), I get the following error: Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto), : Viewport has zero dimension(s)

Is there any way to solve this?

thackl commented 1 year ago

This is likely an issue with you having too many different names resulting in 10s-100s of colors. The error can occurs if there isn't enough space to draw the legend with all the different colors.

samrthakur commented 1 year ago

I see, I'll try to reduce the number of gene names then by adding gene cluster names. Thank you so much! Update: Its working now!