krassowski / complex-upset

A library for creating complex UpSet plots with ggplot2 geoms
MIT License
469 stars 28 forks source link

upset error: `strip.clip` not defined #173

Closed niehues closed 1 year ago

niehues commented 1 year ago

Describe the bug Calling upset() results in error "Theme element strip.clip is not defined in the element hierarchy."

Code to reproduce

library(ComplexUpset)
movies = ggplot2movies::movies
genres = c('Action', 'Animation', 'Comedy', 'Drama', 'Documentary', 'Romance', 'Short')
upset(
    movies, genres,
    base_annotations=list('Intersection size'=intersection_size(counts=FALSE)),
    min_size=100,
    width_ratio=0.1
)

Expected behavior Reproduce minimal demo upset plot from https://rpubs.com/krassowski/minimal-demo-complex-upset

Screenshots

> upset(
+     movies, genres,
+     base_annotations=list('Intersection size'=intersection_size(counts=FALSE)),
+     min_size=100,
+     width_ratio=0.1
+ )
Error:
! Theme element `strip.clip` is not defined in the element hierarchy.
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/rlang_error>
Error:
! Theme element `strip.clip` is not defined in the element hierarchy.
---
Backtrace:
  1. base `<fn>`(x)
  2. patchwork:::print.patchwork(x)
  3. patchwork:::build_patchwork(plot, plot$layout$guides %||% "auto")
  4. base::lapply(x$plots, plot_table, guides = guides)
  6. patchwork:::plot_table.ggplot(X[[i]], ...)
  7. ggplot2::ggplotGrob(x)
  9. ggplot2:::ggplot_gtable.ggplot_built(ggplot_build(x))
 10. ggplot2:::plot_theme(plot)
 11. base::mapply(validate_element, theme, names(theme), MoreArgs = list(element_tree = get_element_tree()))
 12. ggplot2 `<fn>`(dots[[1L]][[87L]], dots[[2L]][[87L]], element_tree = `<named list>`)
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/rlang_error>
Error:
! Theme element `strip.clip` is not defined in the element hierarchy.
---
Backtrace:
     x
  1. +-base `<fn>`(x)
  2. \-patchwork:::print.patchwork(x)
  3.   \-patchwork:::build_patchwork(plot, plot$layout$guides %||% "auto")
  4.     \-base::lapply(x$plots, plot_table, guides = guides)
  5.       +-patchwork FUN(X[[i]], ...)
  6.       \-patchwork:::plot_table.ggplot(X[[i]], ...)
  7.         \-ggplot2::ggplotGrob(x)
  8.           +-ggplot2::ggplot_gtable(ggplot_build(x))
  9.           \-ggplot2:::ggplot_gtable.ggplot_built(ggplot_build(x))
 10.             \-ggplot2:::plot_theme(plot)
 11.               \-base::mapply(validate_element, theme, names(theme), MoreArgs = list(element_tree = get_element_tree()))
 12.                 \-ggplot2 `<fn>`(dots[[1L]][[87L]], dots[[2L]][[87L]], element_tree = `<named list>`)
 13.                   \-rlang::abort(glue("Theme element `{elname}` is not defined in the element hierarchy."))

Context (required)

ComplexUpset version: 1.3.3

R version details ```R $platform [1] "x86_64-w64-mingw32" $arch [1] "x86_64" $os [1] "mingw32" $system [1] "x86_64, mingw32" $status [1] "" $major [1] "4" $minor [1] "1.2" $year [1] "2021" $month [1] "11" $day [1] "01" $`svn rev` [1] "81115" $language [1] "R" $version.string [1] "R version 4.1.2 (2021-11-01)" $nickname [1] "Bird Hippie" ```
R session information ```R R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ComplexUpset_1.3.3 loaded via a namespace (and not attached): [1] rstudioapi_0.13 magrittr_2.0.3 tidyselect_1.1.2 munsell_0.5.0 colorspace_2.0-3 R6_2.5.1 [7] rlang_1.0.2 fansi_1.0.3 dplyr_1.0.10 ggplot2movies_0.0.1 patchwork_1.1.2 tools_4.1.2 [13] grid_4.1.2 gtable_0.3.1 utf8_1.2.2 cli_3.3.0 ellipsis_0.3.2 digest_0.6.29 [19] tibble_3.1.7 lifecycle_1.0.1 crayon_1.5.1 purrr_0.3.4 ggplot2_3.3.6 vctrs_0.4.1 [25] glue_1.6.2 labeling_0.4.2 compiler_4.1.2 pillar_1.7.0 generics_0.1.3 scales_1.2.1 [31] pkgconfig_2.0.3 ```
krassowski commented 1 year ago

@niehues please see https://github.com/krassowski/complex-upset/issues/165#issuecomment-1328233678. It seems to be a ggplot2/vctrs version incompatibility issue, not a bug in ComplexUpset. I would appreciate if you could confirm whether updating vctrs and restarting R session solves the issue for you too.

niehues commented 1 year ago

@niehues please see #165 (comment). It seems to be a ggplot2/vctrs version incompatibility issue, not a bug in ComplexUpset. I would appreciate if you could confirm whether updating vctrs and restarting R session solves the issue for you too.

Thanks @krassowski for pointing that out. I first updated vctrs from 0.4.1 to 0.5.1, but the error still occurred. After updating ggplot2 from 3.3.6 to 3.4.0 the plot could be reproduced as expected.