Saturday, September 26, 2020

Projecting a continuous trait onto the branches of a tree using variable edge widths

Following on my prior three posts (1, 2, 3), a fourth new addition to the latest CRAN update to phytools is a method for mapping the observed and reconstructed values of a continuous character onto a tree using variable width edges: edge.widthMap.

Here's a quick demo of how it works.

First, let's load some data. This phylogenetic tree and dataset were pulled from Garland et al. (1992).

data(mammal.tree)
data(mammal.data)
lnHomeRange<-setNames(log(mammal.data$homeRange),
    rownames(mammal.data))

For our next step we create our object for plotting using edge.widthMap.

object<-edge.widthMap(mammal.tree,lnHomeRange)
object
## Object of class "edge.widthMap" containing:
## (1) Phylogenetic tree with 49 tips and 48 internal nodes.
## (2) Vector of node values for a mapped quantitative
##     trait.

Finally, let's make our plot.

plot(object,border=1,color=palette()[7],
    legend="log(home range)")