Comparison of functions for comparative phylogenetics

[This article was first published on Recology, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

With all the packages (and beta stage groups of functions) for comparative phylogenetics in R (tested here: picante, geiger, ape, motmot, Liam Revell’s functions), I was simply interested in which functions to use in cases where multiple functions exist to do the same thing. I only show default settings, so perhaps these functions would differ under different parameter settings.  [I am using a Mac 2.4 GHz i5, 4GB RAM]

Get motmot here:
Get Liam Revell’s functions here:

> # Load 
require(motmot); require(geiger); require(picante)
# Make tree
tree <- rcoal(10)

# Transform branch lengths
> system.time( replicate(1000, transformPhylo(tree, model = "lambda", lambda = 0.5)) ) # motmot
   user  system elapsed 
  1.757   0.004   1.762 
> system.time( replicate(1000, lambdaTree(tree, 0.9)) ) # geiger
   user  system elapsed 
  3.708   0.008   3.716 
>   # motmot wins!!!

# Simulate trait evolution
system.time( replicate(1000, transformPhylo.sim(tree, model = "bm")) ) # motmot
   user  system elapsed 
  3.732   0.007   3.741 
> system.time( replicate(1000, rTraitCont(tree, model = "BM")) ) # ape
   user  system elapsed 
  0.312   0.009   0.321 
> system.time( replicate(1000, fastBM(tree)) ) # Revell
   user  system elapsed 
  1.315   0.005   1.320 
>   # ape wins!!!

# Phylogenetically independent contrasts
trait <- rnorm(10)
names(trait) <- tree$tip.label
> system.time( replicate(10000, pic.motmot(trait, tree)$contr[,1])  ) # motmot
   user  system elapsed 
  3.062   0.007   3.070 
> system.time( replicate(10000, pic(trait, tree)) ) # ape
   user  system elapsed 
  2.846   0.007   2.853 
>   # ape wins!!!

# Phylogenetic signal, Blomberg's K
> system.time( replicate(100, Kcalc(trait, tree))  ) # picante
   user  system elapsed 
  1.311   0.005   1.316 
> system.time( replicate(100, phylosig(tree, trait, method = "K")) ) # Revell
   user  system elapsed 
  0.201   0.000   0.202 
>   # Liam Revell wins!!!

# Ancestral character state estimation
> system.time( replicate(100, ace(trait, tree)$ace) ) # ape
   user  system elapsed 
  4.988   0.018   5.007 
> system.time( replicate(100, getAncStates(trait, tree)) ) # geiger
   user  system elapsed 
  2.253   0.005   2.258 
>   # geiger wins!!!

It’s hard to pick an overall winner because not all functions are available in all packages, but there are definitely some functions that are faster than others.

To leave a comment for the author, please follow the link and comment on their blog: Recology. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)