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)")
Some people seem to like this. I think it looks cool.
Hi Liam,
ReplyDeleteI agree, I like this! Is there a way to combine edge.widthMap with a contMap object? I am trying to map two continuous datasets to my tree.
Thanks! Chelsea
You could - but it would be a bit of work.... One trick that jumps to mind is that any "simmap" object can be converted to a standard "phylo" object with singleton nodes using map.to.singleton. Since a "contMap" object encodes the continuous trait along edges using a "simmap" style object, this also applies to the "contMap" tree. Then, you just need to draw the tree with different edge widths (for all the singleton nodes) and different colors. Tell us if you get it to work with this advice, otherwise feel free to email me.
DeleteThis is great Liam! Like Chelsea, I'm wondering if it is possible to color the tree with information of a discrete character, like the function densityMap does. Thanks!
ReplyDelete