From df2d6bcb931ba3b5fa7b327176e5793908d6c8fd Mon Sep 17 00:00:00 2001 From: paradis Date: Tue, 30 Nov 2010 08:07:19 +0000 Subject: [PATCH] fix a bug in as.hclust.phylo + a few typos in man pages git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@140 6e262413-ae40-0410-9e79-b911bd7a66b7 --- ChangeLog | 3 +++ DESCRIPTION | 2 +- R/as.phylo.R | 24 +++++++++++++----------- man/parafit.Rd | 4 ++-- man/rtree.Rd | 2 +- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index a021f9c..3cfdf9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,9 @@ BUG FIXES o drop.tip() shuffled tip labels with subtree = TRUE or trim.internal = FALSE. + o Objects returned by as.hclust.phylo() failed when analysed with + cutree() or rect.hclust(). + CHANGES IN APE VERSION 2.6-1 diff --git a/DESCRIPTION b/DESCRIPTION index 04f43c6..ab0adee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape Version: 2.6-2 -Date: 2010-11-24 +Date: 2010-11-30 Title: Analyses of Phylogenetics and Evolution Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, Christoph Heibl, Daniel Lawson, Vincent Lefort, Pierre Legendre, Jim Lemon, Yvonnick Noel, Johan Nylander, Rainer Opgen-Rhein, Klaus Schliep, Korbinian Strimmer, Damien de Vienne Maintainer: Emmanuel Paradis diff --git a/R/as.phylo.R b/R/as.phylo.R index b576a54..c0304b5 100644 --- a/R/as.phylo.R +++ b/R/as.phylo.R @@ -1,4 +1,4 @@ -## as.phylo.R (2010-09-30) +## as.phylo.R (2010-11-30) ## Conversion Among Tree Objects @@ -89,20 +89,22 @@ as.hclust.phylo <- function(x, ...) if (!is.ultrametric(x)) stop("the tree is not ultrametric") if (!is.binary.tree(x)) stop("the tree is not binary") n <- length(x$tip.label) - bt <- rev(branching.times(x)) - N <- length(bt) - nm <- x$Nnode:1 + n # fix by Filipe G. Vieira (2010-09-30) + bt <- sort(branching.times(x)) + inode <- as.numeric(names(bt)) + N <- n - 1L + nm <- numeric(N + n) # hash table + nm[inode] <- 1:N merge <- matrix(NA, N, 2) for (i in 1:N) { - ind <- which(x$edge[, 1] == nm[i]) - for (k in 1:2) - merge[i, k] <- if (x$edge[ind[k], 2] <= n) -x$edge[ind[k], 2] - else which(nm == x$edge[ind[k], 2]) + ind <- which(x$edge[, 1] == inode[i]) + for (k in 1:2) { + tmp <- x$edge[ind[k], 2] + merge[i, k] <- if (tmp <= n) -tmp else nm[tmp] + } } names(bt) <- NULL - obj <- list(merge = merge, height = bt, order = 1:(N + 1), - labels = x$tip.label, call = match.call(), - method = "unknown") + obj <- list(merge = merge, height = bt, order = 1:n, labels = x$tip.label, + call = match.call(), method = "unknown") class(obj) <- "hclust" obj } diff --git a/man/parafit.Rd b/man/parafit.Rd index 6cb16ac..b819656 100644 --- a/man/parafit.Rd +++ b/man/parafit.Rd @@ -11,8 +11,8 @@ Function \code{\link{parafit}} tests the hypothesis of coevolution between a cla The method, which is described in detail in Legendre et al. (2002), requires some estimates of the phylogenetic trees or phylogenetic distances, and also a description of the host-parasite associations (H-P links) observed in nature. } \usage{ -parafit(host.D, para.D ,HP ,nperm=999, test.links=FALSE, seed=NULL, -correction="none", silent=FALSE) +parafit(host.D, para.D, HP, nperm = 999, test.links = FALSE, + seed = NULL, correction = "none", silent = FALSE) } \arguments{ diff --git a/man/rtree.Rd b/man/rtree.Rd index 05a1fbe..0f2dbaa 100644 --- a/man/rtree.Rd +++ b/man/rtree.Rd @@ -46,7 +46,7 @@ rmtree(N, n, rooted = TRUE, tip.label = NULL, br = runif, ...) } \author{Emmanuel Paradis} \seealso{ - \code{\link{stree}} + \code{\link{stree}}, \code{\link{rlineage}} } \examples{ layout(matrix(1:9, 3, 3)) -- 2.39.2