Hi Thiago.

You could do something like this using phytools & ape. For genus name "Genus1" (assuming genus & species names are separated by a "_" character):

x<-grep("Genus1_",tree$tip.label)

... gives you the indices in tree$tip.label for everything in "Genus1".

y<-findMRCA(tree,tree$tip.label[x])

... gives you the node number for the ancestor of "Genus1".

tree<-bind.tip(tree,"Genus1_newsp",where=y)

... attaches the new tip to the root of "Genus1".

Note that this will only work if you have multiple species in each genus that you want to add to. If not, then the MRCA of the genus will not be defined. In that case, you could, for instance, add the new tip 1/2 way along the terminal edge leading to the one species in "Genus1". E.g.:

if(length(x)==1){
        tree<-bind.tip(tree,"Genus1_newsp",where=x,
        position=0.5*tree$edge.length[which(tree$edge[,2]==x)])
}

It would be straightforward to automate this if you have to iterate across many samples. Let me know if you need help with that.

All the best, Liam

Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 10/31/2013 1:41 PM, Thiago A. Pires wrote:
Dear list members,

I need to add a list of 230 species in a
phylogenetic tree. Is there a logical way to add the species to the root of
the
genre to which it belongs, in a systematic way, that is, to make
a
function recognizes the name of the
genre to which the species belongs, and so it adds the species to that
root? I can name the roots of the
genre of the tree, if necessary.

Thanks in advance

T.

_____________________________________________________________
Thiago Augusto Pires
  Mestrando - PPG Ecologia - Instituto de Biologia - UNICAMP
Master Student - Ecology Program - Biology Institute - UNICAMP

Collaborator Researcher - Laboratory of Ecology and Systematics - UNIFESP


Email: pires.thiagoaugu...@gmail.com
Home Page:
http://thiagoaugustopires.wix.com/naturevisions
CV Lattes:
http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4298681Z0
_____________________________________________________________


*
*

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to