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
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>
-## as.phylo.R (2011-03-16)
+## as.phylo.R (2011-03-25)
## Conversion Among Tree Objects
as.phylo <- function (x, ...)
{
- if (class(x) == "phylo") return(x)
+ if (length(class(x)) == 1 && class(x) == "phylo")
+ return(x)
UseMethod("as.phylo")
}
-## dist.topo.R (2011-02-21)
+## dist.topo.R (2011-03-26)
## Topological Distances, Tree Bipartitions,
## Consensus Trees, and Bootstrapping Phylogenies
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
-## read.nexus.R (2011-03-18)
+## read.nexus.R (2011-03-26)
## Read Tree File in Nexus Format
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)
} 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)
}
}
class(trees) <- "multiPhylo"
+ if (!all(nms.trees == "")) names(trees) <- nms.trees
}
if (length(grep("[\\/]", file)) == 1)
if (!file.exists(file)) # suggestion by Francois Michonneau
-## 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.
}
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)
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
}
\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)
\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.