]> git.donarmstrong.com Git - ape.git/blobdiff - R/dist.topo.R
few corrections and fixes
[ape.git] / R / dist.topo.R
index f2a10ae26352e16325763cea2cfda19fa5bcad46..1eb770af6a12f15948b70388a322eb0f6fcd7992 100644 (file)
@@ -1,4 +1,4 @@
-## dist.topo.R (2010-01-22)
+## dist.topo.R (2010-01-25)
 
 ##      Topological Distances, Tree Bipartitions,
 ##   Consensus Trees, and Bootstrapping Phylogenies
@@ -13,6 +13,8 @@ dist.topo <- function(x, y, method = "PH85")
     if (method == "score" && (is.null(x$edge.length) || is.null(y$edge.length)))
         stop("trees must have branch lengths for Billera et al.'s distance.")
     nx <- length(x$tip.label)
+    x <- unroot(x)
+    y <- unroot(y)
     bp1 <- .Call("bipartition", x$edge, nx, x$Nnode, PACKAGE = "ape")
     bp1 <- lapply(bp1, function(xx) sort(x$tip.label[xx]))
     ny <- length(y$tip.label) # fix by Otto Cordero
@@ -80,8 +82,9 @@ dist.topo <- function(x, y, method = "PH85")
             stop(paste("tree no.", i, "has different tip labels"))
         ie <- match(1:n, x[[i]]$edge[, 2])
         x[[i]]$edge[ie, 2] <- ilab
+        x[[i]]$tip.label <- NULL
     }
-    for (i in 1:length(x)) x[[i]]$tip.label <- NULL
+    x[[1]]$tip.label <- NULL
     attr(x, "TipLabel") <- ref
     x
 }