]> git.donarmstrong.com Git - ape.git/commitdiff
a fix in cophyloplot()
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Tue, 14 Feb 2012 04:15:37 +0000 (04:15 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Tue, 14 Feb 2012 04:15:37 +0000 (04:15 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@178 6e262413-ae40-0410-9e79-b911bd7a66b7

DESCRIPTION
NEWS
R/bind.tree.R
R/cophyloplot.R
R/plotPhyloCoor.R
R/root.R
man/bind.tree.Rd
src/dist_dna.c

index 9f97add0ae60710c1359a395d300d0650cb12119..6ad0dbccdabaf6a5411bd723fa6a974dde67736e 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
-Version: 3.0
-Date: 2012-02-10
+Version: 3.0-1
+Date: 2012-02-14
 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 0a4293ea3df9c121d1d74dac19fd1ea12278e2c6..53eb924bb2734247fdcdc6ac271698869bb7d741 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,20 @@
+               CHANGES IN APE VERSION 3.0-1
+
+
+NEW FEATURES
+
+    o bind.tree() now accepts 'position' > 0 when the trees have no
+      banch lengths permitting to create a node in 'x' when grafting
+      'y' (see ?bind.tree for details).
+
+
+BUG FIXES
+
+    o cophyloplot( , rotate = TRUE) made R hanged after a few clicks.
+      Also the tree is no more plotted twice.
+
+
+
                CHANGES IN APE VERSION 3.0
 
 
index cc7ee1ff3a055ca837889415b3d48c2cf2161d7c..b43ce900055d4c393e324023ab7ff57801a0afe8 100644 (file)
@@ -1,8 +1,8 @@
-## bind.tree.R (2011-06-21)
+## bind.tree.R (2012-02-13)
 
 ##    Bind Trees
 
-## Copyright 2003-2011 Emmanuel Paradis
+## Copyright 2003-2012 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -63,9 +63,11 @@ bind.tree <- function(x, y, where = "root", position = 0, interactive = FALSE)
     ## case = 3 -> y is bound on a node of x
 
     ## check that 'position' is correct
-    if (position) {
-        if (!wbl)
-            stop("'position' is non-null but trees have no branch lengths")
+    if (position && wbl) {
+### New in ape 3.0-1: this makes possible binding 'y' below
+### a node of 'x' thus creating a new node in 'x'
+###        if (!wbl)
+###            stop("'position' is non-null but trees have no branch lengths")
         if (case == 1) {
             if (xHasNoRootEdge)
                 stop("tree 'x' has no root edge")
index faf9e34ae792f5571dc4b80910e4514c27b3b719..85f091fd8614bc15176e8f7691a6e20601de7958 100644 (file)
@@ -1,4 +1,4 @@
-## cophyloplot.R (2010-03-18)
+## cophyloplot.R (2012-02-14)
 
 ##   Plots two phylogenetic trees face to
 ##   face with the links between the tips
@@ -29,14 +29,10 @@ cophyloplot <-
             if (click < length(res$a[, 1]) + 1) {
                 if (click > res$N.tip.x)
                   x <- rotate(x, click)
-            }
-            else if (click < length(res$c[, 1]) + 1) {
+            } else if (click < length(res$c[, 1]) + 1) {
                 if (click > length(res$a[, 1]) + res$N.tip.y)
                   y <- rotate(y, click - length(res$a[, 1]))
             }
-            plotCophylo2(x, y, assoc = assoc, use.edge.length = use.edge.length,
-                space = space, length.line = length.line, gap = gap,
-                type = type, return = TRUE, col = col, lwd=lwd, lty=lty, show.tip.label = show.tip.label, font = font)
         }
         on.exit(print("done"))
     }
index 8ede4df55bf89aaa871b4b6eca72011658347761..35f9ae4e8a0a17d011b1de1120bdbc49689c3b07 100644 (file)
@@ -1,4 +1,4 @@
-## plotPhyloCoor.R (2008-04-30)
+## plotPhyloCoor.R (2012-02-14)
 
 ##   Coordinates of a Tree Plot
 
@@ -32,7 +32,8 @@ plotPhyloCoor <-
     }
 
     xe <- x$edge
-    x <- reorder(x, order = "pruningwise")
+    ## first reorder the tree in cladewise order to avoid cophyloplot() hanging:
+    x <- reorder(reorder(x), order = "pruningwise")
     ereorder <- match(x$edge[, 2], xe[, 2])
 
     if (phyloORclado) {
index 8526b8f3d4f74add15240b88eca14a8267785496..8c1d9b26f9ebbfa49dc49f7826b910f262c07c47 100644 (file)
--- a/R/root.R
+++ b/R/root.R
@@ -31,7 +31,7 @@ unroot <- function(phy)
     ## eventually adding the branch length to the other one
     ## also coming from the root.
     ## In all cases, the node deleted is the 2nd one (numbered
-    ## nb.tip+2 in `edge'), so we simply need to renumber the
+    ## nb.tip+2 in 'edge'), so we simply need to renumber the
     ## nodes by adding 1, except the root (this remains the
     ## origin of the tree).
     nb.tip <- length(phy$tip.label)
@@ -57,7 +57,7 @@ unroot <- function(phy)
     }
     phy$Nnode <- phy$Nnode - 1L
     if (!is.null(phy$node.label))
-      phy$node.label <- phy$node.label[-2]
+        phy$node.label <- phy$node.label[-2]
     phy
 }
 
index f7de459f80f2752d5f8c51f5d479dc6643b6b463..b1e9908c65ab9beaf80261c57142541ae8720147 100644 (file)
@@ -35,6 +35,17 @@ bind.tree(x, y, where = "root", position = 0, interactive = FALSE)
     bind.tree(x, y, position = if (is.null(x$root.edge)) 0 else
     x$root.edge)
   }
+
+  If only one of the trees has no branch length, the branch lengths of
+  the other one are ignored with a warning.
+
+  If one (or both) of the trees has no branch length, it is possible to
+  specify a value of 'position' to graft 'y' below the node of 'x'
+  specified by 'where'. In this case, the exact value of 'position' is
+  not important as long as it is greater than zero. The new node will be
+  multichotomous if 'y' has no root edge. This can be solved by giving
+  an arbitrary root edge to 'y' beforehand (e.g., \code{y$root.edge <-
+  1}): it will be deleted during the binding operation.
 }
 \value{
   an object of class \code{"phylo"}.
index 7174af6d013d961c80dba33b453c78ad5e3c8bfe..61f32d29ca3a55e5d526fe3b3de8a09d7e3f1c95 100644 (file)
@@ -1,4 +1,4 @@
-/* dist_dna.c       2012-01-10 */
+/* dist_dna.c       2012-02-13 */
 
 /* Copyright 2005-2012 Emmanuel Paradis
 
@@ -73,6 +73,9 @@ double detFourByFour(double *x)
     }\
     if (IsPyrimidine(x[s1]) && IsPyrimidine(x[s2])) Ns++;
 
+
+
+
 void distDNA_TsTv(unsigned char *x, int *n, int *s, double *d, int Ts, int pairdel)
 {
        int i1, i2, s1, s2, target, Nd, Ns;
@@ -81,7 +84,7 @@ void distDNA_TsTv(unsigned char *x, int *n, int *s, double *d, int Ts, int paird
        for (i1 = 1; i1 < *n; i1++) {
                for (i2 = i1 + 1; i2 <= *n; i2++) {
                        Nd = Ns = 0;
-                       for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+                       for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                                if (pairdel && !(KnownBase(x[s1]) && KnownBase(x[s2]))) continue;
                                COUNT_TS_TV
                        }
@@ -100,7 +103,7 @@ void distDNA_raw(unsigned char *x, int *n, int *s, double *d, int scaled)
        for (i1 = 1; i1 < *n; i1++) {
                for (i2 = i1 + 1; i2 <= *n; i2++) {
                        Nd = 0;
-                       for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n)
+                       for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n)
                                if (DifferentBase(x[s1], x[s2])) Nd++;
                        if (scaled) d[target] = ((double) Nd / *s);
                        else d[target] = ((double) Nd);
@@ -117,7 +120,7 @@ void distDNA_raw_pairdel(unsigned char *x, int *n, int *s, double *d, int scaled
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = L = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                 CHECK_PAIRWISE_DELETION
                if (DifferentBase(x[s1], x[s2])) Nd++;
            }
@@ -150,7 +153,7 @@ void distDNA_JC69(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n)
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n)
              if (DifferentBase(x[s1], x[s2])) Nd++;
            COMPUTE_DIST_JC69
            target++;
@@ -233,7 +236,7 @@ void distDNA_K80_pairdel(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Ns = L = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                CHECK_PAIRWISE_DELETION
                COUNT_TS_TV
            }
@@ -285,7 +288,7 @@ void distDNA_F81_pairdel(unsigned char *x, int *n, int *s, double *d, double *BF
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = L = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                CHECK_PAIRWISE_DELETION
                if (DifferentBase(x[s1], x[s2])) Nd++;
            }
@@ -332,7 +335,7 @@ void distDNA_K81(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Nv1 = Nv2 = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                COUNT_TS_TV1_TV2
            }
            COMPUTE_DIST_K81
@@ -351,7 +354,7 @@ void distDNA_K81_pairdel(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Nv1 = Nv2 = L = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                CHECK_PAIRWISE_DELETION
                COUNT_TS_TV1_TV2
            }
@@ -392,7 +395,7 @@ void distDNA_F84(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Ns = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                COUNT_TS_TV
            }
            COMPUTE_DIST_F84
@@ -413,7 +416,7 @@ void distDNA_F84_pairdel(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Ns = L = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                CHECK_PAIRWISE_DELETION
                COUNT_TS_TV
            }
@@ -449,7 +452,7 @@ void distDNA_T92(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Ns = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                COUNT_TS_TV
            }
            COMPUTE_DIST_T92
@@ -470,7 +473,7 @@ void distDNA_T92_pairdel(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Ns = L = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                CHECK_PAIRWISE_DELETION
                COUNT_TS_TV
            }
@@ -546,7 +549,7 @@ void distDNA_TN93(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Ns1 = Ns2 = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                COUNT_TS1_TS2_TV
            }
            COMPUTE_DIST_TN93
@@ -568,7 +571,7 @@ void distDNA_TN93_pairdel(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Ns1 = Ns2 = L = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                CHECK_PAIRWISE_DELETION
                COUNT_TS1_TS2_TV
            }
@@ -610,7 +613,7 @@ void distDNA_GG95(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Ns = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                COUNT_TS_TV
            }
            P[target] = ((double) Ns / *s);
@@ -686,7 +689,7 @@ void distDNA_GG95_pairdel(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            Nd = Ns = L[target] = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                if (KnownBase(x[s1]) && KnownBase(x[s2])) L[target]++;
                else continue;
                COUNT_TS_TV
@@ -772,7 +775,7 @@ void distDNA_LogDet(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            for (k = 0; k < 16; k++) Ntab[k] = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                DO_CONTINGENCY_NUCLEOTIDES
            }
            COMPUTE_DIST_LogDet
@@ -792,7 +795,7 @@ void distDNA_LogDet_pairdel(unsigned char *x, int *n, int *s, double *d,
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            for (k = 0; k < 16; k++) Ntab[k] = 0;
            L = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                CHECK_PAIRWISE_DELETION
                DO_CONTINGENCY_NUCLEOTIDES
            }
@@ -818,7 +821,7 @@ void distDNA_BH87(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            for (k = 0; k < 16; k++) Ntab[k] = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                DO_CONTINGENCY_NUCLEOTIDES
            }
 
@@ -916,7 +919,7 @@ void distDNA_ParaLin(unsigned char *x, int *n, int *s, double *d,
     for (i1 = 1; i1 < *n; i1++) {
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            for (k = 0; k < 16; k++) Ntab[k] = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                DO_CONTINGENCY_NUCLEOTIDES
            }
            COMPUTE_DIST_ParaLin
@@ -960,7 +963,7 @@ void distDNA_ParaLin_pairdel(unsigned char *x, int *n, int *s, double *d,
         for (i2 = i1 + 1; i2 <= *n; i2++) {
            L = 0;
            for (k = 0; k < 16; k++) Ntab[k] = 0;
-           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1+= *n, s2 += *n) {
+           for (s1 = i1 - 1, s2 = i2 - 1; s1 < i1 + *n*(*s - 1); s1 += *n, s2 += *n) {
                CHECK_PAIRWISE_DELETION
                DO_CONTINGENCY_NUCLEOTIDES
            }
@@ -1115,6 +1118,7 @@ void dist_dna(unsigned char *x, int *n, int *s, int *model, double *d,
            else distDNA_TsTv(x, n, s, d, 1, 0); break;
     case 15 : if (pairdel) distDNA_TsTv(x, n, s, d, 0, 1);
            else distDNA_TsTv(x, n, s, d, 0, 0); break;
-
+    case 16 : distDNA_indel(x, n, s, d); break;
+    case 17 : distDNA_indelblock(x, n, s, d); break;
     }
 }