Adjust branch lengths with node ages: comparison of two methods

April 10, 2011
By

(This article was first published on Recology, and kindly contributed to R-bloggers)

Here is an approach for comparing two methods of adjusting branch lengths on trees: bladj in the program Phylocom and a fxn written by Gene Hunt at the Smithsonian.

Get the code and example files here: http://wp.me/PRT1F-2v
Get phylocom here: http://www.phylodiversity.net/phylocom/

The code uses as input a newick tree file and a text file of node ages.



# This is where the work happens... 
# Directory below needs to have at least three items:
# 1. phylocom executable for windows or mac
# 2. tree newick file
# 3. node ages file as required by phylocom, see their manual
# Output: trees_out is a list of three trees, the original, bladj, and Gene Hunt's method
# Also, within the function all three trees are written to file as PDFs
setwd("/Mac/R_stuff/Blog_etc/Bladjing")
trees_out <- AdjBrLens("tree.txt", "nodeages.txt")
 
# plot trees of three methods together,
# with nodes with age estimates labeled
layout(matrix(1:3, 1, 3))
plot(trees_out[[1]])
nodelabels(trees_out[[1]]$node.label, cex = 0.6)
title("original tree")
plot(trees_out[[2]])
nodelabels(trees_out[[2]]$node.label, cex = 0.6)
title("bladj method")
plot(trees_out[[3]])
nodelabels(trees_out[[3]]$node.label, cex = 0.6)
title("gene hunt method, scalePhylo")
Created by Pretty R at inside-R.org


It is sort of hard to see the differences in the branch length changes here, but the individual output trees will reveal the differences better.

To leave a comment for the author, please follow the link and comment on his blog: Recology.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , ,

Comments are closed.