teunbrand / ggchromatic

Colour and fill scales for 'ggplot2' using colour spaces.
https://teunbrand.github.io/ggchromatic/
Other
11 stars 1 forks source link

Error generating cube #16

Open brigidar opened 1 year ago

brigidar commented 1 year ago

I am trying to do a umap graph with 3 genes and I can get the color to work, but then when it has to create the legend it fails with the error: Error in if (0 <= angle & angle < 90) { : the condition has length >

trace back info:

  1. rotate_just(angle, hjust, vjust)
  2. title_spec(label, x = x, y = y, hjust = hjust, vjust = vjust, angle = angle, gp = gp, debug = debug, check.overlap = check.overlap)
  3. titleGrob(label, x, y, hjust = hj, vjust = vj, angle = angle, gp = modify_list(element_gp, gp), margin = margin, margin_x = margin_x, margin_y = margin_y, debug = element$debug, ...)
  4. element_grob.element_text(title.theme, label = label, angle = ang, x = unit(pos[, 1], "cm"), y = unit(pos[, 2], "cm"), hjust = 0.5, vjust = 0, )
  5. element_grob(title.theme, label = label, angle = ang, x = unit(pos[, 1], "cm"), y = unit(pos[, 2], "cm"), hjust = 0.5, vjust = 0, )
  6. withCallingHandlers(expr, warning = function(w) if (inherits(w, classes)) tryInvokeRestart("muffleWarning"))
  7. suppressWarnings(element_grob(title.theme, label = label, angle = ang, x = unit(pos[, 1], "cm"), y = unit(pos[, 2], "cm"), hjust = 0.5, vjust = 0, ))
  8. build_cube_titles(guide, theme, axes$params)
  9. guide_gengrob.colourcube(X[[i]], ...)
  10. FUN(X[[i]], ...)
  11. lapply(gdefs, guide_gengrob, theme)
  12. guides_gengrob(gdefs, theme)
  13. build_guides(plot$scales, plot$layers, plot$mapping, position, theme, plot$guides, plot$labels)
  14. ggplot_gtable.ggplot_built(data)
  15. ggplot_gtable(data)
  16. print.ggplot(x)
  17. (function (x, ...) UseMethod("print"))(x)

If i suppress the legend with theme(legend.position='none') I can get the graph to work. Similarly if I only use two genes I can see the graph and the legend. I made a dataframe with the umap coordinates and the SCT normalized expression for 3 genes. Tried to look at your code to figure out what was wrong with my input. I am running this on a docker image with RStudio with ggplot2 3.4.3.

Here is my code tes<-subset(immune_combined2, features= c('Zbtb16','Gata3','Rorc')) FD<-cbind(immune_combined2@reductions$umap@cell.embeddings,t(tes@assays$SCT$data)) FD<-data.frame(FD) g1<-ggplot(FD, aes(x = umap_1, y = umap_2))+geom_point(aes(colour = rgb_spec(Zbtb16, Gata3, Rorc)))+theme_classic()

aeheath23 commented 5 months ago

Hi! Did you ever find a solution for this? I'm having similar issues and am struggling to find additional documentation

teunbrand commented 5 months ago

The guide system changed in ggplot2 3.5.0 and I don't know when I'll have the time or motivation to patch this up to a working state.

aeheath23 commented 5 months ago

It's definitely a cool concept in general, hope to see it working in the future!