Dear Joseph, thanks so much. This is exactly what I need!
I am running into some problems that I don’t understand though. In my case, rootID is 18, and max(phy$edge[,1]) is 33. When I try to execute your loop, this happens: > extract.clade(phy, 18) Phylogenetic tree with 17 tips and 16 internal nodes. Tip labels: X1, X8, X9, X10 ... Rooted; includes branch lengths. So far so good… but then I keep getting these errors: > extract.clade(phy, 19) Error in phy$edge[, 2] : incorrect number of dimensions > extract.clade(phy, 20) Error in phy$edge[, 2] : incorrect number of dimensions Not sure why extract.clade produces these errors. 19-23 don’t work, 24-26 work, 27 produces the error again, 28 works etc. Thanks again. Kamila > On Jan 5, 2017, at 4:12 PM, Joseph W. Brown <josep...@umich.edu> wrote: > > Not sure if I understand the problem completely, but this should allow you to > examine all of the clades (and should work if polytomies are involved): > > # for tree phy > rootID <- length(phy$tip.label) + 1; > for (i in rootID:max(phy$edge[,1])) { > clade <- extract.clade(phy, i); > # do something > } > > This includes the root node (i.e. whole tree), but that can be changed. This > can be rewritten as an lapply if necessary. > > HTH. > JWB > ________________________________________ > Joseph W. Brown > Post-doctoral Researcher, Smith Laboratory > University of Michigan > Department of Ecology & Evolutionary Biology > Room 2071, Kraus Natural Sciences Building > Ann Arbor MI 48109-1079 > josep...@umich.edu <mailto:josep...@umich.edu> > > > >> On 5 Jan, 2017, at 15:50, Kamila Naxerova <knaxer...@partners.org >> <mailto:knaxer...@partners.org>> wrote: >> >> Hi all, >> >> I would like to break a phylogenetic tree into all possible clades and then >> examine each one of them for certain characteristics. >> >> I am writing some code to do this from scratch, but it’s getting pretty >> cumbersome quickly. >> >> I was wondering whether there are some functions out there already that >> could help me with this task? >> >> Thanks so much for any help. >> >> Cheers, >> Kamila >> >> >> The information in this e-mail is intended only for t...{{dropped:24}} _______________________________________________ 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/