You could try something like the following:
tips<-tree$tip.label
genera<-unique(sapply(strsplit(tips,"_"),function(x) x[1]))
ii<-sapply(genera,function(x,y) grep(x,y)[1],y=tips)
tree<-drop.tip(tree,setdiff(tree$tip.label,tips[ii]))
Let us know if this works.
All the best, Liam
Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: [email protected]
blog: http://blog.phytools.org
On 11/3/2014 11:56 AM, Susan Kapust wrote:
Dear colleagues,
I have a large species-level phylogeny in which the tip labels are
indicated as "Genus_species". All genera are monophyletic.
I have two things I'm struggling with:
(1) I'd like to drop all but one of the tips in each genus (i.e. to
generate a genus-level phylogeny). Given that all genera are
monophyletic, it shouldn't matter which species I pick.
(2) I'd like to establish an era (e.g. 25 Mya) and leave only one
representative of the clades there were present at that point in time.
Given that I actually have a post-burnin set of trees, once I figure out
how to do the steps above I could (hopefully) do that for all trees.
thanks so much for your help.
Susan.
[[alternative HTML version deleted]]
_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/
_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/