# R Code

I have written a function to ultrametricize non-ultrametric phylogenies in R. You’ll need the packages ape and phangorn in order for this to work. The code is here.

Let’s say you have a non-ultrametric tree called “MyTree.” Just load the function and run the following line of code:

NewTree <- ultrametricize(MyTree)

“NewTree” will be your ultrametricized phylogeny.

I wrote this function as an alternative to the compute.brlen function in ape (described at inside-R and r-phylo as well as the ape reference manual). My function averages the terminal branch lengths of sister taxa and then stretches all the other branches proportionally, scaling them to the longest branch(es). The function is inspired by Sanderson (1997).

If you use this function, please let me know at schachat@stanford.edu. In the future I hope to share additional R functions relating to tree stretching and coevolution.