ggtree
ggtree copied to clipboard
tibble format: branch.length & label
trafficstars
reprex
library(ape)
library(tidytree)
set.seed(2017)
tree <- rtree(4)
x <- as_tibble(as_tibble(tree))
as.treedata(x)
Output:
'treedata' S4 object'.
...@ phylo:
Phylogenetic tree with 4 tips and 3 internal nodes.
Tip labels:
1, 4, 2, 3
Node labels:
5, 6, 7
Rooted; no branch lengths.
with the following features available:
'branch.length', 'label'.
# The associated data tibble abstraction: 7 × 4
# The 'node', 'label' and 'isTip' are from the phylo tree.
node label.x isTip label.y
<int> <chr> <lgl> <chr>
1 1 1 TRUE t4
2 2 4 TRUE t2
3 3 2 TRUE t1
4 4 3 TRUE t3
5 5 5 FALSE NA
6 6 6 FALSE NA
7 7 7 FALSE NA
Description
If the as.treedata input is a tibble (or data.table) instead of a tbl_tree, neither branch.length nor label is recognized correctly. The function doc doesn't include info on how to deal with this formatting issue, which would be very helpful. There also seems to be no as_tbl_tree function for object conversion.
SessionInfo
R version 4.1.2 (2021-11-01)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS
Matrix products: default
BLAS/LAPACK: /tmp/global2/nyoungblut/code/general/conda_envs/general-tidy-seq/lib/libopenblasp-r0.3.18.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ape_5.6-2 ggtree_3.2.0 clustermq_0.8.95.3 LeyLabRMisc_0.2.1
[5] tidytable_0.6.7 data.table_1.14.2 ggplot2_3.3.5 tidyr_1.2.0
[9] dplyr_1.0.7
loaded via a namespace (and not attached):
[1] treeio_1.18.0 pbdZMQ_0.3-7 tidyselect_1.1.1 repr_1.1.4
[5] purrr_0.3.4 lattice_0.20-45 ggfun_0.0.5 colorspace_2.0-3
[9] vctrs_0.3.8 generics_0.1.2 htmltools_0.5.2 base64enc_0.1-3
[13] utf8_1.2.2 gridGraphics_0.5-1 rlang_0.4.12 R.oo_1.24.0
[17] pillar_1.7.0 glue_1.6.2 withr_2.5.0 R.utils_2.11.0
[21] uuid_1.0-3 lifecycle_1.0.1 plyr_1.8.6 munsell_0.5.0
[25] gtable_0.3.0 R.methodsS3_1.8.1 codetools_0.2-18 evaluate_0.15
[29] labeling_0.4.2 fastmap_1.1.0 parallel_4.1.2 fansi_1.0.2
[33] IRdisplay_1.1 Rcpp_1.0.8 scales_1.1.1 IRkernel_1.3
[37] jsonlite_1.8.0 farver_2.1.0 digest_0.6.29 aplot_0.1.2
[41] grid_4.1.2 cli_3.2.0 tools_4.1.2 yulab.utils_0.0.4
[45] magrittr_2.0.2 lazyeval_0.2.2 patchwork_1.1.1 tibble_3.1.6
[49] crayon_1.5.0 pkgconfig_2.0.3 tidytree_0.3.9 ellipsis_0.3.2
[53] ggplotify_0.1.0 R6_2.5.1 nlme_3.1-155 compiler_4.1.2