Friday, May 10, 2013

New version of contMap

I just posted a new version of contMap (described here and in my recent MEE article). contMap uses a color scale to map the observed and reconstructed values of a continuous character onto the branches of a phylogeny.

This update just brings contMap into alignment with densityMap in that it (invisibly) returns an object of class "contMap" so that adjusting the plotting parameters can be accomplished without recomputing all the ancestral states.

As I demonstrated on Travis Ingram's recommendation, this - in addition to speeding up re-plotting if we need to change the parameters of our plot - allows us to easily change the palette of colors used to map our trait on the tree. For instance, we can easily change to grayscale. Here I show how we can flip low to high in our color map.

> require(phytools)
Loading required package: phytools
> packageVersion("phytools")
[1] ‘0.2.61’
> tree<-pbtree(n=30)
> x<-fastBM(tree)
> maps<-contMap(tree,x)

Alright, now let's flip the colors:

> maps$cols[]<-maps$cols[length(maps$cols):1]
> plot(maps)

Pretty cool.

Code is here; new phytools build (0.2-61), here.

1 comment:

  1. Dear Liam,
    This is a great improvement to contMap!
    Is it possible to provide the ancestral states instead of using the ML estimations from fastAnc?
    I’ve seen that the function contMap stores internally the results of fasAnc in the object “a”. I’ve tried to modify contMap to store in “a” the ancestral estimations resulting from anc.Bayes (after discarding the burnin, checking for the performance of MCMC and summarizing the values for each node) but I got a message regarding getState (the object was not found).
    Thank you in advance for your help with this issue.


Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.