X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fdrop.tip.R;h=2d2a8f0165847347777db326584b10c1811543f1;hb=3ad385892d75db5c646c92f0f631ae9c5e3da4f6;hp=6e497cb9c0245dd66e39bbd79d291bd484cab0af;hpb=039cecc7ab5174412f1be3164f991f1ddc637f83;p=ape.git diff --git a/R/drop.tip.R b/R/drop.tip.R index 6e497cb..2d2a8f0 100644 --- a/R/drop.tip.R +++ b/R/drop.tip.R @@ -1,4 +1,4 @@ -## drop.tip.R (2009-06-23) +## drop.tip.R (2009-09-09) ## 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 @@ -167,8 +167,9 @@ drop.tip <- n <- length(oldNo.ofNewTips) # the new number of tips in the tree - ## assumes that the ordering of tips is unchanged: - phy$edge[TERMS, 2] <- 1:n + ## the tips may not be sorted in increasing order of their + ## in the 2nd col of edge, so no need to reorder $tip.label + phy$edge[TERMS, 2] <- rank(phy$edge[TERMS, 2]) ## make new tip labels if necessary: if (subtree || !trim.internal) {