Tutorial 11: Visualizing trait evolution with phylomorphospace
Objectives
Plot body mass and brain size together and connect reconstructed ancestors to descendants in trait space.
Prerequisites and working directory
Install PhyKIT and create a working directory. Save the tutorial files there under the listed names, then run the commands from that directory.
mkdir phykit-tutorial-11
cd phykit-tutorial-11
Download these example files into that directory.
Workflow
Phylomorphospace plots overlay the phylogeny onto a two-dimensional trait space, connecting species to their ancestors via edges that trace the evolutionary trajectory of traits (Sidlauskas 2008). Internal node positions are estimated by maximum-likelihood ancestral state reconstruction. This visualization reveals how lineages have moved through morphospace over evolutionary time — showing convergence, divergence, and the overall geometry of trait evolution.
Hypothetical study question. Suppose we want to visualize how body mass and brain size have coevolved across our eight mammal species. Do closely related species cluster together in trait space? Have any lineages converged on similar body mass–brain size combinations despite being distantly related?
PhyKIT's phylomorphospace command (aliases: phylomorpho, phmo) generates these
plots directly from the command line.
Step 0: Prepare data
Two input files are needed: a phylogenetic tree and a tab-delimited multi-trait file with a
header row (same format as for phylogenetic PCA). When the trait file has exactly two trait
columns, they are automatically selected. With three or more traits, you must specify
which two traits to plot using --trait-x and --trait-y.
Step 1: Generate a phylomorphospace plot
Since our trait file has three traits (body_mass, brain_size, longevity), we specify which two to plot:
phykit phylomorphospace \
-t tree_simple.tre \
-d tree_simple_multi_traits.tsv \
--trait-x body_mass \
--trait-y brain_size
This generates a plot file (phylomorphospace_plot.png by default) showing:
Tip points positioned at observed trait values for each species
Internal nodes positioned at ML-reconstructed ancestral trait values
Tree edges connecting parent and child nodes, colored by distance from the root (coolwarm colormap with colorbar)
Tip labels identifying each species
Interpretation. In the resulting plot, species with large body mass and brain size (bear, sea_lion, seal) cluster in the upper right, while small-bodied species (weasel, cat) appear in the lower left. The tree edges show the evolutionary trajectories: the ancestral node reconstructions reveal whether lineages traveled through morphospace gradually or underwent rapid shifts.
Step 2: Export data as JSON
For programmatic access to the tip data and reconstructed ancestral states:
phykit phylomorphospace \
-t tree_simple.tre \
-d tree_simple_multi_traits.tsv \
--trait-x body_mass \
--trait-y brain_size \
--json
The JSON output includes the tip data, selected traits, and output path, enabling custom post-processing or alternative visualizations.
Summary
In this tutorial, we used phylomorphospace to visualize the coevolution of body mass and brain size across a mammal phylogeny. The plot reveals evolutionary trajectories through trait space and highlights patterns of convergence or divergence. Combined with phylogenetic PCA and phylogenetic signal analyses, phylomorphospace provides a powerful complement for understanding multivariate trait evolution.
For methodological details, see
Sidlauskas (2008).
The R equivalent is phytools::phylomorphospace()
(Revell 2012).
Expected artifacts
The command writes a phylomorphospace plot. The JSON output contains the selected traits, tip values, and plot path.
Troubleshooting
Run
phykit <command> --helpto compare an invocation with the live interface.Confirm that downloaded files are in the current working directory and retain the filenames shown in the tutorial.
For parsing errors, compare taxon names exactly across alignments, trees, and trait tables, including capitalization and underscores.
See Troubleshooting for installation, format, and error-reporting guidance.