The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
The 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 carnivora
from adephylo
.
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 phylo4d
object.
Once we have a phylo4d
object, we can plot it… There are three plotting functions: barplot
, dotplot
and gridplot
. These functions are actually wrappers of the function multiplot.phylo4d
.
Each of these functions can be used with one of the 3 tree styles: phylogram
, cladogram
and 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.
mat.e <- matrix(abs(rnorm(19 * 3, 0, 0.5)), ncol = 3,
dimnames = list(tipLabels(p4d), names(tdata(p4d))))
barplot(p4d, error.bar.sup = mat.e, error.bar.inf = mat.e)
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.
mat.col <- ifelse(tdata(p4d, "tip") < 0, "red", "grey35")
barplot(p4d, center = FALSE, bar.col = mat.col)
Clearly identify traits with colored backgrounds:
For gridplots, cells are colored with a color palette, using the cell.col
argument.
gridplot(p4d, tree.type = "fan", tree.ratio = 0.5,
show.trait = FALSE, show.tip = FALSE,
cell.col = terrain.colors(100))
Combine arguments for sophisticated plots
tip.col <- rep(1, nTips(p4d))
tip.col[(mat.col[, 2] == "red") | (mat.col[, 3] == "red")] <- 2
barplot(p4d, center = FALSE, trait.bg.col = c("#F6CED8", "#CED8F6", "#CEF6CE"),
bar.col = mat.col, tip.col = tip.col, trait.font = c(1, 2, 2))
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 points()
, 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 focusTree
, focusTraits
, focusTips
and 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
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.