Title: | Visualizing Phylomorphospaces using 'ggtree' |
---|---|
Description: | This package is a comprehensive visualization tool specifically designed for exploring phylomorphospace. It not only simplifies the process of generating phylomorphospace, but also enhances it with the capability to add graphic layers to the plot with grammar of graphics to create fully annotated phylomorphospaces. It also provide some utilities to help interpret evolutionary patterns. |
Authors: | Guangchuang Yu [aut, cre, ths, cph] , Li Lin [ctb] |
Maintainer: | Guangchuang Yu <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.3.0 |
Built: | 2024-11-29 06:25:46 UTC |
Source: | https://github.com/bioc/ggtreeSpace |
A layer of phylomorphospace
geom_treespace(tr, data, mapping = NULL, ...)
geom_treespace(tr, data, mapping = NULL, ...)
tr |
a tree object. This should be an object of class that is compatible with 'ggtree', typically an object of class 'phylo' or 'treedata'. |
data |
Trait data as a data frame or matrix, where each row represents a tree tip or node. For data matching the number of tips, ancestral traits are reconstructed for internal nodes. For data equal to the total number of nodes, values are directly used as node coordinates. |
mapping |
aesthetic mapping |
... |
additional parameters for customization with 'geom_tree'. Please use '?ggtree::geom_tree' for more information. |
ggplot object
library(ggplot2) library(ggtree) library(phytools) tr <- rtree(10) a <- fastBM(tr, nsim = 2) p <- ggplot() + geom_treespace(tr, a)
library(ggplot2) library(ggtree) library(phytools) tr <- rtree(10) a <- fastBM(tr, nsim = 2) p <- ggplot() + geom_treespace(tr, a)
Add a layer of heat map with trait data
geom_tsheatmap(trait, resolution = 0.001, bins = 24, ...)
geom_tsheatmap(trait, resolution = 0.001, bins = 24, ...)
trait |
trait data. It can be either a data frame with node numbers and trait, or a trait name present in the plot data. |
resolution |
resolution of the heat map |
bins |
number of contour bins |
... |
additional parameters for 'geom_contour_filled'. Please use '?ggplot2::geom_contour_filled' for more information. |
ggplot object
library(ggtree) library(phytools) library(ggplot2) library(ggtreeSpace) tr <- rtree(15) td <- fastBM(tr, nsim = 2, bounds = c(0, Inf)) col <- colorRampPalette(c( "#FFFFCC", "#FFEDA0", "#FED976", "#FEB24C", "#FD8D3C", "#FC4E2A", "#E31A1C", "#B10026" ))(24) tdex <- data.frame( z = fastBM(tr, nsim = 1, bounds = c(0, Inf)), node = 1:15 ) p <- ggtreespace(tr, td) p %<+% tdex + geom_tippoint() + geom_tsheatmap(trait = "z", alpha = 0.7, resolution = 0.01, bin = 24) + scale_fill_manual( values = col, guide = guide_colorsteps(show.limits = TRUE) ) + theme_treespace2() + theme( legend.key.height = unit(1, "null"), legend.justification.top = "right" )
library(ggtree) library(phytools) library(ggplot2) library(ggtreeSpace) tr <- rtree(15) td <- fastBM(tr, nsim = 2, bounds = c(0, Inf)) col <- colorRampPalette(c( "#FFFFCC", "#FFEDA0", "#FED976", "#FEB24C", "#FD8D3C", "#FC4E2A", "#E31A1C", "#B10026" ))(24) tdex <- data.frame( z = fastBM(tr, nsim = 1, bounds = c(0, Inf)), node = 1:15 ) p <- ggtreespace(tr, td) p %<+% tdex + geom_tippoint() + geom_tsheatmap(trait = "z", alpha = 0.7, resolution = 0.01, bin = 24) + scale_fill_manual( values = col, guide = guide_colorsteps(show.limits = TRUE) ) + theme_treespace2() + theme( legend.key.height = unit(1, "null"), legend.justification.top = "right" )
This function plots a phylomorphospace by mapping a tree object onto a vector space like morphospace.
ggtreespace(tr, data, mapping = NULL, ...)
ggtreespace(tr, data, mapping = NULL, ...)
tr |
a tree object. This should be an object of class that is compatible with 'ggtree', typically an object of class 'phylo' or 'treedata'. |
data |
Trait data as a data frame or matrix, where each row represents a tree tip or node. For data matching the number of tips, ancestral traits are reconstructed for internal nodes. For data equal to the total number of nodes, values are directly used as node coordinates. |
mapping |
aesthetic mapping |
... |
additional parameters for customization with 'ggtree'. Please use '?ggtree::ggtree' for more information. |
ggtreeSpace object
library(ggtree) library(phytools) library(ggtreeSpace) tr <- rtree(15) td <- fastBM(tr, nsim = 2) ggtreespace(tr, td) + geom_tippoint()
library(ggtree) library(phytools) library(ggtreeSpace) tr <- rtree(15) td <- fastBM(tr, nsim = 2) ggtreespace(tr, td) + geom_tippoint()
Make plot data for ggtreespace. This function processes a phylogenetic tree and associated trait data to create a data frame suitable for plotting with 'ggtreespace'.
make_ts_data(tr, data)
make_ts_data(tr, data)
tr |
a tree object. This should be an object of class that is compatible with 'ggtree', typically an object of class 'phylo' or 'treedata'. |
data |
Trait data as a data frame or matrix, where each row represents a tree tip or node. For data matching the number of tips, ancestral traits are reconstructed for internal nodes. For data equal to the total number of nodes, values are directly used as node coordinates. |
ggplot object
library(ggplot2) library(ggtree) library(phytools) tr <- rtree(10) a <- fastBM(tr, nsim = 2) trd <- make_ts_data(tr, a)
library(ggplot2) library(ggtree) library(phytools) tr <- rtree(10) a <- fastBM(tr, nsim = 2) trd <- make_ts_data(tr, a)
This function creates a scatterplot matrix for comparing multiple continuous traits mapped onto the same phylogenetic tree, providing a visual representation of trait correlations and evolutionary patterns.
phylospm( tr, traits = NULL, title = NULL, xAxisLabels = NULL, yAxisLabels = NULL, tr.params = list(size = 1, colors = NULL, panel.grid = TRUE), sptr.params = list(tippoint = TRUE, tiplab = FALSE, labdir = "horizonal", panel.grid = TRUE) )
phylospm( tr, traits = NULL, title = NULL, xAxisLabels = NULL, yAxisLabels = NULL, tr.params = list(size = 1, colors = NULL, panel.grid = TRUE), sptr.params = list(tippoint = TRUE, tiplab = FALSE, labdir = "horizonal", panel.grid = TRUE) )
tr |
A phylogenetic tree |
traits |
A data frame containing multiple column of trait data |
title |
Set the title for the phylogenetic scatterplot matrix |
xAxisLabels |
Set the label of the x axis |
yAxisLabels |
Set the label of the y axis |
tr.params |
List of parameters to customize the phylogenetic tree with continuous trait mapping as continuous colors on the branch. Users can add tip point, add tip label, set tip label direction and set background gird. |
sptr.params |
List of parameters to customize the phylomorphospaces. Users can add tip point, add tip label, set tip label direction and set background gird. |
phylospm object
library(ggtree) library(phytools) library(ggtreeSpace) tr <- rtree(10) a <- fastBM(tr, nsim = 4) phylospm(tr, a)
library(ggtree) library(phytools) library(ggtreeSpace) tr <- rtree(10) a <- fastBM(tr, nsim = 4) phylospm(tr, a)
Phylomorphospace theme No.1, with arrow-end axis and grey panel grid.
theme_treespace(...)
theme_treespace(...)
... |
additional parameters for 'ggplot2::theme'. Please use '?ggplot2::theme()' to learn more information. |
a theme object with arrow-end axis
library(ggtree) library(phytools) library(ggtreeSpace) tr <- rtree(15) td <- fastBM(tr, nsim = 2) ggtreespace(tr, td) + geom_tippoint() + theme_treespace()
library(ggtree) library(phytools) library(ggtreeSpace) tr <- rtree(15) td <- fastBM(tr, nsim = 2) ggtreespace(tr, td) + geom_tippoint() + theme_treespace()
Phylomorphospace theme No.2, with blank background and panel border.
theme_treespace2(...)
theme_treespace2(...)
... |
additional parameters for 'ggplot2::theme'. Please use '?ggplot2::theme()' to learn more information. |
a theme object with blank background and panel border
library(ggtree) library(phytools) library(ggtreeSpace) tr <- rtree(15) td <- fastBM(tr, nsim = 2) ggtreespace(tr, td) + geom_tippoint() + theme_treespace2()
library(ggtree) library(phytools) library(ggtreeSpace) tr <- rtree(15) td <- fastBM(tr, nsim = 2) ggtreespace(tr, td) + geom_tippoint() + theme_treespace2()