YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/treedata-book/
830 stars 172 forks source link

Some `layout` options cause error in ggtree() #545

Open cmt2 opened 1 year ago

cmt2 commented 1 year ago

Some of the options for the layout argument in ggtree::ggtree() cause an error (session and package version info below). The options that cause error are:

'ape' 'slanted' 'radial' 'equal_angle' 'daylight'

Session and version info:

R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.6
ggplot2_3.4.0
ggtree_3.6.0 

Reproducible example and error output:

> tree <- ape::rtree(100)
> ggtree::ggtree(tree, layout = "ape")
Error in `stat_tree()`:
! Problem while converting geom to grob.
ℹ Error occurred in the 1st layer.
Caused by error in `check.length()`:
! 'gpar' element 'lwd' must not be length 0
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/rlang_error>
Error in `stat_tree()`:
! Problem while converting geom to grob.
ℹ Error occurred in the 1st layer.
Caused by error in `check.length()`:
! 'gpar' element 'lwd' must not be length 0
---
Backtrace:
  1. base (local) `<fn>`(x)
  2. ggplot2:::print.ggplot(x)
  4. ggplot2:::ggplot_gtable.ggplot_built(data)
  5. ggplot2:::by_layer(...)
 12. ggplot2 (local) f(l = layers[[i]], d = data[[i]])
 13. l$draw_geom(d, layout)
 14. ggplot2 (local) draw_geom(..., self = self)
 15. self$geom$draw_layer(...)
 16. ggplot2 (local) draw_layer(..., self = self)
 17. base::lapply(...)
 18. ggplot2 (local) FUN(X[[i]], ...)
 20. self$draw_panel(...)
 21. ggtree (local) draw_panel(...)
 24. grid::gpar(...)
 25. grid:::validGP(list(...))
 26. grid (local) numnotnull("lwd")
 27. grid (local) check.length(gparname)
 28. base::stop(...)
Run `rlang::last_trace()` to see the full context.
xiangpin commented 1 year ago

This problem is caused by the latest version (3.4.0) of ggplot2. The latest patch has been submitted to Bioconductor, and the 3.6.1 version might be online tomorrow. You can refer to the answer.

cmt2 commented 1 year ago

Thank you! Installing from github does solve this problem. Hoping the patch makes it to Bioconductor soon.