Giter VIP home page Giter VIP logo

Comments (2)

andy941 avatar andy941 commented on June 25, 2024 2

Ah yes! ok, it makes sense. I was actually almost there earlier but I couldn't figure out exactly what the problem was. I was trying to apply to_intron to only subsets of the dataframe but this is much easier. Thank you very much and great package, I was really missing something simple like ggtranscript, that works well with the ggplot2 philosophy.
Thanks for the prompt reply, I am closing this as it's resolved.
Andrea

from ggtranscript.

dzhang32 avatar dzhang32 commented on June 25, 2024

Thanks for the feedback on ggtranscript!

to_intron() assumes each group_var is represented once in the data. In your data each "feature_id" is repeated 3 times (one repeat per DAI), which results in the weird output.

The easiest solution is to create a unique group_var for each of your transcript + DAIs combinations. For example:

prop_plot <- prop_plot |> dplyr::mutate(unique_id = stringr::str_c(feature_id, "-", DAI)

Then, the rest of your code should work as intended.

# using the created "unique_id" as the group_var
prop_plot_introns <- ggtranscript::to_intron(prop_plot, "unique_id")

prop_plot %>%
  ggplot2::ggplot(ggplot2::aes(
    xstart = start,
    xend = end,
    y = feature_id
  )) +
  ggplot2::facet_grid(cols = vars(DAI)) +
  ggtranscript::geom_range(
    ggplot2::aes(fill = Proportion)
  ) +  
  ggtranscript::geom_intron(
    data = prop_plot_introns,
    ggplot2::aes(strand = strand)
  ) +
  ggplot2::scale_fill_gradient2(
    high = "darkorchid",
    low = "white",
    mid = "darkorange",
    midpoint = 0.5
    # midpoint = min(prop_plot$Proportion) + ((max(prop_plot$Proportion) - min(prop_plot$Proportion)) / 2)
  ) +
  ggplot2::guides(fill = ggplot2::guide_legend("Proportion"))

ggtranscript_issue_7

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.