]> git.donarmstrong.com Git - ape.git/commitdiff
a few fixes
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Mon, 5 Mar 2012 11:42:29 +0000 (11:42 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Mon, 5 Mar 2012 11:42:29 +0000 (11:42 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@181 6e262413-ae40-0410-9e79-b911bd7a66b7

DESCRIPTION
NEWS
R/compute.brtime.R
R/ltt.plot.R
R/write.nexus.R
Thanks
man/ltt.plot.Rd

index 7d6ef8936ebe156a6c845171477ee817de1c92a3..a69b65a57a30943bacfb8ed575ae97e64c9adffb 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
 Version: 3.0-2
-Date: 2012-02-27
+Date: 2012-03-05
 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 2ebf72e906fb998d185d1c717e7ef728a5766255..87f4ffa73ae62dc802aa1b1b0006335d9048c378 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,17 @@ NEW FEATURES
       alignment and opens the result in a new window.
 
 
+BUG FIXES
+
+    o compute.brtime() did not completely randomized the order of the
+      branching times.
+
+    o write.nexus() did not work correctly with rooted trees (thanks
+      to Matt Johnson for the fix).
+
+    o mltt.plot(, backward = FALSE) did not set the x-axis correctly.
+
+
 
                CHANGES IN APE VERSION 3.0-1
 
@@ -28,7 +39,7 @@ BUG FIXES
     o read.GenBank() has been updated to work with EFetch 2.0.
 
     o unroot() on trees in "pruningwise" order did not respect this
-      attribute
+      attribute.
 
 
 
index 35a358ab0812f6dc4e46381e8ce5bfe254122996..24e9b83226cdd057dda1fa3113febedb09dce2c3 100644 (file)
@@ -1,8 +1,8 @@
-## compute.brtime.R (2011-07-26)
+## compute.brtime.R (2012-03-02)
 
 ##   Compute and Set Branching Times
 
-## Copyright 2011 Emmanuel Paradis
+## Copyright 2011-2012 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -32,15 +32,24 @@ compute.brtime <-
 
     y <- c(rep(0, n), x) # for all nodes (terminal and internal)
 
-    phy <- reorder(phy, "pruningwise")
-    e1 <- phy$edge[, 1L] # local copies of the pointer
+    e1 <- phy$edge[, 1L] # local copies of the pointers
     e2 <- phy$edge[, 2L] #
-    el <- numeric(N)
-    if (force.positive) y[unique(e1)] <- sort(x)
 
-    for (i in 1:N) el[i] <- y[e1[i]] - y[e2[i]]
+    if (force.positive) {
+        o <- .Call("seq_root2tip", phy$edge, n, m, PACKAGE = "ape")
+        list.nodes <- list(n + 1L)
+        i <- 2L
+        repeat {
+            z <- sapply(o, "[", i)
+            z <- unique(z[!(z <= n | is.na(z))])
+            if (!length(z)) break
+            list.nodes[[i]] <- z
+            i <- i + 1L
+        }
+        nodes <- unlist(lapply(list.nodes, function(x) x[sample(length(x))]))
+        y[nodes] <- sort(x, decreasing = TRUE)
+    }
 
-    phy$edge.length <- el
-    reorder(phy)
+    phy$edge.length <- y[e1] - y[e2]
+    phy
 }
-
index 17a1d3152248e4e4201c52a2442dd7f78f60c203..520294fc9cb68c4313637c65bf5b6f3e33bbe525 100644 (file)
@@ -1,8 +1,8 @@
-## ltt.plot.R (2011-09-24)
+## ltt.plot.R (2012-03-05)
 
 ##    Lineages Through Time Plot
 
-## Copyright 2002-2011 Emmanuel Paradis
+## Copyright 2002-2012 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -106,14 +106,24 @@ mltt.plot <-
                 a <- lapply(dts[[i]], ltt.plot.coords, backward = backward, tol = tol)
                 names(a) <- names(dts[[i]])
                 if (is.null(names(a)))
-                    names(a) <- paste(deparse(substitute(phy)), "-", 1:length(a))
+                    names(a) <- paste(deparse(substitute(phy)), "-", seq_along(a))
             }
             TREES <- c(TREES, a)
         }
     }
     n <- length(TREES)
-    xl <- c(min(unlist(lapply(TREES, function(x) min(x[, 1])))), 0)
-    yl <- c(1, max(unlist(lapply(TREES, function(x) max(x[, 2])))))
+    range.each.tree <- sapply(TREES, function(x) range(x[, 1]))
+    xl <- range(range.each.tree)
+    yl <- c(1, max(sapply(TREES, function(x) max(x[, 2]))))
+
+    ## if backward is FALSE, we have to rescale the time scales of each tree:
+    if (!backward) {
+        for (i in seq_along(TREES)) {
+            tmp <- TREES[[i]]
+            tmp[, 1] <- tmp[, 1] + xl[2] - range.each.tree[2, i]
+            TREES[[i]] <- tmp
+        }
+    }
 
     plot.default(NA, type = "n", xlim = xl, ylim = yl, xaxs = "r",
                  yaxs = "r", xlab = xlab, ylab = ylab, log = log)
index fd4407832b4c6ca2ddb12e78cc5a91b53466b7ab..00fcffc9f481614952d2bf8c5cf015bc819f7eba 100644 (file)
@@ -1,4 +1,4 @@
-## write.nexus.R (2012-02-09)
+## write.nexus.R (2012-03-02)
 
 ##   Write Tree File in Nexus Format
 
@@ -67,9 +67,8 @@ write.nexus <- function(..., file = "", translate = TRUE, original.data = NULL)
 
     for (i in 1:ntree) {
         if (class(obj[[i]]) != "phylo") next
-        if (is.rooted(obj[[i]]))
-          cat("\tTREE *,", title[i], "= [&R] ", file = file, append = TRUE)
-        else cat("\tTREE *", title[i], "= [&U] ", file = file, append = TRUE)
+        root.tag <- if (is.rooted(obj[[i]])) "= [&R] " else "= [&U] "
+        cat("\tTREE *", title[i], root.tag, file = file, append = TRUE)
         cat(write.tree(obj[[i]], file = ""),
             "\n", sep = "", file = file, append = TRUE)
     }
diff --git a/Thanks b/Thanks
index c16ee8253847a786da8cc00eee0312ca2b3268b1..f6c513d251eb93bfe8133dbfda6b86f56b50326c 100644 (file)
--- a/Thanks
+++ b/Thanks
@@ -6,11 +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, 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.
+FitzJohn, Matt Johnson, 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.
@@ -22,4 +22,4 @@ Financial support was provided by the Department of Information
 Systems of IRD in form a "SPIRALES" project (2006).
 
 Financial support was provided by Google to Andrei-Alin Popescu during
-the 2011 Google Summer of Code (GSoC 2011).
\ No newline at end of file
+the 2011 Google Summer of Code (GSoC 2011).
index b40cf1e4d4f04a124860f65d5d82ae2a08307b8b..9af111642be9e92529a2ed0b4c16f91e0ac2ecac 100644 (file)
@@ -57,8 +57,8 @@ ltt.plot.coords(phy, backward = TRUE, tol = 1e-6)
 
   The option \code{tol} is used as follows: first the most distant tip
   from the root is found, then all tips whose distance to the root is
-  not more different from the previous one than \code{tol} are
-  considered to be contemporaneous with it.
+  not different from the previous one than \code{tol} are considered to
+  be contemporaneous with it.
 
   If the tree is not ultrametric, the plot is done assuming the tips,
   except the most distant from the root, represent extinction events. If
@@ -73,8 +73,11 @@ ltt.plot.coords(phy, backward = TRUE, tol = 1e-6)
   \code{"phylo"} (single trees) and/or \code{"multiPhylo"} (multiple
   trees). Any number of objects may be given. This function is mainly
   for exploratory analyses with the advantages that the axes are set
-  properly to view all lines, and the legend is plotted by default. For
-  more flexible settings of line drawings, it may be better to combine
+  properly to view all lines, and the legend is plotted by default. The
+  plot will certainly make sense if all trees have their
+  most-distant-from-the-root tips contemporaneous (i.e., trees with only
+  extinct lineages will not be represented properly). For more flexible
+  settings of line drawings, it may be better to combine
   \code{ltt.plot()} with successive calls of \code{ltt.lines()} (see
   examples).
 
@@ -101,9 +104,9 @@ ltt.plot.coords(phy, backward = TRUE, tol = 1e-6)
 }
 \author{Emmanuel Paradis}
 \seealso{
-  \code{\link{skyline}}, \code{\link{branching.times}},
-  \code{\link{birthdeath}}, \code{\link{bd.ext}},
-  \code{\link{yule.cov}}, \code{\link{bd.time}};
+  \code{\link{kronoviz}}, \code{\link{skyline}},
+  \code{\link{branching.times}}, \code{\link{birthdeath}},
+  \code{\link{bd.ext}}, \code{\link{yule.cov}}, \code{\link{bd.time}};
   \code{\link[graphics]{plot}} for the basic plotting function in R
 }
 \examples{