ggtree functions suddenly stopped working: "Error in offspring.tbl_tree_item(..."
1
0
Entering edit mode
Hank • 0
@32a0ec3b
Last seen 9 months ago
United States

I am fairly new to ggtree and it had been working until today.

Today, several functions stopped working:

-- MRCA(), geom_hilight(), and geom_cladelab()

I have searched the web for answers.

Example:

> sessionInfo( )
R version 4.3.1 (2023-06-16)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.4.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Chicago
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ape_5.7-1      tidytree_0.4.4 ggtree_3.8.0  

loaded via a namespace (and not attached):
 [1] gtable_0.3.3        jsonlite_1.8.7      BiocManager_1.30.21 dplyr_1.1.2        
 [5] compiler_4.3.1      tidyselect_1.2.0    aplot_0.1.10        Rcpp_1.0.11        
 [9] gridGraphics_0.5-1  parallel_4.3.1      ggplotify_0.1.1     tidyr_1.3.0        
[13] ggfun_0.1.1         scales_1.2.1        lattice_0.21-8      ggplot2_3.4.2      
[17] R6_2.5.1            labeling_0.4.2      generics_0.1.3      patchwork_1.1.2    
[21] yulab.utils_0.0.6   tibble_3.2.1        munsell_0.5.0       pillar_1.9.0       
[25] rlang_1.1.1         treeio_1.24.2       utf8_1.2.3          lazyeval_0.2.2     
[29] cli_3.6.1           withr_2.5.0         magrittr_2.0.3      digest_0.6.33      
[33] grid_4.3.1          rstudioapi_0.15.0   lifecycle_1.0.3     nlme_3.1-162       
[37] vctrs_0.6.3         glue_1.6.2          farver_2.1.1        fansi_1.0.4        
[41] colorspace_2.1-0    purrr_1.0.1         tools_4.3.1         pkgconfig_2.0.3    

> nwk <- system.file("extdata", "sample.nwk", package="treeio")
> tree <- read.tree(nwk)
> p <- ggtree(tree) + geom_text2(aes(subset=!isTip, label=node), hjust=-.3) +
+   geom_tiplab()
> p
> MRCA(tree, tip=c('A', 'E'))
Error in MRCA.phylo(tree, tip = c("A", "E")) : 
  argument ".node1" is missing, with no default
> MRCA(p, tip=c('A', 'E'))
Error in MRCA.ggtree(p, tip = c("A", "E")) : 
  argument ".node1" is missing, with no default
> p$data[17,]
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
# A tibble: 1 × 9
  parent  node branch.length label isTip     x     y branch angle
   <int> <int>         <dbl> <chr> <lgl> <dbl> <dbl>  <dbl> <dbl>
1     16    17            10 NA    FALSE    27  9.94     22  275.
> p + geom_hilight(node=18, fill="blue")
> p + geom_cladelab(node=18, label="Node 18")
Error in offspring.tbl_tree_item(.data = .data, .node = .node, tiponly = tiponly,  : 
  could not find function "offspring.tbl_tree_item"

geom_hilight() highlights only a very thin bad just at the internal node 17, and does not highlight the entire clade. p + geom_cladelab(node=18, label="Node 18") does not draw a cladogram.

I wonder if there is a conflict with some of my packages, but would like to avoid unloading and reloading hundreds of packages in my R framework.

I'm at a loss, and open to any suggestions. Thank you all for your time and attention!

ggtree • 3.5k views
ADD COMMENT
1
Entering edit mode

I started having this exact same problem with geom_hilight and geom_cladelab several days ago as well. I don't know why this is the case, but I was able to trace it to an update in the tidytree package. When I reverted back to a previous version of tidytree (see below), both functions started working again.

if(!require("tidytree", quietly=TRUE))
  install_version("tidytree", version = "0.4.2")
ADD REPLY
0
Entering edit mode

Thanks! I just tried it and it is "working" again, and now I get this warning:

Warning messages: 1: The following aesthetics were dropped during statistical transformation: node, parent This can happen when ggplot fails to infer the correct grouping structure in the data. Did you forget to specify agroupaesthetic or to convert a numerical variable into a factor?

ADD REPLY
0
Entering edit mode

Hmm, I've not seen that warning before.

ADD REPLY
0
Entering edit mode
@xshuangbin-21585
Last seen 5 months ago
Germany

Please refer to the answer.

ADD COMMENT

Login before adding your answer.

Traffic: 555 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6