Giter VIP home page Giter VIP logo

Comments (4)

gpertea avatar gpertea commented on June 25, 2024 1

Thank you for the detailed work on this and the documentation, the examples are great! A lot of work, really appreciated.

from ggtranscript.

dzhang32 avatar dzhang32 commented on June 25, 2024

I really like the idea of labelling geom_ranges. Not only would this be useful for exons, I can imagine it coming in handy for other use cases e.g. labelling to_diff() (or one day, to_jdiff()) outputs with their width to see if transcript changes remain in frame. With this in mind, I find the generic solution more appealing, with a helper function to facilitate the exon number use case.

Thinking this through, I think such a label could currently be achieved by adding something like e.g. ggplot2::geom_label(aes(x = (start + end / 2), label = exon_number)). I wonder if it is worth adding a label parameter to geom_range() or instead, show in the vignette/example the combined use of geom_label and geom_range? Personally favour the latter, as it gives users more flexibility and maybe more ggplot2-esque - would appreciate your thoughts.

For the junction case, I do think a label parameter makes sense. The difference from geom_range being that users currently cannot easily add a label to the centre of the junction line as this requires knowing the points of the curve (in particular the y values). Implementation-wise, I think I would need to rewrite GeomJunction to inherit from GeomPath rather than GeomCurve to allow manipulation of the curve prior to creation of the grob - I will give this a go.

Thank you for your feedback, super helpful @gpertea!

from ggtranscript.

gpertea avatar gpertea commented on June 25, 2024

Thank you -- using geom_label (with geom_range) sounds like a good solution for labeling exons, I did not realize it could be that simple. I guess in that case the only thing left for exons would be to make sure the exon_ number column can be generated with a helper function if the attribute is missing.

from ggtranscript.

dzhang32 avatar dzhang32 commented on June 25, 2024

I've added both the exon number helper function and method for labelling junctions.

For the junction label, I went for a separate label geom that inherits from ggrepel::geom_label_repel. The reason I chose this option over a label parameter inside geom_junction was because I think this approach would give users more flexibility in deciding the label aesthetics. The downside of this approach is that costs more computationally (as we have to generate junction curves twice - once for junctions, another for junction labels), but there is scope to optimise my implementation if speed does become a bottleneck.

One thing I was considering is whether to provide a helper function (pretty much what is used internally by geom_junction_label_repel) to obtain the midpoints of junction curves. This would enable users to e.g. use ggplot2::geom_text or ggplot2::geom_label instead of ggrepel::geom_label_repel if they desired. Out of simplicity, I've held back on this for now with the idea to return to it if any users requested - would you find this helper useful?

Let me know if you have any additional thoughts regarding the above - thank you!

from ggtranscript.

Related Issues (12)

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.