Re: [R-sig-phylo] Extracting sister groups

2014-10-23 Thread Arbuckle, Kevin
Hi Fran�ois, Thank you kindly for your offer of help. The code below will simulate a phylogeny (tree) and a dataframe (trait) with one binary trait for 100 species. The format is representative of the data I am using for my analyses so should serve as a test case. Hopefully this helps, let me

Re: [R-sig-phylo] Extracting sister groups

2014-10-23 Thread François Michonneau
HI Kevin, If I understand correctly what you're trying to do, you'll first need to collapse some of your tips to create clades, a proportion of which will have the trait. You'll then be able to use this new tree to generate the data.frame needed by the functions you mentioned in your original

Re: [R-sig-phylo] midpoint rooting? how to get the outgroup?

2014-10-23 Thread romain
Dear Klauss, Following the topic below, I was wondering if there is function to get the name of the outgroup after having rooted the tree with the midpoint function. I can plot the tree and just check it by eyes. However I got 1000 trees and I want to count how many times on particular species

Re: [R-sig-phylo] Extracting sister groups

2014-10-23 Thread Liam J. Revell
Hi Kevin. It sounds like what you want to do is perform a pre-order tree traversal and for each node visited ask if all the taxa to one side (e.g., descendants of the right daughter node) are in state 0 and all the taxa to the other side (e.g., descendants of the left daughter) are in state

Re: [R-sig-phylo] midpoint rooting? how to get the outgroup?

2014-10-23 Thread dga...@huskers.unl.edu
Hi Romain, I think I've done something similar to this by searching the subtrees for the name of the taxa in question. The code is probably pretty slow on really big trees (since the subtrees function takes a while). library(phybase) library(phytools) set.seed(5) #make 100 20 tip trees

Re: [R-sig-phylo] midpoint rooting? how to get the outgroup?

2014-10-23 Thread Klaus Schliep
Dear Romain, the small function below returns the out group. I define he outgroup as the clade with less taxa from the root. If both clades have the same number of taxa in it one clades is chosen randomly. library(phangorn) getOutgroup - function(tree){ tree = midpoint(tree) # you probably