Re: [R-sig-phylo] mean phylogenetic distance for subsets of species from a tree
Yes, it looks like it! Thank you! Guess I was making it more complicated than it needed to be. Cheers, Zach On Thu, Feb 2, 2017 at 2:36 PM, Liam J. Revell wrote: > Hi Zach. > > Do you just mean the mean patristic distance among all pairwise > combinations of species in each assemblage? > > If you have your assemblages in a list of vectors, each containing the > species of the corresponding assemblage, I think you could do: > > library(ape) > D<-cophenetic(tree) > d<-sapply(assemblages,function(sp,D) mean(as.dist(D[sp,sp])),D=D) > > Does that work? > > All the best, Liam > > Liam J. Revell, Associate 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 2/2/2017 3:22 PM, Zach Culumber wrote: > >> Hi everyone, >> >> I have a time-calibrated phylogeny with ~100 species and a list of ~1000 >> observed species assemblages which vary from 2-20 species in size. I'd >> like to get the mean phylogenetic distance among species in each >> assemblage, but I'm having difficulty finding a way to do this. The >> comm.phylo.cor command in picante throws an error in as.hclust.default(x), >> that x cannot be coerced to class hclust, and I've hit a dead end finding >> a >> solution to that error. I'm not sure whether comm.phylo.cor will do what >> I >> want even if it works. >> >> I wrote a loop to prune the phylogeny separately for each group of >> species, >> which can then theoretically be used to get the distances with >> cophenetic.phylo. However, as soon as I start to run cophenetic.phylo >> across my list of trees, R starts to hang up and freeze my entire computer >> even though my code is set to skip trees for which distance can't be >> measured. One time it managed run a few and gave a memory error (e.g., >> 6050235 Tb of memory is not available). But R freezes even when I try to >> run this on an 12 core mac. >> >> Does anyone have any other suggestions for how to get the mean >> phylogenetic >> distance for subsets of species on a tree? Thanks for any ideas! >> >> Zach >> >> >> -- Zachary W. Culumber Postdoctoral Research Associate Kansas State University Division of Biology [[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/
Re: [R-sig-phylo] mean phylogenetic distance for subsets of species from a tree
Hi Zach. Do you just mean the mean patristic distance among all pairwise combinations of species in each assemblage? If you have your assemblages in a list of vectors, each containing the species of the corresponding assemblage, I think you could do: library(ape) D<-cophenetic(tree) d<-sapply(assemblages,function(sp,D) mean(as.dist(D[sp,sp])),D=D) Does that work? All the best, Liam Liam J. Revell, Associate 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 2/2/2017 3:22 PM, Zach Culumber wrote: Hi everyone, I have a time-calibrated phylogeny with ~100 species and a list of ~1000 observed species assemblages which vary from 2-20 species in size. I'd like to get the mean phylogenetic distance among species in each assemblage, but I'm having difficulty finding a way to do this. The comm.phylo.cor command in picante throws an error in as.hclust.default(x), that x cannot be coerced to class hclust, and I've hit a dead end finding a solution to that error. I'm not sure whether comm.phylo.cor will do what I want even if it works. I wrote a loop to prune the phylogeny separately for each group of species, which can then theoretically be used to get the distances with cophenetic.phylo. However, as soon as I start to run cophenetic.phylo across my list of trees, R starts to hang up and freeze my entire computer even though my code is set to skip trees for which distance can't be measured. One time it managed run a few and gave a memory error (e.g., 6050235 Tb of memory is not available). But R freezes even when I try to run this on an 12 core mac. Does anyone have any other suggestions for how to get the mean phylogenetic distance for subsets of species on a tree? Thanks for any ideas! Zach ___ 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] mean phylogenetic distance for subsets of species from a tree
Hi everyone, I have a time-calibrated phylogeny with ~100 species and a list of ~1000 observed species assemblages which vary from 2-20 species in size. I'd like to get the mean phylogenetic distance among species in each assemblage, but I'm having difficulty finding a way to do this. The comm.phylo.cor command in picante throws an error in as.hclust.default(x), that x cannot be coerced to class hclust, and I've hit a dead end finding a solution to that error. I'm not sure whether comm.phylo.cor will do what I want even if it works. I wrote a loop to prune the phylogeny separately for each group of species, which can then theoretically be used to get the distances with cophenetic.phylo. However, as soon as I start to run cophenetic.phylo across my list of trees, R starts to hang up and freeze my entire computer even though my code is set to skip trees for which distance can't be measured. One time it managed run a few and gave a memory error (e.g., 6050235 Tb of memory is not available). But R freezes even when I try to run this on an 12 core mac. Does anyone have any other suggestions for how to get the mean phylogenetic distance for subsets of species on a tree? Thanks for any ideas! Zach -- Zachary W. Culumber Postdoctoral Research Associate Kansas State University Division of Biology [[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/