]> git.donarmstrong.com Git - ape.git/commitdiff
fixed bugs in multi2di and di2multi + code and doc clean-up
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Mon, 17 Mar 2008 07:43:39 +0000 (07:43 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Mon, 17 Mar 2008 07:43:39 +0000 (07:43 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@22 6e262413-ae40-0410-9e79-b911bd7a66b7

Changes
DESCRIPTION
R/multi2di.R
man/DNAbin.Rd
man/multi2di.Rd
man/read.tree.Rd
src/reorder_phylo.c

diff --git a/Changes b/Changes
index aa313f07b306e42b7e1099614677d627a77a8324..087178573cc5992e6373de8289516681bf0fba36 100644 (file)
--- 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
index 801dc62d173d82ba9820dfe09196568c22999b60..7c0832418f4417b6517d0b839e3f34a8ecbdaa93 100644 (file)
@@ -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,
index 7bb4c8868378e15a069b517792bed3797998e441..731f3286fee3357ae11020b7f4a8c66725d7b5a7 100644 (file)
@@ -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
 }
index 94593727bae759bc817b340ca29a4f501939ccbb..ca1b23e83f1e682aae3dee81b233618c9a08a22c 100644 (file)
@@ -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{
index bf53982d81e0cadb1ca54b3f63ac74ef118e17f7..ddb0f3c20745fb0965408d1c408fc8bf38914279 100644 (file)
@@ -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)
index 698c728b1ff68ce9cabe40d22827a81f78334ff3..75f4cb55355fd400abc4e3d19df314db2efd9650 100644 (file)
@@ -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}}
index 2ab6f5b2f97963bc3ec7b4ef811156281818ded0..c54ea52ee9103d28eef2ca301903503dca327e04 100644 (file)
@@ -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 */