Git Product home page Git Product logo

Comments (4)

thackl avatar thackl commented on September 26, 2024

Fancy! Good question. What kind of scale do you mean? A complete axis, or a small scale bar with fixed size for comparison. Maybe akin to #85 geom_scale_bar but on the y-axis matching the ribbon scale?

On a side note, check out gggenomes::geom_wiggle() which I've added a while back. It wraps geom_ribbon(), so that you don't need to add all the y,ymax,x,xend, ....

from gggenomes.

Daniel-Ze avatar Daniel-Ze commented on September 26, 2024

Thanks a lot for the geom_wiggle() tip! Indeed makes it much easier to plot the ribbons. I tried the "line" and "linerange" option which gives you a legend for the plotted data. This is already pretty nice!
Below is the "line" version as I think the "linerange" is a bit confusing in a whole genome context. To elaborate the graph a bit: The upper ribbon is actual annotated genes of a gene family and the lower part is expressed genes of the same gene family from IsoSeq data.
example_sw_wiggle

However, the problem I encounter is that each ribbon gets its own legend scale. It should be a shared one among all the ribbons.

I guess an added dedicated axis for each ribbon would be the easiest for people to understand what they are looking at there.

Thank you for your help!

Cheers,
Daniel

from gggenomes.

Daniel-Ze avatar Daniel-Ze commented on September 26, 2024

A little update to this. I had some time to play around with this and I got a bit further with the gggenomes builtin aesthetics:

  • First I draw the bare genome
  • Then I add the feature track plus a bar plot
  • To this I add the axis information plus a continuous scale that takes the max from the added feature track.
p_chr <- gggenomes(seqs = genome)+
  geom_seq()

p_chr %>% add_feats(cluster)+
  geom_bar(aes(x=(x+xend)/2,
               y = score), 
              feats(cluster),
              fill="orange",
              linetype=1,
              size=0.1,
              alpha=1, 
              stat = "identity")+
  theme(axis.line.y.left = element_line(),
        axis.ticks.y = element_line(),
        axis.text.y = element_text(),
        axis.line.x = element_blank(),
        axis.ticks.x = element_blank(),
        axis.text.x = element_blank())+
  scale_y_continuous(limits = c(0, max(cluster$score)),breaks = seq(0,max(cluster$score), 2))

image

My question would be if there is a way to move the bare genome to 0. It seems to sit always at 1 at the Y-axis.
I haven't tried to add this to a bigger gggenomes plot.

from gggenomes.

thackl avatar thackl commented on September 26, 2024

Here's a solution, although granted, not the prettiest ...

p1 <- gggenomes(emale_genes, emale_seqs) |> add_clusters(emale_cogs) +
  geom_seq() + geom_gene()

# default plot with first genome at y==1
p1 + theme_bw()

image

p2 <- p1
# change y-coords of seqs by hand
p2 <- set_seqs(p2, get_seqs(p2) |> mutate(y=y-1)) 
# relayout other features (genes, etc)
# BUG: this should work but ignore_seqs not propaged
# p2 <- layout(p2, ignore_seqs=TRUE) 
# this works
p2$data <- layout(p2$data, ignore_seqs=TRUE)

# plot with genomes shifted on y axis, i.e. first genomes at y==0
p2 + theme_bw()

image

from gggenomes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.