phylosignal package comes with functions designed to plot trait values and phylogeny together. These functions are generics for
phylo4d objects. This document present how to use them.
First, we load the package
phylosignal and some others. We will also use the dataset
Here is a phylogenetic tree of 19 carnivora species.
And we create a dataframe of 3 traits for the 19 carnivora species. - Body mass - Random values - Simulated values under a Brownian Motion model along the tree
We can combine phylogeny and traits into a
Once we have a
phylo4d object, we can plot it… There are three plotting functions:
gridplot. These functions are actually wrappers of the function
Each of these functions can be used with one of the 3 tree styles:
fan. For example, here is a dotplot with a cladogram.
And here a gridplot with a fan tree.
Select the ratio of the plot occupied by the tree.
Control which traits to plot and their order.
Add simple error bars.
It is also possible to open a fan tree with a specified angle.
It’s easy to color bars ‘by species’ with a vector.
And for a finer control, one can use a matrix. Here, negative values in red.
Clearly identify traits with colored backgrounds:
For gridplots, cells are colored with a color palette, using the
Combine arguments for sophisticated plots
You can control many other things. See
?multiplot.phylo4d for more informations.
In R, it is often possible to add graphical elements to a plot after drawing it (eg. with
abline(), etc.). This is also possible to use such functions with the plots generated with phylosignal. However, as plots are divided in regions (tree, data, tips), you need special functions to interactively browse among them. These functions are
focusStop. Let’s see how we can use them.
Add a time scale bar to a tree
Add a vertical red line to the 2nd trait
Highlight the clade Ursus with a rectangle