From 5f07c2ca4b34dafc7ecc22e028c10d2d7eadffef Mon Sep 17 00:00:00 2001 From: paradis Date: Mon, 17 Mar 2008 07:43:39 +0000 Subject: [PATCH] fixed bugs in multi2di and di2multi + code and doc clean-up git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@22 6e262413-ae40-0410-9e79-b911bd7a66b7 --- Changes | 5 +++++ DESCRIPTION | 2 +- R/multi2di.R | 12 ++++++++++-- man/DNAbin.Rd | 2 +- man/multi2di.Rd | 2 +- man/read.tree.Rd | 2 +- src/reorder_phylo.c | 11 +++++------ 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Changes b/Changes index aa313f0..0871785 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,11 @@ BUG FIXES o An error was fixed in the computation of ancestral character states by generalized least squares in ace(). + o di2multi() did not modify node labels correctly. + + o multi2di() failed if the tree had its attribute "order" set to + "cladewise". + CHANGES IN APE VERSION 2.1-2 diff --git a/DESCRIPTION b/DESCRIPTION index 801dc62..7c08324 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape Version: 2.1-3 -Date: 2008-03-10 +Date: 2008-03-17 Title: Analyses of Phylogenetics and Evolution Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, diff --git a/R/multi2di.R b/R/multi2di.R index 7bb4c88..731f328 100644 --- a/R/multi2di.R +++ b/R/multi2di.R @@ -1,8 +1,8 @@ -## multi2di.R (2007-08-02) +## multi2di.R (2008-03-17) ## Collapse and Resolve Multichotomies -## Copyright 2005-2007 Emmanuel Paradis +## Copyright 2005-2008 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -62,6 +62,12 @@ multi2di <- function(phy, random = TRUE) phy$edge <- rbind(phy$edge[-edge2delete, ], new.edge) if (wbl) phy$edge.length <- c(phy$edge.length[-edge2delete], new.edge.length) + if (!is.null(attr(phy, "order"))) attr(phy, "order") <- NULL + print(phy$node.label) + if (!is.null(phy$node.label)) + phy$node.label <- + c(phy$node.label, rep("", phy$Nnode - length(phy$node.label))) + print(phy$node.label) reorder(phy) ##read.tree(text = write.tree(phy)) } @@ -96,5 +102,7 @@ di2multi <- function(phy, tol = 1e-8) sel <- phy$edge > min(node2del) for (i in which(sel)) phy$edge[i] <- phy$edge[i] - sum(node2del < phy$edge[i]) + if (!is.null(phy$node.label)) + phy$node.label <- phy$node.label[-(node2del - length(phy$tip.label))] phy } diff --git a/man/DNAbin.Rd b/man/DNAbin.Rd index 9459372..ca1b23e 100644 --- a/man/DNAbin.Rd +++ b/man/DNAbin.Rd @@ -63,7 +63,7 @@ } \references{ Paradis, E. (2007) A Bit-Level Coding Scheme for Nucleotides. - \url{http://pbil.univ-lyon1.fr/R/ape/misc/BitLevelCodingScheme_20April2007.pdf} + \url{http://ape.mpl.ird.fr/misc/BitLevelCodingScheme_20April2007.pdf} } \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}} \seealso{ diff --git a/man/multi2di.Rd b/man/multi2di.Rd index bf53982..ddb0f3c 100644 --- a/man/multi2di.Rd +++ b/man/multi2di.Rd @@ -4,7 +4,7 @@ \title{Collapse and Resolve Multichotomies} \description{ These two functions collapse or resolve multichotomies in phylogenetic - trees (objects of class \code{"phylo"}). + trees. } \usage{ multi2di(phy, random = TRUE) diff --git a/man/read.tree.Rd b/man/read.tree.Rd index 698c728..75f4cb5 100644 --- a/man/read.tree.Rd +++ b/man/read.tree.Rd @@ -72,7 +72,7 @@ read.tree(file = "", text = NULL, tree.names = NULL, \url{http://evolution.genetics.washington.edu/phylip/newick_doc.html} Paradis, E. (2006) Definition of Formats for Coding Phylogenetic Trees - in R. \url{http://pbil.univ-lyon1.fr/R/ape/misc/FormatTreeR_4Dec2006.pdf} + in R. \url{http://ape.mpl.ird.fr/misc/FormatTreeR_4Dec2006.pdf} } \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}} diff --git a/src/reorder_phylo.c b/src/reorder_phylo.c index 2ab6f5b..c54ea52 100644 --- a/src/reorder_phylo.c +++ b/src/reorder_phylo.c @@ -1,6 +1,6 @@ -/* reorder_phylo.c 2006-10-11 */ +/* reorder_phylo.c 2008-03-17 */ -/* Copyright 2006 Emmanuel Paradis */ +/* Copyright 2008 Emmanuel Paradis */ /* This file is part of the R-package `ape'. */ /* See the file ../COPYING for licensing issues. */ @@ -22,10 +22,9 @@ void neworder_cladewise(int *n, int *edge1, int *edge2, done = (int*)R_alloc(*N, sizeof(int)); node_back = (int*)R_alloc(*N + 2 - *n, sizeof(int)); - for (i = 0; i < *N; i++) done[i] = 0; + memset(done, 0, *N * sizeof(int)); - j = 0; - k = 0; + j = k = 0; node = *n + 1; while (j < *N) { for (i = 0; i < *N; i++) { @@ -71,7 +70,7 @@ void neworder_pruningwise(int *ntip, int *nnode, int *edge1, /* use `nextI' temporarily because need an address for R_tabulate */ nextI = *ntip + *nnode; Ndegr = (int*)R_alloc(nextI, sizeof(int)); - for (i = 0; i < nextI; i++) Ndegr[i] = 0; + memset(Ndegr, 0, nextI*sizeof(int)); R_tabulate(edge1, nedge, &nextI, Ndegr); /* `ready' indicates whether an edge is ready to be */ -- 2.39.2