Introduction

ggtreeSpace is a comprehensive visualization tool design to plot phylomorphospace with the grammar of graphics.

Function

You can plot phylomorphospace easily with ggtreeSpace fuction:

suppressPackageStartupMessages(library(ggtree))
suppressPackageStartupMessages(library(ggtreeSpace))
suppressPackageStartupMessages(library(phytools))
tr <- rtree(15)
td <- fastBM(tr, nsim = 2)
ggtreeSpace(tr, td) +
  geom_tippoint()

ggtreeSpace supports adding phylomorphospace as a graphic layer.

suppressPackageStartupMessages(library(ggtree))
suppressPackageStartupMessages(library(ggtreeSpace))
suppressPackageStartupMessages(library(phytools))
suppressPackageStartupMessages(library(ggplot2))
tr1 <- rtree(15)
td1 <- fastBM(tr1, nsim = 2)
ggplot() +
  geom_treeSpace(tr1, td1)

You can add an additional layer of heatmap base on your data.

suppressPackageStartupMessages(library(ggtree))
suppressPackageStartupMessages(library(ggtreeSpace))
suppressPackageStartupMessages(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.0 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