Skip to content

Instantly share code, notes, and snippets.

@darmitage
Created May 8, 2012 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darmitage/2631680 to your computer and use it in GitHub Desktop.
Save darmitage/2631680 to your computer and use it in GitHub Desktop.
List nodes falling between specified node and root of phylogeny
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