X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fdrop.tip.R;h=c0bda8bc15042186f101ac7f548e7fc1fb20dd34;hb=f5793d2af1299540f8ff7ad9ec8c1a6de1fee4cf;hp=69c957629e6533598488d0f7b3c4ede773faede7;hpb=fc029e0a1be9a5bd338c941b00842cfad95c0336;p=ape.git diff --git a/R/drop.tip.R b/R/drop.tip.R index 69c9576..c0bda8b 100644 --- a/R/drop.tip.R +++ b/R/drop.tip.R @@ -1,4 +1,4 @@ -## drop.tip.R (2009-03-04) +## drop.tip.R (2009-03-22) ## Remove Tips in a Phylogenetic Tree @@ -76,6 +76,7 @@ drop.tip <- { if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"') + phy <- reorder(phy) Ntip <- length(phy$tip.label) NEWROOT <- ROOT <- Ntip + 1 Nnode <- phy$Nnode @@ -145,7 +146,10 @@ drop.tip <- TIPS <- phy$edge[, 2] <= Ntip ## keep the ordering so no need to reorder tip.label: phy$edge[TIPS, 2] <- rank(phy$edge[TIPS, 2]) - Ntip <- length(phy$tip.label) # update Ntip + ## 3) update node.label if needed + if (!is.null(phy$node.label)) + phy$node.label <- phy$node.label[sort(unique(phy$edge[, 1])) - Ntip] + Ntip <- length(phy$tip.label) # 4) update Ntip ## make new tip labels if necessary if (subtree || !trim.internal) {