YuLab-SMU / ggtree

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

multiple ggtree functions error with "could not find function "offspring.tbl_tree_item"" #588

Closed nelsonruth11 closed 10 months ago

nelsonruth11 commented 10 months ago

Prerequisites

Describe you issue

Ask in right place

The functions I'm attempting to use are get_taxa_name and collapse. get_taxa_name works when I don't specify a node, but breaks when I do specify a node. Collapse breaks every time.

hc_tree<-structure(list(edge = structure(c(11L, 11L, 12L, 13L, 14L, 15L, 
15L, 14L, 13L, 16L, 17L, 18L, 19L, 19L, 18L, 17L, 16L, 12L, 1L, 
12L, 13L, 14L, 15L, 2L, 3L, 4L, 16L, 17L, 18L, 19L, 5L, 6L, 7L, 
8L, 9L, 10L), .Dim = c(18L, 2L)), Nnode = 9L, tip.label = c("XPA.85.007", 
"XPA.85.002", "XPA.85.001", "XPA.85.009", "XPA.85.013", "XPA.85.012", 
"XPA.85.011", "XPA.85.010", "XPA.85.014", "XPA.85.003"), edge.length = c(0.0218860096110355, 
0.0218860096110355, 0.0157703305873459, 0.0253235785955029, 0.0304972457273817, 
0.0480189746562429, 0.0500981691928612, 0.135321566311564, 0.0432215089373018, 
0.112235851237383, 0.243285688496605, 0.0742303504425568, 0.0271071192052938, 
0.0260784098242765, 0.134848138865602, 0.374765735649553, 0.159653881377338, 
0.093950590734575), node.label = c("", "", "58", "66", "92", 
"88", "99", "100", "100"), root.edge = 0), .Names = c("edge", 
"Nnode", "tip.label", "edge.length", "node.label", "root.edge"
), class = "phylo", order = "cladewise")

hc_annot_clean <- structure(list(XPA = c("XPA.85.001", "XPA.85.002", "XPA.85.003", 
"XPA.85.007", "XPA.85.009", "XPA.85.010", "XPA.85.011", "XPA.85.012", 
"XPA.85.013", "XPA.85.014"), HCfam = c("H03", "H03", "H03", "H03", 
"H03", "H04", "H01", "H01", "H01", "H03")), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -10L), .Names = c("XPA", 
"HCfam"))

#creating and annotating tree works
p <- ggtree(hc_tree, linetype="solid", layout="circular") %>% collapse(node=17)
p <- p %<+% hc_annot_clean

#highlighting node works
p + geom_nodelab(aes(label=node)) 
  geom_hilight(node=17)

#can print every taxa name
get_taxa_name(p)

#breaks when I specify which node to print taxa from
get_taxa_name(p, node=17)

#collapse also breaks when I specify a node
p <- ggtree(hc_tree, linetype="solid", layout="circular")
p <- collapse(p, node=17)

Both provide the same error message:

Error in offspring.tbl_tree_item(.data = .data, .node = .node, tiponly = tiponly,  : 
  could not find function "offspring.tbl_tree_item

I have seen this issue: https://github.com/YuLab-SMU/tidytree/issues/42 and done the troubleshooting methods there, but nothing worked.

The solutions proposed here did not work either: https://support.bioconductor.org/p/9153297/#9153353

Thanks,

-Nelson

xiangpin commented 10 months ago

Did you try re-install ggtree using BiocManager::install("ggtree", force=T, type = 'source') ?

nelsonruth11 commented 10 months ago

I have, but that also errored:

> BiocManager::install("ggtree", force=T, type = 'source')
'getOption("repos")' replaces Bioconductor standard repositories, see 'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
    CRAN: https://cran.rstudio.com/
Bioconductor version 3.15 (BiocManager 1.30.22), R 4.2.1 (2022-06-23)
Installing package(s) 'ggtree'
trying URL 'https://bioconductor.org/packages/3.15/bioc/src/contrib/ggtree_3.4.4.tar.gz'
Content type 'application/gzip' length 356386 bytes (348 KB)
==================================================
downloaded 348 KB

* installing *source* package ‘ggtree’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in get(x, envir = ns, inherits = FALSE) : 
  object 'warning_wrap' not found
Error: unable to load R code in package ‘ggtree’
Execution halted
ERROR: lazy loading failed for package ‘ggtree’
* removing ‘/Users/nruth/Library/R/x86_64/4.2/library/ggtree’
* restoring previous ‘/Users/nruth/Library/R/x86_64/4.2/library/ggtree’

The downloaded source packages are in
    ‘/private/var/folders/30/w80ljzj12zxdg2rn5tqr9th40015b6/T/RtmpEoEOmK/downloaded_packages’
Installation paths not writeable, unable to update packages
  path: /Library/Frameworks/R.framework/Versions/4.2/Resources/library
  packages:
    boot, class, cluster, codetools, foreign, KernSmooth, lattice, MASS, mgcv, nlme, nnet, rpart, spatial, survival
Old packages: 'classInt', 'flextable', 'Matrix', 'MatrixModels', 'mvtnorm', 'RcppArmadillo', 'terra', 'tidytree'

Rolling back tidytree to 0.4.2 didn't work either

xiangpin commented 10 months ago

This is because you use Bioconductor version 3.15, an old version. Now the released version of Bioconductor is 3.17. You should update Bioconductor first, Or you can try re-install ggtree using remotes::install_github('YuLab-SMU/ggtree').

nelsonruth11 commented 10 months ago

I stepped away for a few days and now things work. Still on the same BiocManager, ggtree 3.4.4, ggtreeExtra 1.6.1. Thanks for your help and a great package, closing.

alephreish commented 10 months ago

I'm not sure it belongs here, but I want to mention the following experience:

I stumbled upon this (getting could not find function "offspring.tbl_tree_item with geom_cladelab) today when creating a conda environment with the latest version of bioconda/bioconductor-ggtree which is 3.8.0, under Linux. Updating to 3.8.2 manually is highly undesirable under this scenario.

ewallace commented 9 months ago

Noting that I ran into the same bug, (getting could not find function "offspring.tbl_tree_item with geom_cladelab) today.

I fixed it by reinstalling packages as described:

devtools::install_version("tidytree", version = "0.4.2")
BiocManager::install("ggtree", force=T, type = 'source')

It would still be great to fix the most recent package versions to remove the bug.