]> git.donarmstrong.com Git - ape.git/commitdiff
a few changes...
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Thu, 10 Nov 2011 10:23:02 +0000 (10:23 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Thu, 10 Nov 2011 10:23:02 +0000 (10:23 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@172 6e262413-ae40-0410-9e79-b911bd7a66b7

DESCRIPTION
NEWS
R/mantel.test.R
R/yule.R
Thanks
man/bionj.Rd
man/fastme.Rd
man/nj.Rd
src/bipartition.c

index 5882a71bc76c9fbf65d6ce68d22adc93e42f3a75..2ac8960c33904955267526d779d6f07bab819089 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
-Version: 2.8
-Date: 2011-10-20
+Version: 2.8-1
+Date: 2011-11-10
 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, Andrei-Alin Popescu, Klaus Schliep, Korbinian Strimmer, Damien de Vienne
 Maintainer: Emmanuel Paradis <Emmanuel.Paradis@ird.fr>
diff --git a/NEWS b/NEWS
index 17f28e25af52fa9bf1440a6c698b0179ac4f1a94..39b3905d1c4262bba55feec7f7fcf65f471c5ca6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,19 @@
+               CHANGES IN APE VERSION 2.8-1
+
+
+BUG FIXES
+
+    o mantel.test() could return P-values > 1 with the default
+      two-tailed test.
+
+
+OTHER CHANGES
+
+    o The code of yule() has been simplified and is now much faster for
+      big trees.
+
+
+
                CHANGES IN APE VERSION 2.8
 
 
@@ -22,6 +38,11 @@ NEW FEATURES
       the new function ltt.plot.coords.
 
 
+BUG FIXES
+
+    o prop.part() crashed if some trees had some multichotomies.
+
+
 
                CHANGES IN APE VERSION 2.7-3
 
index 97041523e965a18c3e73d4c71bb9672555db6286..a23bc324de8af19ff2a84dacf0478908633e5714 100644 (file)
@@ -1,4 +1,4 @@
-## mantel.test.R (2011-06-22)
+## mantel.test.R (2011-11-10)
 
 ##   Mantel Test for Similarity of Two Matrices
 
@@ -18,20 +18,19 @@ mant.zstat <- function(m1, m2) sum(lower.triang(m1 * m2))
 
 lower.triang <- function(m)
 {
-    d <- dim(m)
-    if (d[1] != d[2]) print("Warning: non-square matrix")
+    if (!diff(dim(m))) print("Warning: non-square matrix")
     m[col(m) <= row(m)]
 }
 
-mantel.test <- function (m1, m2, nperm = 1000, graph = FALSE,
-                         alternative = "two.sided", ...)
+mantel.test <- function(m1, m2, nperm = 1000, graph = FALSE,
+                        alternative = "two.sided", ...)
 {
     alternative <- match.arg(alternative, c("two.sided", "less", "greater"))
     n <- nrow(m1)
     realz <- mant.zstat(m1, m2)
     nullstats <- replicate(nperm, mant.zstat(m1, perm.rowscols(m2, n)))
     pval <- switch(alternative,
-                   "two.sided" = 2 * sum(abs(nullstats) > abs(realz)),
+                   "two.sided" =  2 * min(sum(nullstats > realz), sum(nullstats < realz)),
                    "less" = sum(nullstats < realz),
                    "greater" = sum(nullstats > realz))
     pval <- pval / nperm
index 041bda5deb4d5d0a519c87a8d211c46e1c48563e..abd719cf9e79a19bb9569907b1d381c37b968cfc 100644 (file)
--- a/R/yule.R
+++ b/R/yule.R
@@ -1,11 +1,11 @@
-## yule.R (2009-06-08)
+## yule.R (2011-11-03)
 
 ##     Fits Yule Model to a Phylogenetic Tree
 
 ## yule: standard Yule model (constant birth rate)
 ## yule.cov: Yule model with covariates
 
-## Copyright 2003-2009 Emmanuel Paradis
+## Copyright 2003-2011 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 yule <- function(phy, use.root.edge = FALSE)
 {
     if (!is.binary.tree(phy))
-      stop("tree must be dichotomous to fit the Yule model.")
-    bt <- rev(sort(branching.times(phy))) # branching times from past to present
-    ni <- cumsum(rev(table(bt))) + 1
+        stop("tree must be dichotomous to fit the Yule model.")
+
     X <- sum(phy$edge.length)
     nb.node <- phy$Nnode
-    if (!is.null(phy$root.edge) && use.root.edge) {
-        X <- X + phy$root.edge
-        ni <- c(1, ni)
-    } else nb.node <- nb.node - 1
+
+    if (!is.null(phy$root.edge) && use.root.edge) X <- X + phy$root.edge
+    else nb.node <- nb.node - 1
+
     lambda <- nb.node/X
     se <- lambda/sqrt(nb.node)
-    loglik <- -lambda*X + lfactorial(phy$Nnode) + nb.node*log(lambda)
+    loglik <- -lambda * X + lfactorial(phy$Nnode) + nb.node * log(lambda)
     obj <- list(lambda = lambda, se = se, loglik = loglik)
     class(obj) <- "yule"
     obj
diff --git a/Thanks b/Thanks
index 0d9b4736e7f3d7c17000bb753c45e1373475a8b0..98cf2534da381a957c4bc220f4ded42fd065c8a4 100644 (file)
--- a/Thanks
+++ b/Thanks
@@ -6,7 +6,7 @@ comments, or bug reports: thanks to all of you!
 
 Significant bug fixes were provided by Cécile Ané, Jeremy Beaulieu,
 James Bullard, Otto Cordero, Éric Durand, Olivier François, Rich
-FitzJohn, Jos Käfer, Bret Larget, Naim Matasci, Nick Matzke, Michael
+FitzJohn, Jos Käfer, Bret Larget, Naim Matasci, Nick Matzke, Michael
 Phelan, Elizabeth Purdom, Dan Rabosky, Filipe Vieira, Tim Wallstrom,
 Li-San Wang, Yan Wong, Peter Wragg, Janet Young, and Jinlong Zhang.
 Contact me if I forgot someone.
index 261542a382e5295615b794992c85609f04a0991d..18b06b488754cbfd3131798ee458d46771203b2c 100644 (file)
@@ -35,9 +35,10 @@ x <- c(7, 8, 11, 13, 16, 13, 17, 5, 8, 10, 13,
        10, 14, 5, 7, 10, 7, 11, 8, 11, 8, 12,
        5, 6, 10, 9, 13, 8)
 M <- matrix(0, 8, 8)
-M[row(M) > col(M)] <- x
-M[row(M) < col(M)] <- x
-rownames(M) <- colnames(M) <- 1:8
+M[lower.tri(M)] <- x
+M <- t(M)
+M[lower.tri(M)] <- x
+dimnames(M) <- list(1:8, 1:8)
 tr <- bionj(M)
 plot(tr, "u")
 ### a less theoretical example
index d29d305e851e1ebcb9b85b6f1925e0ecda609c7f..9174b48cca957c76676437b2bcd523c65eff33ec 100644 (file)
@@ -42,9 +42,10 @@ x <- c(7, 8, 11, 13, 16, 13, 17, 5, 8, 10, 13,
        10, 14, 5, 7, 10, 7, 11, 8, 11, 8, 12,
        5, 6, 10, 9, 13, 8)
 M <- matrix(0, 8, 8)
-M[row(M) > col(M)] <- x
-M[row(M) < col(M)] <- x
-rownames(M) <- colnames(M) <- 1:8
+M[lower.tri(M)] <- x
+M <- t(M)
+M[lower.tri(M)] <- x
+dimnames(M) <- list(1:8, 1:8)
 tr <- fastme.bal(M)
 plot(tr, "u")
 ### a less theoretical example
index 612d78038f435d3dee0a85679fdb9f25a7cbc161..88d2258c5893c5da384b74136ac357635d4b66d9 100644 (file)
--- a/man/nj.Rd
+++ b/man/nj.Rd
@@ -35,9 +35,10 @@ x <- c(7, 8, 11, 13, 16, 13, 17, 5, 8, 10, 13,
        10, 14, 5, 7, 10, 7, 11, 8, 11, 8, 12,
        5, 6, 10, 9, 13, 8)
 M <- matrix(0, 8, 8)
-M[row(M) > col(M)] <- x
-M[row(M) < col(M)] <- x
-rownames(M) <- colnames(M) <- 1:8
+M[lower.tri(M)] <- x
+M <- t(M)
+M[lower.tri(M)] <- x
+dimnames(M) <- list(1:8, 1:8)
 tr <- nj(M)
 plot(tr, "u")
 ### a less theoretical example
index a2b34d38d39159fbb1ca705c8701b17f8040d899..884fc6c35100f1619c3017997343eef82524b24c 100644 (file)
@@ -1,4 +1,4 @@
-/* bipartition.c    2011-06-23 */
+/* bipartition.c    2011-10-22 */
 
 /* Copyright 2005-2011 Emmanuel Paradis, and 2007 R Development Core Team */
 
@@ -189,6 +189,11 @@ SEXP prop_part(SEXP TREES, SEXP nbtree, SEXP keep_partitions)
 
     /* We start on the 2nd tree: */
     for (k = 1; k < Ntree; k++) {
+
+/* in case there are trees with multichotomies: */
+       nbnode = getListElement(VECTOR_ELT(TREES, k), "Nnode");
+       Nnode = INTEGER(nbnode)[0];
+
         PROTECT(bp = bipartition(getListElement(VECTOR_ELT(TREES, k), "edge"),
                                 nbtip, nbnode));
        for (i = 1; i < Nnode; i++) {