From 5090ae602c33e1cd3bbdbd2429a43daa8188b8c3 Mon Sep 17 00:00:00 2001 From: paradis Date: Sat, 9 Feb 2013 12:43:50 +0000 Subject: [PATCH] fix bug in prop.clades git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@207 6e262413-ae40-0410-9e79-b911bd7a66b7 --- NEWS | 4 ++++ R/dist.topo.R | 13 +++++++++++-- man/boot.phylo.Rd | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 5f1d758..59c6fed 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,10 @@ BUG FIXES o read.dna(, "fasta") may add '\r' in labels: this is fixed. + o prop.clades() returned wrong numbers when the tip labels of + 'phy' are not in the same order than the list of trees (thanks + to Rupert Collins for the report). + CHANGES IN APE VERSION 3.0-7 diff --git a/R/dist.topo.R b/R/dist.topo.R index 230f009..fa7edf8 100644 --- a/R/dist.topo.R +++ b/R/dist.topo.R @@ -1,9 +1,9 @@ -## dist.topo.R (2012-12-12) +## dist.topo.R (2013-02-09) ## Topological Distances, Tree Bipartitions, ## Consensus Trees, and Bootstrapping Phylogenies -## Copyright 2005-2012 Emmanuel Paradis +## Copyright 2005-2013 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -87,6 +87,7 @@ dist.topo <- function(x, y, method = "PH85") y$tip.label <- NULL y } + x <- unclass(x) # another killer improvement by Tucson's hackathon (1/2/2013) x <- lapply(x, relabel) attr(x, "TipLabel") <- ref class(x) <- "multiPhylo" @@ -165,6 +166,14 @@ prop.clades <- function(phy, ..., part = NULL, rooted = FALSE) part <- prop.part(obj, check.labels = TRUE) } + ## until ape 3.0-7 it was assumed implicitly that the labels in phy + ## are in the same order than in 'part' (bug report by Rupert Collins) + if (!identical(phy$tip.label, attr(part, "labels"))) { + i <- match(phy$tip.label, attr(part, "labels")) + j <- match(seq_len(Ntip(phy)), phy$edge[, 2]) + phy$edge[j, 2] <- i + phy$tip.label <- attr(part, "labels") + } bp <- prop.part(phy) if (!rooted) { bp <- postprocess.prop.part(bp) diff --git a/man/boot.phylo.Rd b/man/boot.phylo.Rd index 8ac8668..2e16665 100644 --- a/man/boot.phylo.Rd +++ b/man/boot.phylo.Rd @@ -133,11 +133,11 @@ tr <- f(woodmouse) for (i in 1:5) print(boot.phylo(tr, woodmouse, f, quiet = TRUE)) ### How many partitions in 100 random trees of 10 labels?... -TR <- replicate(100, rtree(10), FALSE) +TR <- rmtree(100, 10) pp10 <- prop.part(TR) length(pp10) ### ... and in 100 random trees of 20 labels? -TR <- replicate(100, rtree(20), FALSE) +TR <- rmtree(100, 20) pp20 <- prop.part(TR) length(pp20) plot(pp10, pch = "x", col = 2) -- 2.39.2