[R-sig-phylo] Adding a taxon to a pre-exisiting tree

Liam J. Revell liam.revell at umb.edu
Sat Apr 2 05:33:55 CEST 2011

Hi Matthew.

I don't doubt that other members of the list have better suggestions, 
but it is possible to add a tip in all possible places using bind.tree() 
in "ape."

For instance, starting with a random unrooted tree with, say, 4 taxa:

# create a 5th species, here "t5", to add as a "phylo" object
# [I don't think this can be avoided with bind.tree()]
# add the new tip to all edges of the tree
trees<-list(); class(trees)<-"multiPhylo"
for(i in 1:nrow(tree$edge))
# now plot them to see what we have done

Of course I would be happy to see a more elegant solution!

Sincerely, Liam

Liam J. Revell
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.revell at umb.edu
blog: http://phytools.blogspot.com

On 4/1/2011 11:02 PM, Matthew Vavrek wrote:
> Hello again all,
> I got a number of great solutions to my last question about branch and
> bound maximum parsimony searches, several of which had definitely not
> crossed my mind. However, being stubborn (or is that stupid? Hard to
> tell sometimes) I went ahead and have started putting together a branch
> and bound style search function for R, just because (I'll try to get it
> up on CRAN shortly). It works, however it's not as efficient as I think
> it probably could be, probably because the method I use to add new taxa
> to the tree involves text searches with grep to create Newick trees. All
> that being said, is there any way to take an existing tree (in any
> format, such as Newick, but also the edge lists like in an ape 'phylo'
> object) and add a taxon at all the possible positions? I know allTrees()
> exists, but that would give me all the possibilities, rather than a
> restricted set (as I would need for branch and bound).
> Thanks again
> Matthew
> _______________________________________________
> R-sig-phylo mailing list
> R-sig-phylo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

More information about the R-sig-phylo mailing list