]> git.donarmstrong.com Git - ape.git/blobdiff - R/drop.tip.R
several bug fixes while in JKT
[ape.git] / R / drop.tip.R
index 6e497cb9c0245dd66e39bbd79d291bd484cab0af..acdbe688d7643f6465b9d04c5a30844ce027ffea 100644 (file)
@@ -1,4 +1,4 @@
-## drop.tip.R (2009-06-23)
+## drop.tip.R (2009-07-06)
 
 ##   Remove Tips in a Phylogenetic Tree
 
@@ -29,7 +29,7 @@ extract.clade <- function(phy, node, root.edge = 0)
     root.node <- which(phy$edge[, 2] == node)
     start <- root.node + 1 # start of the clade looked for
     anc <- phy$edge[root.node, 1] # the ancestor of 'node'
-    next.anc <- which(phy$edge[-(1:start), 1] == anc) # find the next occurence of 'anc'
+    next.anc <- which(phy$edge[-(1:start), 1] <= anc) # find the next occurence of 'anc' or an 'older' node
 
     keep <- if (length(next.anc)) start + 0:(next.anc[1] - 1) else start:Nedge