Created
April 24, 2012 22:59
-
-
Save darmitage/2484454 to your computer and use it in GitHub Desktop.
Collapse a phylogenetic clade by support values
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
#Code to collapse a phylogeny by a tree's support values, when nodes have support value names | |
#tree = phylogenetic tree, cutoff = support value cutoff (can be changed or made into a vector) | |
require(ape) | |
h <- which(tree$node.label < cutoff) | |
nodes <- matrix(h + Ntip(tree)) | |
nodes <- nodes[-1] | |
k <- matrix(tree$edge[,2]) | |
j <- matrix(nrow = length(i), ncol = 1) | |
for (i in 1:length(nodes)){ | |
j[i] = which(k == nodes[i]) | |
} | |
tree$edge.length[j] <- 0 | |
newtree <- di2multi(tree) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment