Thursday, May 10, 2012

New version of drop.tip.simmap

OK, I just posted a new version of drop.tip.simmap which modifies both the $maps and $mapped.edge elements of the modified tree object created by (say) read.simmap or sim.history. Direct link to the code is here, but I have also built a new version (0.1-81) of phytools containing this update. You can download and install from source here.

Nothing spectacular, I just created this function from the tree pruning function that I completed (with some errors, now fixed in this version) this afternoon. Let's check it out:

> # first load from source or install new phytools
> install.packages("phytools_0.1-81.tar.gz",type="source", repos=NULL)
* installing *source* package 'phytools' ...
* DONE (phytools)
> require(phytools)
Loading required package: phytools
> # now simulate tree or read from file (here simulated)
> tree<-pbtree(n=20,scale=2)
> Q<-matrix(c(-2,1,1,1,-2,1,1,1,-2),3,3)
> mtree<-sim.history(tree,Q)
> # this is the full, unpruned tree
> plotSimmap(mtree,pts=F,lwd=3)
> # pick some tips to prune at random
> tips<-sample(tree$tip.label,5)
> tips
[1] "t20" "t8" "t5" "t16" "t14"
> ptree<-drop.tip.simmap(mtree,tips)
> plotSimmap(ptree,lwd=3,pts=F)

Well, this seems to work - but I welcome feedback from users that try it on their own data or from trees read from file. Good luck!

No comments:

Post a Comment