From 3ece2ec76da287a8a86339827cc44e193fe16cdd Mon Sep 17 00:00:00 2001 From: paradis Date: Thu, 19 May 2011 16:42:58 +0000 Subject: [PATCH] fixing drop.tip and bionj git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@158 6e262413-ae40-0410-9e79-b911bd7a66b7 --- DESCRIPTION | 2 +- NEWS | 11 +++++++++++ R/SlowinskiGuyer.R | 8 +++++--- R/drop.tip.R | 5 +++-- R/me.R | 6 ++++-- R/root.R | 8 ++++---- man/delta.plot.Rd | 2 +- man/diversity.contrast.test.Rd | 31 +++++++++++++++++++++---------- 8 files changed, 50 insertions(+), 23 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 90bd55b..4005e70 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape Version: 2.7-2 -Date: 2011-03-29 +Date: 2011-05-19 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/NEWS b/NEWS index c702b68..f9af949 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,17 @@ NEW FEATURES is not plotted but the graphical device is set and the coordinates are saved as normal. + o diversity.contrast.test() gains a fourth version of the test with + method = "logratio"; the literature citations have been clarified. + + +BUG FIXES + + o bionj() made R crash if distances were two large. It now returns + an error if at least one distance is greater than 100. + + o drop.tip() returned a wrong tree if 'tip' was of zero length. + CHANGES IN APE VERSION 2.7-1 diff --git a/R/SlowinskiGuyer.R b/R/SlowinskiGuyer.R index 1563f02..b0fc956 100644 --- a/R/SlowinskiGuyer.R +++ b/R/SlowinskiGuyer.R @@ -1,4 +1,4 @@ -## SlowinskiGuyer.R (2011-03-10) +## SlowinskiGuyer.R (2011-05-05) ## Tests of Diversification Shifts with Sister-Clades @@ -65,7 +65,8 @@ richness.yule.test <- function(x, t) diversity.contrast.test <- function(x, method = "ratiolog", alternative = "two.sided", nrep = 0, ...) { - method <- match.arg(method, c("ratiolog", "proportion", "difference")) + method <- match.arg(method, c("ratiolog", "proportion", + "difference", "logratio")) alternative <- match.arg(alternative, c("two.sided", "less", "greater")) minmax <- t(apply(x, 1, sort)) # sort all rows @@ -81,7 +82,8 @@ diversity.contrast.test <- log(minmax[, 2]) / log(minmax[, 1]) }, "proportion" = minmax[, 2] / (minmax[, 2] + minmax[, 1]), - "difference" = abs(DIFF)) + "difference" = abs(DIFF), + "logratio" = log(minmax[, 1] / minmax[, 2])) y <- SIGN * CONTRAST # the signed contrasts diff --git a/R/drop.tip.R b/R/drop.tip.R index 948b226..b339578 100644 --- a/R/drop.tip.R +++ b/R/drop.tip.R @@ -1,8 +1,8 @@ -## drop.tip.R (2010-11-24) +## drop.tip.R (2011-05-19) ## Remove Tips in a Phylogenetic Tree -## Copyright 2003-2010 Emmanuel Paradis +## Copyright 2003-2011 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -79,6 +79,7 @@ drop.tip <- { if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"') + if (!length(tip)) return(phy) Ntip <- length(phy$tip.label) ## find the tips to drop: diff --git a/R/me.R b/R/me.R index 7dca6c0..96c7e65 100644 --- a/R/me.R +++ b/R/me.R @@ -1,9 +1,9 @@ -## me.R (2009-01-07) +## me.R (2011-05-12) ## Tree Estimation Based on Minimum Evolution Algorithm ## Copyright 2007 Vincent Lefort with modifications by -## Emmanuel Paradis (2008-2009) +## Emmanuel Paradis (2008-2011) ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -49,6 +49,8 @@ fastme.ols <- function(X, nni = TRUE) bionj <- function(X) { if (is.matrix(X)) X <- as.dist(X) + if (any(X > 100)) + stop("at least one distance was greater than 100") N <- as.integer(attr(X, "Size")) labels <- sprintf("%6s", 1:N) edge1 <- edge2 <- integer(2*N - 3) diff --git a/R/root.R b/R/root.R index ac5ec27..5691bb5 100644 --- a/R/root.R +++ b/R/root.R @@ -1,8 +1,8 @@ -## root.R (2010-02-11) +## root.R (2011-04-29) ## Root of Phylogenetic Trees -## Copyright 2004-2010 Emmanuel Paradis +## Copyright 2004-2011 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -252,7 +252,7 @@ root <- function(phy, outgroup, node = NULL, o[NEXT:(NEXT + ne - 1L)] <- s if (fuseRoot) { - phy$Nnode <- oldNnode - 1 + phy$Nnode <- oldNnode - 1L N <- N - 1L } phy$edge[INV, ] <- phy$edge[INV, 2:1] @@ -288,7 +288,7 @@ root <- function(phy, outgroup, node = NULL, } } ## N <- N + 1L ... not needed - phy$Nnode <- phy$Nnode + 1 + phy$Nnode <- phy$Nnode + 1L } ## The block below renumbers the nodes so that they conform diff --git a/man/delta.plot.Rd b/man/delta.plot.Rd index 59877a0..cf45e2c 100644 --- a/man/delta.plot.Rd +++ b/man/delta.plot.Rd @@ -7,7 +7,7 @@ delta.plot(X, k = 20, plot = TRUE, which = 1:2) \arguments{ \item{X}{a distance matrix, may be an object of class ``dist''.} \item{k}{an integer giving the number of intervals in the plot.} - \item{plot}{a logival specifying whether to draw the + \item{plot}{a logical specifying whether to draw the \eqn{\delta}{delta} plot (the default).} \item{which}{a numeric vector indicating which plots are done; 1: the histogram of the \eqn{\delta_q}{delta_q} values, 2: the plot of the diff --git a/man/diversity.contrast.test.Rd b/man/diversity.contrast.test.Rd index b24d42b..dd6e7ca 100644 --- a/man/diversity.contrast.test.Rd +++ b/man/diversity.contrast.test.Rd @@ -12,26 +12,29 @@ diversity.contrast.test(x, method = "ratiolog", \arguments{ \item{x}{a matrix or a data frame with at least two columns: the first one gives the number of species in clades with a trait supposed to - increase or decrease diversification rate, and the second one the number of - species in the sister-clades without the trait. Each - row represents a pair of sister-clades.} - \item{method}{a character string specifying the kind of test: \code{"ratiolog"} (default), - \code{"proportion"}, \code{"difference"}, or any unambiguous + increase or decrease diversification rate, and the second one the + number of species in the sister-clades without the trait. Each row + represents a pair of sister-clades.} + \item{method}{a character string specifying the kind of test: + \code{"ratiolog"} (default), \code{"proportion"}, + \code{"difference"}, \code{"logratio"}, or any unambiguous abbreviation of these.} \item{alternative}{a character string defining the alternative hypothesis: \code{"two.sided"} (default), \code{"less"}, \code{"greater"}, or any unambiguous abbreviation of these.} \item{nrep}{the number of replications of the randomization test; by default, a Wilcoxon test is done.} - \item{\dots}{arguments passed to the function \code{\link[stats]{wilcox.test}}.} + \item{\dots}{arguments passed to the function + \code{\link[stats]{wilcox.test}}.} } \details{ If \code{method = "ratiolog"}, the test described in Barraclough et al. (1996) is performed. If \code{method = "proportion"}, the version in Barraclough et al. (1995) is used. If \code{method = "difference"}, - then this is Wiegmann et al.'s (1993) version. Vamosi and Vamosi (2005) - gave a detailed account of these three tests which are essentially - different versions of the same test. + the signed difference is used (Sargent 2004). If \code{method = + "logratio"}, then this is Wiegmann et al.'s (1993) version. These + four tests are essentially different versions of the same test (Vamosi + and Vamosi 2005, Vamosi 2007). If \code{nrep = 0}, a Wilcoxon test is done on the species diversity contrasts with the null hypothesis is that they are distributed around @@ -52,7 +55,15 @@ diversity.contrast.test(x, method = "ratiolog", Barraclough, T. G., Harvey, P. H., and Nee, S. (1996) Rate of \emph{rbc}L gene sequence evolution and species diversification in flowering plants (angiosperms). \emph{Proceedings of the Royal Society - of London. Series B. Biological Sciences}, \bold{263}, 589--591. + of London. Series B. Biological Sciences}, \bold{263}, 589--591. + + Sargent, R. D. (2004) Floral symmetry affects speciation rates in + angiosperms. \emph{Proceedings of the Royal Society of London. Series + B. Biological Sciences}, \bold{271}, 603--608. + + Vamosi, S. M. (2007) Endless tests: guidelines for analysing non-nested + sister-group comparisons. An addendum. \emph{Evolutionary Ecology + Research}, \bold{9}, 717. Vamosi, S. M. and Vamosi, J. C. (2005) Endless tests: guidelines for analysing non-nested sister-group comparisons. \emph{Evolutionary -- 2.39.2