From: paradis Date: Mon, 5 Mar 2012 11:42:29 +0000 (+0000) Subject: a few fixes X-Git-Url: https://git.donarmstrong.com/?p=ape.git;a=commitdiff_plain;h=e43c90282fbbdbc38d185cee55cfa0d446554c81 a few fixes git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@181 6e262413-ae40-0410-9e79-b911bd7a66b7 --- diff --git a/DESCRIPTION b/DESCRIPTION index 7d6ef89..a69b65a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/NEWS b/NEWS index 2ebf72e..87f4ffa 100644 --- 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. diff --git a/R/compute.brtime.R b/R/compute.brtime.R index 35a358a..24e9b83 100644 --- a/R/compute.brtime.R +++ b/R/compute.brtime.R @@ -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 } - diff --git a/R/ltt.plot.R b/R/ltt.plot.R index 17a1d31..520294f 100644 --- a/R/ltt.plot.R +++ b/R/ltt.plot.R @@ -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) diff --git a/R/write.nexus.R b/R/write.nexus.R index fd44078..00fcffc 100644 --- a/R/write.nexus.R +++ b/R/write.nexus.R @@ -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 c16ee82..f6c513d 100644 --- 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). diff --git a/man/ltt.plot.Rd b/man/ltt.plot.Rd index b40cf1e..9af1116 100644 --- a/man/ltt.plot.Rd +++ b/man/ltt.plot.Rd @@ -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{