dynverse / dyno

Inferring, interpreting and visualising trajectories using a streamlined set of packages 🦕
https://dynverse.github.io/dyno
Other
163 stars 32 forks source link

Plotting Issue/Bug for dynplot::plot_dimred with large data sets #62

Closed semmrich closed 4 years ago

semmrich commented 4 years ago

Dear Dynverse Team,

When using a 10X Genomics dataset with ~18k cells x ~10k genes (FULL) I came across a strange behavior with plot_dimred: To optimize conditions I am using a test dataset of 1.6k cells x ~10k genes, which gives me a sweet plot dimred.test.PAGA_tree.ggplot2.pdf with this code: plot_dimred(model.tree.paga_tree, color_cells = "grouping", alpha_cells = 1, size_cells = 1) + scale_color_manual(values = color.clusters.NOmp) + theme_classic()

However, using the FULL dataset yields the default plotting dimred.FULL.PAGA_tree.NOggplot2.pdf despite the same code: plot_dimred(PT.paga_tree, color_cells = "grouping", alpha_cells = 1, size_cells = 1) + scale_color_manual(values = color.clusters.NOmp) + theme_classic()

It seems the large data dimension inactivates or overrides ggplot2 coloring. Indeed, while the test dataset code will have the usual ggplot2 color scale note Scale for 'colour' is already present. Adding another scale for 'colour', which will replace the existing scale. which does not appear with the FULL dataset. Strange enough the theme works, but adding i.e. geom_rug again only works for test but not FULL.

Is there a way to fix this? I would like to use the plot_dimred trajectories for presentation and publishing, truely appreciate if you can help me out here. Many Thanks in advance, Stephan

rcannood commented 4 years ago

Hey Stephan,

Large dataset sizes indeed cause hex binning to be activated, by default (hex_cells = ifelse(length(trajectory$cell_ids) > 10000, 100, FALSE)), you can set hex_cells = FALSE to turn this off, but this will cause your plots to be much larger.

The problem in your case is that hex-binning requires you to use scale_fill_manual() instead of scale_colour_manual().

This should fix the problem for you, let me know if it works. Robrecht

semmrich commented 4 years ago

Hi Robrecht,

Both tips work excellent! Thank you very much! The hex_cells function is actually described in the plot_dimred documentary, I could have read it up myself, sorry.

Stephan