YuLab-SMU / tidytree

:shower:A Tidy Tool for Phylogenetic Tree Data Manipulation
https://yulab-smu.top/treedata-book/
52 stars 15 forks source link

could not find function "offspring.tbl_tree_item" #40

Closed cagenet closed 1 year ago

cagenet commented 1 year ago

Hello I'm trying to use the treeplot function of clusterProfiler package. I obtained error with my data and so tried with clusterProfiler example. I'm obtaining the following error :

treeplot(ego2, showCategory = 30)
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
 # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
Error in offspring.tbl_tree_item(.data = .data, .node = .node, tiponly = tiponly,  : 
  could not find function "offspring.tbl_tree_item"

here are my code and session info. I updated all my packages. thanks in advance Regards Carine

library(clusterProfiler)
> library(org.Hs.eg.db)
> library(enrichplot)
> library(GOSemSim)
> library(ggplot2)
> library(DOSE)

> data(geneList)
> gene <- names(geneList)[abs(geneList) > 2]
> ego <- enrichGO(gene  = gene,
+                 universe      = names(geneList),
+                 OrgDb         = org.Hs.eg.db,
+                 ont           = "BP",
+                 pAdjustMethod = "BH",
+                 pvalueCutoff  = 0.01,
+                 qvalueCutoff  = 0.05,
+                 readable      = TRUE)
> d <- godata('org.Hs.eg.db', ont="BP")
preparing gene to GO mapping data...
preparing IC data...
> ego2 <- pairwise_termsim(ego, method = "Wang", semData = d)
> treeplot(ego2, showCategory = 30)
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
! # Invaild edge matrix for <phylo>. A <tbl_df> is returned.
Error in offspring.tbl_tree_item(.data = .data, .node = .node, tiponly = tiponly,  : 
  could not find function "offspring.tbl_tree_item"
> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.utf8  LC_CTYPE=French_France.utf8   
[3] LC_MONETARY=French_France.utf8 LC_NUMERIC=C                  
[5] LC_TIME=French_France.utf8    

time zone: Europe/Paris
tzcode source: internal

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

other attached packages:
 [1] DOSE_3.26.1           pathview_1.40.0       BiocManager_1.30.21  
 [4] org.Hs.eg.db_3.17.0   AnnotationDbi_1.62.2  IRanges_2.34.1       
 [7] S4Vectors_0.38.1      Biobase_2.60.0        BiocGenerics_0.46.0  
[10] dbplyr_2.3.3          gprofiler2_0.2.2      cowplot_1.1.1        
[13] enrichplot_1.20.0     lubridate_1.9.2       forcats_1.0.0        
[16] stringr_1.5.0         dplyr_1.1.2           purrr_1.0.1          
[19] readr_2.1.4           tidyr_1.3.0           tibble_3.2.1         
[22] ggplot2_3.4.2         tidyverse_2.0.0       clusterProfiler_4.8.2
[25] GOSemSim_2.26.1      

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3      rstudioapi_0.15.0      
  [3] jsonlite_1.8.7          magrittr_2.0.3         
  [5] farver_2.1.1            rmarkdown_2.23         
  [7] zlibbioc_1.46.0         vctrs_0.6.3            
  [9] memoise_2.0.1           RCurl_1.98-1.12        
 [11] ggtree_3.8.0            htmltools_0.5.5        
 [13] gridGraphics_0.5-1      htmlwidgets_1.6.2      
 [15] plyr_1.8.8              plotly_4.10.2          
 [17] cachem_1.0.8            igraph_1.5.0           
 [19] lifecycle_1.0.3         pkgconfig_2.0.3        
 [21] Matrix_1.6-0            R6_2.5.1               
 [23] fastmap_1.1.1           gson_0.1.0             
 [25] GenomeInfoDbData_1.2.10 digest_0.6.33          
 [27] aplot_0.1.10            ggnewscale_0.4.9       
 [29] colorspace_2.1-0        patchwork_1.1.2        
 [31] RSQLite_2.3.1           labeling_0.4.2         
 [33] fansi_1.0.4             timechange_0.2.0       
 [35] httr_1.4.6              polyclip_1.10-4        
 [37] compiler_4.3.1          bit64_4.0.5            
 [39] withr_2.5.0             downloader_0.4         
 [41] BiocParallel_1.34.2     viridis_0.6.3          
 [43] DBI_1.1.3               ggupset_0.3.0          
 [45] ggforce_0.4.1           MASS_7.3-60            
 [47] HDO.db_0.99.1           tools_4.3.1            
 [49] ape_5.7-1               scatterpie_0.2.1       
 [51] glue_1.6.2              nlme_3.1-162           
 [53] grid_4.3.1              shadowtext_0.1.2       
 [55] reshape2_1.4.4          fgsea_1.26.0           
 [57] generics_0.1.3          gtable_0.3.3           
 [59] tzdb_0.4.0              data.table_1.14.8      
 [61] hms_1.1.3               tidygraph_1.2.3        
 [63] utf8_1.2.3              XVector_0.40.0         
 [65] ggrepel_0.9.3           pillar_1.9.0           
 [67] yulab.utils_0.0.6       splines_4.3.1          
 [69] tweenr_2.0.2            treeio_1.24.2          
 [71] lattice_0.21-8          bit_4.0.5              
 [73] tidyselect_1.2.0        GO.db_3.17.0           
 [75] Biostrings_2.68.1       knitr_1.43             
 [77] gridExtra_2.3           xfun_0.39              
 [79] graphlayouts_1.0.0      KEGGgraph_1.60.0       
 [81] stringi_1.7.12          lazyeval_0.2.2         
 [83] ggfun_0.1.1             yaml_2.3.7             
 [85] evaluate_0.21           codetools_0.2-19       
 [87] ggraph_2.1.0            qvalue_2.32.0          
 [89] Rgraphviz_2.44.0        graph_1.78.0           
 [91] ggplotify_0.1.1         cli_3.6.1              
 [93] munsell_0.5.0           Rcpp_1.0.11            
 [95] GenomeInfoDb_1.36.1     png_0.1-8              
 [97] XML_3.99-0.14           parallel_4.3.1         
 [99] blob_1.2.4              bitops_1.0-7           
[101] viridisLite_0.4.2       tidytree_0.4.4         
[103] scales_1.2.1            crayon_1.5.2           
[105] rlang_1.1.1             fastmatch_1.1-3        
[107] KEGGREST_1.40.0        
xiangpin commented 1 year ago

Did you try re-open a R session and re-run the example? The message did not affect the final result. I can run the example on my computer. PS: I also think we might need to add options('check.tbl_tree.verbose'=FALSE) in the .onAttach function of enrichplot, treeio, ggtree etc.

cagenet commented 1 year ago

hi, Yes I try re-open and re-run. Well there must be something wrong with my R installation. Will check it again. thanks.

cagenet commented 1 year ago

Hello, I used another laptop, re-install everything and still have the same issue.... Thanks

WuHuiCHN commented 1 year ago

I encountered the same issue with the same error Error in offspring.tbl_tree_item(.data = .data, .node = .node, tiponly = tiponly, : could not find function "offspring.tbl_tree_item"

xiangpin commented 1 year ago

please check tidytree >= 0.4.4? Or you can re-install tidytree using remotes::install_github("YuLab-SMU/tidytree"). It seem that the old tidytree was loaded in your environment. Or you can re-install ggtree using remotes::install_github('YuLab-SMU/ggtree').

AroneyS commented 1 year ago

I have the same issue installing ggtree and tidytree via conda. Fixed by re-install ggtree using remotes. SessionInfo:

``` R version 4.3.1 (2023-06-16) Platform: x86_64-conda-linux-gnu (64-bit) Running under: SUSE Linux Enterprise Server 12 SP5 Matrix products: default BLAS/LAPACK: /mnt/hpccs01/work/microbiome/users/aroneys/.conda/envs/r-treedataverse/lib/libopenblasp-r0.3.23.so; LAPACK version 3.11.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ggtreeExtra_1.10.0 here_1.0.1 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2 purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.2 [12] tidyverse_2.0.0 cowplot_1.1.1 treeio_1.24.1 ggtree_3.8.0 loaded via a namespace (and not attached): [1] yulab.utils_0.0.6 utf8_1.2.3 generics_0.1.3 ggplotify_0.1.1 stringi_1.7.12 lattice_0.21-8 hms_1.1.3 digest_0.6.33 magrittr_2.0.3 RColorBrewer_1.1-3 grid_4.3.1 [12] timechange_0.2.0 rprojroot_2.0.3 jsonlite_1.8.7 ggnewscale_0.4.9 ape_5.7-1 fansi_1.0.4 aplot_0.1.10 scales_1.2.1 textshaping_0.3.6 lazyeval_0.2.2 cli_3.6.1 [23] crayon_1.5.2 rlang_1.1.1 bit64_4.0.5 munsell_0.5.0 tidytree_0.4.4 withr_2.5.0 tools_4.3.1 parallel_4.3.1 tzdb_0.4.0 colorspace_2.1-0 vctrs_0.6.3 [34] R6_2.5.1 gridGraphics_0.5-1 lifecycle_1.0.3 bit_4.0.5 ggfun_0.1.1 vroom_1.6.3 ragg_1.2.5 pkgconfig_2.0.3 pillar_1.9.0 gtable_0.3.3 glue_1.6.2 [45] Rcpp_1.0.11 systemfonts_1.0.4 xfun_0.39 tidyselect_1.2.0 knitr_1.43 farver_2.1.1 nlme_3.1-162 patchwork_1.1.2 svglite_2.1.1 labeling_0.4.2 compiler_4.3.1 ```
xiangpin commented 1 year ago

Please make sure the tidytree is >=0.4.4 after loading it using library('tidytree').

> library(tidytree)
> library(ggtree)
> library(treeio)
> sessionInfo()
xiangpin commented 1 year ago

If you are using ggtree on the windows or mac. Please re-install it using BiocManager::install("ggtree", force=T, type = 'source'). Because the windows or mac binary of ggtree on bioconductor was built with old tidytree.

BastiDucreux commented 1 year ago

Hi, I'm having the same tissue and solutions proposed here seemed to fail, here is my sessionInfo() :

> sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 13.4.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

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

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

other attached packages:
[1] enrichplot_1.16.2     treeio_1.20.2         ggtree_3.4.4         
[4] tidytree_0.4.4.001    clusterProfiler_4.4.4 edgeR_3.38.4         
[7] limma_3.52.4    

Is there anything abnormal ?

BastiDucreux commented 1 year ago

Finally managed to solve it via remotes::install_github('YuLab-SMU/ggtree')and re-launching R session

franz-gassner commented 1 year ago

Finally managed to solve it via remotes::install_github('YuLab-SMU/ggtree')and re-launching R session

I had the same issue and this solution worked for me too. Thanks a lot to @xiangpin and @BastiDucreux