]> git.donarmstrong.com Git - ape.git/commitdiff
final update for ape 2.7-1
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Sat, 26 Mar 2011 08:41:35 +0000 (08:41 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Sat, 26 Mar 2011 08:41:35 +0000 (08:41 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@154 6e262413-ae40-0410-9e79-b911bd7a66b7

ChangeLog
DESCRIPTION
R/as.phylo.R
R/dist.topo.R
R/read.nexus.R
R/write.nexus.R
man/ace.Rd
man/plot.phylo.Rd
man/richness.yule.test.Rd

index 5f6172d24d48c3f8a82f69cc8258ce1dbd9df2f8..40d2a9549737beaae4fd14e5a894e38faa5f0b35 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,15 +19,22 @@ BUG FIXES
     o image.DNAbin() did not colour correctly the bases if there were
       some '-' and no 'N'.
 
+    o .compressTipLabel() failed with a list with a single tree.
+
     o identify.phylo() returned a wrong answer when the x- and y-scales
       are very different.
 
+    o write.nexus() failed with lists of trees with compressed labels.
+
 
 OTHER CHANGES
 
     o identify.phylo() now returns NULL if the user right-(instead of
       left-)clicks (an error was returned previously).
 
+    o read.nexus() should be robust to commands inserted in the TREES
+      block.
+
 
 
                CHANGES IN APE VERSION 2.7
index 32054d419cf3b963ae83df5ec1285a689ddbb794..6da064ba81c6cd7dca80f2e53544c620b7d23351 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
 Version: 2.7-1
-Date: 2011-03-22
+Date: 2011-03-26
 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, Klaus Schliep, Korbinian Strimmer, Damien de Vienne
 Maintainer: Emmanuel Paradis <Emmanuel.Paradis@ird.fr>
index 8ebd54049fa1b9693a48bd034a8203a71aaaa633..5d541bce67f3de75f947ba59caa0ea256921e4eb 100644 (file)
@@ -1,4 +1,4 @@
-## as.phylo.R (2011-03-16)
+## as.phylo.R (2011-03-25)
 
 ##     Conversion Among Tree Objects
 
@@ -29,7 +29,8 @@ new2old.phylo <- function(phy)
 
 as.phylo <- function (x, ...)
 {
-    if (class(x) == "phylo") return(x)
+    if (length(class(x)) == 1 && class(x) == "phylo")
+        return(x)
     UseMethod("as.phylo")
 }
 
index d94866adfe1c65f9c46946567573196b6a4e51a9..e192f4f43b56184fc8a3a6545fd85a2b3b6fb8db 100644 (file)
@@ -1,4 +1,4 @@
-## dist.topo.R (2011-02-21)
+## dist.topo.R (2011-03-26)
 
 ##      Topological Distances, Tree Bipartitions,
 ##   Consensus Trees, and Bootstrapping Phylogenies
@@ -71,23 +71,26 @@ dist.topo <- function(x, y, method = "PH85")
     if (any(table(ref) != 1))
         stop("some tip labels are duplicated in tree no. 1")
     n <- length(ref)
-    for (i in 2:length(x)) {
-        label <- x[[i]]$tip.label
-        if (!identical(label, ref)) {
-            if (length(label) != length(ref))
-                stop(paste("tree no.", i, "has a different number of tips"))
-            ilab <- match(label, ref)
-            ## can use tabulate here because 'ilab' contains integers
-            if (any(is.na(ilab)))
-                stop(paste("tree no.", i, "has different tip labels"))
+    Ntree <- length(x)
+    if (Ntree > 1) {
+        for (i in 2:Ntree) {
+            label <- x[[i]]$tip.label
+            if (!identical(label, ref)) {
+                if (length(label) != length(ref))
+                    stop(paste("tree no.", i, "has a different number of tips"))
+                ilab <- match(label, ref)
+                ## can use tabulate here because 'ilab' contains integers
+                if (any(is.na(ilab)))
+                    stop(paste("tree no.", i, "has different tip labels"))
 ### <FIXME> the test below does not seem useful anymore
 ###            if (any(tabulate(ilab) > 1))
 ###                stop(paste("some tip labels are duplicated in tree no.", i))
 ### </FIXME>
-            ie <- match(1:n, x[[i]]$edge[, 2])
-            x[[i]]$edge[ie, 2] <- ilab
+                ie <- match(1:n, x[[i]]$edge[, 2])
+                x[[i]]$edge[ie, 2] <- ilab
+            }
+            x[[i]]$tip.label <- NULL
         }
-        x[[i]]$tip.label <- NULL
     }
     x[[1]]$tip.label <- NULL
     attr(x, "TipLabel") <- ref
index 117b31f36ce61b33178734b3715dff078e23cb9e..cdbc291645823ac923f9db659f034e4194d277f7 100644 (file)
@@ -1,4 +1,4 @@
-## read.nexus.R (2011-03-18)
+## read.nexus.R (2011-03-26)
 
 ##   Read Tree File in Nexus Format
 
@@ -154,12 +154,13 @@ read.nexus <- function(file, tree.names = NULL)
     end <- endblock[endblock > i1][1] - 1
     tree <- X[start:end]
     rm(X)
-    tree <- gsub("^.*= *", "", tree)
+###    tree <- gsub("^.*= *", "", tree)
     ## check whether there are empty lines from the above manips:
     tree <- tree[tree != ""]
     semico <- grep(";", tree)
-    Ntree <- length(semico)
+    Ntree <- length(semico) # provisional -- some ";" may actually mark end of commands
     ## are some trees on several lines?
+    ## -- this actually 'packs' all characters ending with a ";" in a single string --
     if (Ntree == 1 && length(tree) > 1) STRING <- paste(tree, collapse = "") else {
         if (any(diff(semico) != 1)) {
             STRING <- character(Ntree)
@@ -175,7 +176,14 @@ read.nexus <- function(file, tree.names = NULL)
         } else STRING <- tree
     }
     rm(tree)
-    STRING <- gsub(" ", "", STRING)
+    ## exclude the possible command lines ending with ";":
+    STRING <- STRING[grep("^[[:blank:]]*tree.*= *", STRING, ignore.case = TRUE)]
+    Ntree <- length(STRING) # update Ntree
+    ## get the tree names:
+    nms.trees <- sub(" *= *.*", "", STRING) # only the first occurence of "="
+    nms.trees <- sub("^ *tree *", "", nms.trees, ignore.case = TRUE)
+    STRING <- sub("^.*= *", "", STRING) # delete title and 'TREE' command with 'sub'
+    STRING <- gsub(" ", "", STRING) # delete all white spaces
     colon <- grep(":", STRING)
     if (!length(colon)) {
         trees <- lapply(STRING, clado.build)
@@ -237,6 +245,7 @@ read.nexus <- function(file, tree.names = NULL)
             }
         }
         class(trees) <- "multiPhylo"
+        if (!all(nms.trees == "")) names(trees) <- nms.trees
     }
     if (length(grep("[\\/]", file)) == 1)
         if (!file.exists(file)) # suggestion by Francois Michonneau
index 2a3c32ada3ce1a5102abf6d0c1492a25bcb6fc90..1db2252d74b0c4d8cd63531de1510a5280a7eed1 100644 (file)
@@ -1,8 +1,8 @@
-## write.nexus.R (2011-02-26)
+## write.nexus.R (2011-03-26)
 
 ##   Write Tree File in Nexus Format
 
-## Copyright 2003-2011x Emmanuel Paradis
+## Copyright 2003-2011 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -57,26 +57,24 @@ the original data won't be written with the tree."))
     }
     cat("BEGIN TREES;\n", file = file, append = TRUE)
     if (translate) {
-        ## We take arbitrarily the labels of the first tree, and
-        ## translate them as "1", "2", "3", ...
         cat("\tTRANSLATE\n", file = file, append = TRUE)
-        tmp <- checkLabel(obj[[1]]$tip.label)
-        X <- paste("\t\t", 1:N, "\t", tmp, ",", sep = "")
+        obj <- .compressTipLabel(obj)
+        X <- paste("\t\t", 1:N, "\t", attr(obj, "TipLabel"), ",", sep = "")
         ## We remove the last comma:
         X[length(X)] <- gsub(",", "", X[length(X)])
         cat(X, file = file, append = TRUE, sep = "\n")
         cat("\t;\n", file = file, append = TRUE)
-        token <- as.character(1:N)
-        names(token) <- obj[[1]]$tip.label
-        obj[[1]]$tip.label <- token
-        if (ntree > 1) {
-            for (i in 2:ntree)
-                obj[[i]]$tip.label <- token[obj[[i]]$tip.label]
-            class(obj) <- NULL
-        }
-    } else {
+        class(obj) <- NULL
         for (i in 1:ntree)
-            obj[[i]]$tip.label <- checkLabel(obj[[i]]$tip.label)
+            obj[[i]]$tip.label <- as.character(1:N)
+    } else {
+        if (is.null(attr(obj, "TipLabel"))) {
+            for (i in 1:ntree)
+                obj[[i]]$tip.label <- checkLabel(obj[[i]]$tip.label)
+        } else {
+            attr(obj, "TipLabel") <- checkLabel(attr(obj, "TipLabel"))
+            obj <- .uncompressTipLabel(obj)
+        }
     }
 
     title <- names(obj)
index f440027d34297bcf7857f78ab7b879883a06bf23..126a21604047e56ed508433fddae6c55633aa112 100644 (file)
@@ -71,7 +71,17 @@ ace(x, phy, type = "continuous", method = "ML", CI = TRUE,
   generalized least squares (\code{method = "GLS"}, Martins and Hansen
   1997, Cunningham et al. 1998). In the latter case, the specification
   of \code{phy} and \code{model} are actually ignored: it is instead
-  given through a correlation structure with the option \code{corStruct}.
+  given through a correlation structure with the option
+  \code{corStruct}.
+
+  In the default setting (i.e., \code{method = "ML"} and \code{model =
+  "BM"}) the maximum likelihood estimation is done simultaneously on
+  the ancestral values and the variance of the Brownian motion process;
+  these estimates are then used to compute the confidence intervals in
+  the standard way (see the package \pkg{geiger} for a different
+  implementation). If \code{method = "pic"} or \code{"GLS"}, the
+  confidence intervals are computed using the expected variances under
+  the model, so they depend only on the tree.
 
   For discrete characters (\code{type = "discrete"}), only maximum
   likelihood estimation is available (Pagel 1994). The model is
index 614ce6285a24f8f5b28209d737ddfc65c016b014..f6a137cc3fbb9d3372d3df7d807c1266c274a753 100644 (file)
 }
 \author{Emmanuel Paradis}
 \seealso{
-  \code{\link{read.tree}}, \code{\link{add.scale.bar}},
-  \code{\link{axisPhylo}}, \code{\link{nodelabels}},
-  \code{\link{edges}}, \code{\link[graphics]{plot}} for the basic
-  plotting function in R
+  \code{\link{read.tree}}, \code{\link{trex}}, \code{\link{kronoviz}},
+  \code{\link{add.scale.bar}}, \code{\link{axisPhylo}},
+  \code{\link{nodelabels}}, \code{\link{edges}},
+  \code{\link[graphics]{plot}} for the basic plotting function in R
 }
 \examples{
 ### An extract from Sibley and Ahlquist (1990)
index b9ba89825e588cd54511402c330ea0ad1ba6d0c4..21df5907478044af48d23440945b547f47029897 100644 (file)
@@ -17,8 +17,6 @@ richness.yule.test(x, t)
   \item{t}{a numeric vector giving the divergence times of each pair of
     clades in \code{x}.}
 }
-\details{
-}
 \value{
   a data frame with the \eqn{\chi^2}{chi2}, the number of degrees of
   freedom (= 1), and the \emph{P}-value.