Monday, September 29, 2014

Redundant phytools functions to replicate phylogenies in a list

I realized the other day that I had inadvertently programmed two different functions in phytools that do exactly the same thing. This was bound to happen as phytools has grown into a pretty substantial endeavor with well over 100 different functions & methods.

Specifically, the phytools function repPhylo (originally described here is exactly equivalent (although derived independently) to phytools S3 rep methods for objects of class "phylo" and "multiPhylo" (added about a year later, here).

I have now removed this redundancy, although repPhylo still exists as a valid alias for rep.phylo (or rep.multiPhylo).

Here's a quick & dirty demo of how these methods work in the latest version of phytools (not yet on CRAN):

library(phytools)
## Loading required package: ape
## Loading required package: maps
packageVersion("phytools")
## [1] '0.4.36'
## simulate tree
tree<-pbtree(n=26,tip.label=LETTERS)
## S3 method rep for objects of class "phylo"
trees<-rep(tree,4)
par(mfrow=c(2,2))
plotTree(trees)

plot of chunk unnamed-chunk-1

## simulate trees
trees<-pbtree(n=12,tip.label=LETTERS[1:12],nsim=3)
## S3 method rep for object of class "multiPhylo"
trees<-rep(trees,2)
par(mfrow=c(2,3))
plotTree(trees)

plot of chunk unnamed-chunk-1

That's it!

Friday, September 19, 2014

Small update to fancyTree method "phenogram95" to permit control of shading

Today I made what amounts to quite a small update to the "phenogram95" method in the function fancyTree. This function plots a 95% high probability density region around a reconstructed 'traitgram' (i.e., a projection of the tree into a space defined by one phenotypic trait on the vertical axis and type since the root on the horizontal axis). This visual effect is accomplished by increasingly transparently shaded lines. The update permits user control of transparency shading which, at present, is completely arbitrary. Here's what that looks like:

library(phytools)
packageVersion("phytools")
## [1] '0.4.35'
## simulate a tree & data
tree<-pbtree(n=26,tip.label=LETTERS,scale=1)
x<-fastBM(tree)
## create 95% traitgram
fancyTree(tree,x=x,type="phenogram95",tlim=c(1,25)) ## light shading

plot of chunk unnamed-chunk-1

fancyTree(tree,x=x,type="phenogram95",tlim=c(10,50)) ## dark shading

plot of chunk unnamed-chunk-1

Transparency upper & lower limits should be specified on the interval (0,99).

For the latest 'bleeding edge' version of phytools with this update see the phytools page. For more information on this and other plotting methods, check out my recent book chapter.

That's it!