Introduction
In the evolving field of evolutionary biology and phylogenetics, visualizing phylomorphospace plays a pivotal role in understanding the diversification of traits across species within a phylogenetic framework. However, as research progresses, datasets not only increase in size but also in the complexity of their relationships, which makes the visualization process more challenging and damands advanced visualization solutions.
Here, we introduce ggtreeSpace
, a comprehensive visualization tool designed for plotting fully annotated phylomorphospaces using the grammar of graphics, offering researchers with extensive control and customization options for their phylomorphospace plots.
Currently, there are other Bioconductor packages like phytools
that also support creating a phylomorphospace. phytools
facilitates plotting with its phylomorphospace
function, which allows for customization and annotation, including the ability to set edge and node colors. And it also supports plotting 3d phylomorphospace with phylomorphospace3d
function.
Compares to phytools
, ggtreeSpace
focus on crafting 2D phylomorphospaces using the grammar of graphics, enabling the creation of fully annotated visualizations through a layer-by-layer annotation approach. This method provides researchers with a more intuitive and user-friendly experience in plotting, enhancing the logic and visualization clarity. ggtreeSpace
not only includes unique layers specifically designed for phylomorphospace annotations but also supports layers from the ggplot2 and ggtree communities, offering a wide range of customization options. Additionally, it supports adding phylomorphospace as a graphic layer, enabling the combination of tree-like structures with various types of spaces, such as maps or histological staining images, thus broadening the applications of phylomorphospace analysis.
Function
You can plot basic phylomorphospace easily with the ggtreeSpace
fuction, and add annotation to it with the +
operator. In this example, we add symbolic point to the tip of phylomorphospace:
library(ggtree)
library(ggtreeSpace)
library(phytools)
tr <- rtree(15)
td <- fastBM(tr, nsim = 2)
ggtreeSpace(tr, td) +
geom_tippoint()
ggtreeSpace also supports adding phylomorphospace as a graphic layer. This can broaden the applications of phylomorphospace analysis by combine the tree-like structure with different types of spaces.
library(ggtree)
library(ggtreeSpace)
library(phytools)
library(ggplot2)
tr1 <- rtree(15)
td1 <- fastBM(tr1, nsim = 2)
ggplot() +
geom_treeSpace(tr1, td1)
You can also introduce an additional heatmap layer based on your data, adding another dimension to better elucidate evolutionary patterns.
library(ggtree)
library(ggtreeSpace)
library(phytools)
tr2 <- rtree(15)
td2 <- fastBM(tr2, nsim = 2, bounds = c(0, Inf))
tdex2 <- data.frame(z = fastBM(tr2, nsim = 1),
node = 1:15)
p <- ggtreeSpace(tr2, td2)
p %<+% tdex2 +
geom_tippoint() +
geom_tsheatmap(trait = "z", alpha = 0.7 ,resolution = 0.01, bin = 12)
Session information
Here is the output of sessionInfo()
on the system on which this document was compiled:
## R Under development (unstable) (2024-03-18 r86148)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.4 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB LC_COLLATE=C
## [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
##
## time zone: America/New_York
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ggplot2_3.5.0 phytools_2.1-1 maps_3.4.2 ape_5.7-1
## [5] ggtreeSpace_0.99.1 ggtree_3.11.1
##
## loaded via a namespace (and not attached):
## [1] fastmatch_1.1-4 gtable_0.3.4 xfun_0.42
## [4] bslib_0.6.2 lattice_0.22-6 numDeriv_2016.8-1.1
## [7] quadprog_1.5-8 vctrs_0.6.5 tools_4.4.0
## [10] generics_0.1.3 yulab.utils_0.1.4 parallel_4.4.0
## [13] tibble_3.2.1 fansi_1.0.6 highr_0.10
## [16] pkgconfig_2.0.3 Matrix_1.7-0 ggplotify_0.1.2
## [19] scatterplot3d_0.3-44 lifecycle_1.0.4 farver_2.1.1
## [22] compiler_4.4.0 treeio_1.27.0 prettydoc_0.4.1
## [25] munsell_0.5.0 mnormt_2.1.1 combinat_0.0-8
## [28] akima_0.6-3.4 codetools_0.2-19 ggfun_0.1.4
## [31] htmltools_0.5.7 sass_0.4.9 yaml_2.3.8
## [34] lazyeval_0.2.2 pillar_1.9.0 jquerylib_0.1.4
## [37] tidyr_1.3.1 MASS_7.3-60.2 cachem_1.0.8
## [40] clusterGeneration_1.3.8 iterators_1.0.14 foreach_1.5.2
## [43] nlme_3.1-164 phangorn_2.11.1 tidyselect_1.2.1
## [46] aplot_0.2.2 digest_0.6.35 dplyr_1.1.4
## [49] purrr_1.0.2 labeling_0.4.3 fastmap_1.1.1
## [52] grid_4.4.0 colorspace_2.1-0 expm_0.999-9
## [55] cli_3.6.2 magrittr_2.0.3 patchwork_1.2.0
## [58] optimParallel_1.0-2 utf8_1.2.4 withr_3.0.0
## [61] scales_1.3.0 sp_2.1-3 rmarkdown_2.26
## [64] igraph_2.0.3 memoise_2.0.1 coda_0.19-4.1
## [67] evaluate_0.23 knitr_1.45 doParallel_1.0.17
## [70] viridisLite_0.4.2 gridGraphics_0.5-1 rlang_1.1.3
## [73] isoband_0.2.7 Rcpp_1.0.12 glue_1.7.0
## [76] tidytree_0.4.6 jsonlite_1.8.8 R6_2.5.1
## [79] fs_1.6.3