Monday, January 30, 2017

Creating a phylogenetic tree in R using phytools::bind.tip in interactive mode

I just made a short video showing how to draw a tree “free-hand” in R using the interactive=TRUE mode of the phytools function bind.tip.

The video is here:

The syntax for this exercise (in case it cannot be easily read from the video) is as follows:

## first load our packages:

## next create a two taxon tree that subtends the root:

## now interactively bind the addt'l tips we want onto this tree:
for(i in 1:length(tips)) tree<-bind.tip(tree,tips[i],interactive=TRUE)

## strip edge lengths (here they were arbitrary):

## plot our tree:

## done.

The objected created in memory is just a regular "phylo" class object, so it can be plotted:


plot of chunk unnamed-chunk-2

written to file:

## [1] "(monkey,(((human,(bonobo,chimp)),gorilla),orangutan));"


In a subsequent post I will demonstrate how to add edge lengths based on divergence dates associated with individual nodes of the tree.

No comments:

Post a Comment

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