From d1546ec66ff1a8ea123adefebe14f6316c23705f Mon Sep 17 00:00:00 2001 From: paradis Date: Tue, 22 Nov 2011 07:38:09 +0000 Subject: [PATCH] fixes in mantel.test() and extract.clade() git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@173 6e262413-ae40-0410-9e79-b911bd7a66b7 --- DESCRIPTION | 2 +- NEWS | 6 ++++++ R/drop.tip.R | 8 ++++++-- R/mantel.test.R | 14 +++++++------- Thanks | 9 +++++---- man/mantel.test.Rd | 2 +- 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2ac8960..2aec280 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape Version: 2.8-1 -Date: 2011-11-10 +Date: 2011-11-11 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 diff --git a/NEWS b/NEWS index 39b3905..223169c 100644 --- a/NEWS +++ b/NEWS @@ -6,12 +6,18 @@ BUG FIXES o mantel.test() could return P-values > 1 with the default two-tailed test. + o extract.clade() sometimes shuffled some tip labels (thanks to + Ludovic Mallet and Mahendra Mariadassou for the fix). + OTHER CHANGES o The code of yule() has been simplified and is now much faster for big trees. + o The code of mantel.test() has been adjusted to be consistent + with common permutation tests. + CHANGES IN APE VERSION 2.8 diff --git a/R/drop.tip.R b/R/drop.tip.R index b339578..5b635f6 100644 --- a/R/drop.tip.R +++ b/R/drop.tip.R @@ -1,4 +1,4 @@ -## drop.tip.R (2011-05-19) +## drop.tip.R (2011-11-21) ## Remove Tips in a Phylogenetic Tree @@ -54,7 +54,11 @@ extract.clade <- function(phy, node, root.edge = 0, interactive = FALSE) if (wbl) phy$edge.length <- phy$edge.length[keep] TIPS <- phy$edge[, 2] <= Ntip tip <- phy$edge[TIPS, 2] - phy$tip.label <- phy$tip.label[sort(tip)] # <- added sort to avoid shuffling of tip labels (2010-07-21) + ## Fix by Ludovic Mallet and Mahendra Mariadassou (2011-11-21): + name <- vector("character", length(tip)) + name[order(tip)] <- phy$tip.label[tip] + phy$tip.label <- name + ## End of fix ## keep the ordering so no need to reorder tip.label: phy$edge[TIPS, 2] <- order(tip) if (!is.null(phy$node.label)) diff --git a/R/mantel.test.R b/R/mantel.test.R index a23bc32..c5c1da2 100644 --- a/R/mantel.test.R +++ b/R/mantel.test.R @@ -1,8 +1,8 @@ -## mantel.test.R (2011-11-10) +## mantel.test.R (2011-11-11) ## Mantel Test for Similarity of Two Matrices -## Copyright 2002-2006 Ben Bolker and Julien Claude +## Copyright 2002-2011 Ben Bolker and Julien Claude ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -22,7 +22,7 @@ lower.triang <- function(m) m[col(m) <= row(m)] } -mantel.test <- function(m1, m2, nperm = 1000, graph = FALSE, +mantel.test <- function(m1, m2, nperm = 999, graph = FALSE, alternative = "two.sided", ...) { alternative <- match.arg(alternative, c("two.sided", "less", "greater")) @@ -30,10 +30,10 @@ mantel.test <- function(m1, m2, nperm = 1000, graph = FALSE, realz <- mant.zstat(m1, m2) nullstats <- replicate(nperm, mant.zstat(m1, perm.rowscols(m2, n))) pval <- switch(alternative, - "two.sided" = 2 * min(sum(nullstats > realz), sum(nullstats < realz)), - "less" = sum(nullstats < realz), - "greater" = sum(nullstats > realz)) - pval <- pval / nperm + "two.sided" = 2 * min(sum(nullstats >= realz), sum(nullstats <= realz)), + "less" = sum(nullstats <= realz), + "greater" = sum(nullstats >= realz)) + pval <- (pval + 1) / (nperm + 1) # 'realz' is included in 'nullstats' if (graph) { plot(density(nullstats), type = "l", ...) abline(v = realz) diff --git a/Thanks b/Thanks index 98cf253..c16ee82 100644 --- a/Thanks +++ b/Thanks @@ -6,10 +6,11 @@ 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 -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. +FitzJohn, Jos Käfer, Bret Larget, Ludovic Mallet, Mahendra +Mariadassou, 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. Kurt Hornik, of the R Core Team, helped in several occasions to fix some problems and bugs. diff --git a/man/mantel.test.Rd b/man/mantel.test.Rd index babb82c..949678e 100644 --- a/man/mantel.test.Rd +++ b/man/mantel.test.Rd @@ -2,7 +2,7 @@ \alias{mantel.test} \title{Mantel Test for Similarity of Two Matrices} \usage{ -mantel.test(m1, m2, nperm = 1000, graph = FALSE, +mantel.test(m1, m2, nperm = 999, graph = FALSE, alternative = "two.sided", ...) } \arguments{ -- 2.39.2