Hi Annemarie.

If you know the tip names for all the species descended from the target node in each tree in your sample, you could use findMRCA in the phytools package. findMRCA uses ape's mrca function to get the MRCA of a set of tips.

So, for instance, if your target node is the MRCA of taxa labeled "t1", "t3", and "t8", with data in the vector x, you could do the following:

sp<-c("t1","t3","t8")
y<-ace(x,tree)
target.state<-y$ace[as.character(findMRCA(tree,sp))]

Of course, looping this over a set of trees is simple, for instance, using sapply:

sp<-c("t1","t3","t8")
target.state<-sapply(trees,function(a,x,sp)
  ace(x,a)$ace[as.character(findMRCA(a,sp))],x=x,sp=sp)

Or, of course, you could just as easily use a simple "for" loop.

Perhaps this helps?

All the best, Liam

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

On 5/8/2012 7:44 PM, Annemarie Verkerk wrote:
Dear r-sig-phylo users,

I have a question regarding the retrieval of ancestral states of
internal nodes in a sample of trees. I am doing ancestral state
estimations on a large sample of trees (using ace() in ape), but a few
groups of languages are present in all my trees. I would like to know
how to easily retrieve the ancestral state of the internal node leading
to such a group of languages, given that I know the numbers of the edges
leading to those language tips, but the number of the internal edge
leading to those languages (and thus defining the grouping / clade) will
not be the same in all of the trees.

This would be very easy to do in BayesTraits using 'addnode', but I
really want to use the 'ML' version of ace(), which is not included in
BayesTraits.

Does anyone have an idea? (Sorry if this has been asked before, I could
not find anything in the archives.)

Many thanks,
Annemarie


_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to