YuLab-SMU / ggtree

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

reroot tree problem #488

Closed liuqian666 closed 2 years ago

liuqian666 commented 2 years ago

Describe you issue

Hello! I'm learning how to use ggtree according to treedata-Book, and here are the code: library(ggtree) library(treeio) library(tidytree) library(TDbook) trda <- tree_boots %>% left_join(df_tip_data, by=c("label" = "Newick_label")) %>% left_join(df_inode_data, by=c("label" = "newick_label")) trda trda2 <- root(trda, outgroup = "Suricata_suricatta", edgelabel = TRUE)

Then it shows: "Error in root.phylo(tree, outgroup = outgroup, node = node, edgelabel = edgelabel, : specified outgroup not in labels of the tree"

The packages are latest version. I've searched in google, and the problem still can't be solved. Hope for your reply. Thank you very much.

xiangpin commented 2 years ago

Which version of your treeio? How about updating treeio package? Please provide your R session information via sessionInfo().

liuqian666 commented 2 years ago

Which version of your treeio? How about updating treeio package? Please provide your R session information via sessionInfo(). R version 4.1.1 (2021-08-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=Chinese (Simplified)_China.936 [2] LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 [4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936

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

other attached packages: [1] ggimage_0.3.0 aplot_0.1.2 phytools_1.0-1 maps_3.4.0 ape_5.6-1
[6] TDbook_0.0.5 ggplot2_3.3.5 tidytree_0.3.5 treeio_1.16.2 ggtree_3.0.4

loaded via a namespace (and not attached): [1] phangorn_2.8.1 tidyselect_1.1.2 purrr_0.3.4
[4] lattice_0.20-45 ggfun_0.0.5 colorspace_2.0-2
[7] vctrs_0.3.8 generics_0.1.2 expm_0.999-6
[10] viridisLite_0.4.0 utf8_1.2.2 gridGraphics_0.5-1
[13] rlang_1.0.1 pillar_1.7.0 withr_2.5.0
[16] glue_1.6.2 lifecycle_1.0.1 munsell_0.5.0
[19] combinat_0.0-8 gtable_0.3.0 codetools_0.2-18
[22] coda_0.19-4 labeling_0.4.2 parallel_4.1.1
[25] fansi_0.5.0 Rcpp_1.0.8 scales_1.1.1
[28] plotrix_3.8-2 clusterGeneration_1.3.7 magick_2.7.3
[31] scatterplot3d_0.3-41 jsonlite_1.8.0 tmvnsim_1.0-2
[34] farver_2.1.0 fastmatch_1.1-3 mnormt_2.0.2
[37] digest_0.6.29 dplyr_1.0.8 numDeriv_2016.8-1.1
[40] grid_4.1.1 quadprog_1.5-8 cli_3.2.0
[43] tools_4.1.1 yulab.utils_0.0.4 magrittr_2.0.1
[46] lazyeval_0.2.2 patchwork_1.1.1 tibble_3.1.5
[49] crayon_1.5.0 tidyr_1.1.4 pkgconfig_2.0.3
[52] ellipsis_0.3.2 MASS_7.3-55 Matrix_1.4-0
[55] ggnewscale_0.4.6 ggplotify_0.1.0 rstudioapi_0.13
[58] R6_2.5.1 igraph_1.2.11 nlme_3.1-153
[61] compiler_4.1.1

liuqian666 commented 2 years ago

I can see the data of "trda" and plot it, but can't reroot any specified outgroup in this tree. Here 're the figure of this tree 图片

xiangpin commented 2 years ago

I know, but your ggtree package suite is not the newest, the root function for treedata was updated in treeio (>=1.18.1). Please update the treeio package.

liuqian666 commented 2 years ago

I know, but your ggtree package suite is not the newest, the root function for treedata was updated in treeio (>=1.18.1). Please update the treeio package.

Oh, I see, thank you very much! I was not very familiar with R, so I get confused with the version of packages. Thank you one more time!(^▽^)