Created
May 8, 2012 00:35
-
-
Save darmitage/2631680 to your computer and use it in GitHub Desktop.
List nodes falling between specified node and root of phylogeny
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nodes2root <- | |
function(phy,int.node) { | |
Ntaxa = length(phy$tip.label) + phy$Nnode | |
Nnode = phy$Nnode | |
tips = c() | |
nodes = int.node | |
repeat { | |
nodes = phy$edge[which(phy$edge[,2]%in%nodes),1] | |
if (length(nodes)==0) break | |
tips = c(tips,nodes) | |
} | |
tips = tips[tips<=Ntaxa] | |
return(tips) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment