From: paradis Date: Fri, 12 Oct 2012 07:56:32 +0000 (+0000) Subject: some changes for ape 3.0-6 X-Git-Url: https://git.donarmstrong.com/?p=ape.git;a=commitdiff_plain;h=da67dccb93d35408baa48b141fcda921772c8b9c some changes for ape 3.0-6 git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@197 6e262413-ae40-0410-9e79-b911bd7a66b7 --- diff --git a/DESCRIPTION b/DESCRIPTION index 03b6257..32f124c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape Version: 3.0-6 -Date: 2012-08-17 +Date: 2012-10-12 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 729e3ed..6ba9bc4 100644 --- a/NEWS +++ b/NEWS @@ -7,7 +7,7 @@ NEW FEATURES index.only = TRUE to return only the vector of indices (the tree is unmodified, see ?reorder.phylo for details). - o The three new functions node.depth.length, node.height, and + o The three new functions node.depth.edgelength, node.height, and node.height.clado make some internal code available from R. See ?node.depth (which was already available and documented) for details. @@ -18,6 +18,9 @@ BUG FIXES o reorder(, "pruningwise") made R crash if the rows of the edge matrix are in random order: this is now fixed. + o drop.tip() sometimes shuffled node labels (thanks to Rebecca Best + for the report). + OTHER CHANGES diff --git a/R/drop.tip.R b/R/drop.tip.R index 5b635f6..e9bd5c0 100644 --- a/R/drop.tip.R +++ b/R/drop.tip.R @@ -1,8 +1,8 @@ -## drop.tip.R (2011-11-21) +## drop.tip.R (2012-10-06) ## Remove Tips in a Phylogenetic Tree -## 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. @@ -208,14 +208,10 @@ drop.tip <- phy$tip.label <- c(phy$tip.label, new.tip.label) } - ## update node.label if needed: - if (!is.null(phy$node.label)) - phy$node.label <- phy$node.label[sort(unique(phy$edge[, 1])) - Ntip] - phy$Nnode <- dim(phy$edge)[1] - n + 1L # update phy$Nnode ## The block below renumbers the nodes so that they conform - ## to the "phylo" format -- same as in root() + ## to the "phylo" format, same as in root() newNb <- integer(n + phy$Nnode) newNb[NEWROOT] <- n + 1L sndcol <- phy$edge[, 2] > n @@ -224,6 +220,10 @@ drop.tip <- (n + 2):(n + phy$Nnode) phy$edge[, 1] <- newNb[phy$edge[, 1]] storage.mode(phy$edge) <- "integer" + if (!is.null(phy$node.label)) { # update node.label if needed + newNb[is.na(newNb)] <- 0L + phy$node.label <- phy$node.label[order(newNb[newNb > 0])] + } collapse.singles(phy) } diff --git a/R/reorder.phylo.R b/R/reorder.phylo.R index ee9e9e0..e717eb2 100644 --- a/R/reorder.phylo.R +++ b/R/reorder.phylo.R @@ -1,4 +1,4 @@ -## reorder.phylo.R (2012-09-03) +## reorder.phylo.R (2012-10-12) ## Internal Reordering of Trees @@ -13,12 +13,13 @@ reorder.phylo <- function(x, order = "cladewise", index.only = FALSE, ...) io <- pmatch(order, ORDER) if (is.na(io)) stop("ambiguous order") order <- ORDER[io] + nb.edge <- dim(x$edge)[1] if (!is.null(attr(x, "order"))) - if (attr(x, "order") == order) return(x) + if (attr(x, "order") == order) + if (index.only) return(1:nb.edge) else return(x) nb.node <- x$Nnode if (nb.node == 1) return(x) nb.tip <- length(x$tip.label) - nb.edge <- dim(x$edge)[1] if (io == 3) { x <- reorder(x) neworder <- diff --git a/man/ace.Rd b/man/ace.Rd index 9686022..15bd387 100644 --- a/man/ace.Rd +++ b/man/ace.Rd @@ -6,6 +6,22 @@ \alias{AIC.ace} \alias{anova.ace} \title{Ancestral Character Estimation} +\description{ + This function estimates ancestral character states, and the associated + uncertainty, for continuous and discrete characters. + + \code{logLik}, \code{deviance}, and \code{AIC} are generic functions + used to extract the log-likelihood, the deviance, or the Akaike + information criterion of a fitted object. If no such values are + available, \code{NULL} is returned. + + \code{anova} is another generic function which is used to compare + nested models: the significance of the additional parameter(s) is + tested with likelihood ratio tests. You must ensure that the models + are effectively nested (if they are not, the results will be + meaningless). It is better to list the models from the smallest to the + largest. +} \usage{ ace(x, phy, type = "continuous", method = "ML", CI = TRUE, model = if (type == "continuous") "BM" else "ER", @@ -47,22 +63,6 @@ ace(x, phy, type = "continuous", method = "ML", CI = TRUE, information criterion.} \item{\dots}{further arguments passed to or from other methods.} } -\description{ - This function estimates ancestral character states, and the associated - uncertainty, for continuous and discrete characters. - - \code{logLik}, \code{deviance}, and \code{AIC} are generic functions - used to extract the log-likelihood, the deviance (-2*logLik), or the - Akaike information criterion of a tree. If no such values are - available, \code{NULL} is returned. - - \code{anova} is another generic function which is used to compare - nested models: the significance of the additional parameter(s) is - tested with likelihood ratio tests. You must ensure that the models - are effectively nested (if they are not, the results will be - meaningless). It is better to list the models from the smallest to the - largest. -} \details{ If \code{type = "continuous"}, the default model is Brownian motion where characters evolve randomly following a random walk. This model @@ -74,8 +74,8 @@ ace(x, phy, type = "continuous", method = "ML", CI = TRUE, 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 + In the default setting (\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. The REML method first estimates the ancestral value @@ -89,8 +89,8 @@ ace(x, phy, type = "continuous", method = "ML", CI = TRUE, It could be shown that, with a continous character, REML results in unbiased estimates of the variance of the Brownian motion process - while ML gives a downward bias. Therefore, the former is recommanded - over the latter, even though it is not the default. + while ML gives a downward bias. Therefore the former is recommanded, + even though it is not the default. For discrete characters (\code{type = "discrete"}), only maximum likelihood estimation is available (Pagel 1994). The model is @@ -110,7 +110,7 @@ ace(x, phy, type = "continuous", method = "ML", CI = TRUE, is determined from the data. } \value{ - a list with the following elements: + an object of class \code{"ace"} with the following elements: \item{ace}{if \code{type = "continuous"}, the estimates of the ancestral character values.} @@ -153,7 +153,7 @@ ace(x, phy, type = "continuous", method = "ML", CI = TRUE, Likelihood of ancestor states in adaptive radiation. \emph{Evolution}, \bold{51}, 1699--1711. } -\author{Emmanuel Paradis, Ben Bolker \email{bolker@zoo.ufl.edu}} +\author{Emmanuel Paradis, Ben Bolker} \seealso{ \code{\link{corBrownian}}, \code{\link{corGrafen}}, \code{\link{corMartins}}, \code{\link{compar.ou}}, diff --git a/man/collapse.singles.Rd b/man/collapse.singles.Rd index cd6e8b6..ecfa0ec 100644 --- a/man/collapse.singles.Rd +++ b/man/collapse.singles.Rd @@ -14,7 +14,7 @@ collapse.singles(tree) \value{ an object of class \code{"phylo"}. } -\author{Ben Bolker \email{bolker@zoo.ufl.edu}} +\author{Ben Bolker} \seealso{ \code{\link{plot.phylo}}, \code{\link{read.tree}} } diff --git a/man/dist.dna.Rd b/man/dist.dna.Rd index bc5d485..8168603 100644 --- a/man/dist.dna.Rd +++ b/man/dist.dna.Rd @@ -10,7 +10,7 @@ dist.dna(x, model = "K80", variance = FALSE, \item{x}{a matrix or a list containing the DNA sequences; this must be of class \code{"DNAbin"} (use \code{\link{as.DNAbin}} is they are stored as character).} - \item{model}{a character string specifying the evlutionary model to be + \item{model}{a character string specifying the evolutionary model to be used; must be one of \code{"raw"}, \code{"N"}, \code{"TS"}, \code{"TV"}, \code{"JC69"}, \code{"K80"} (the default), \code{"F81"}, \code{"K81"}, \code{"F84"}, \code{"BH87"}, @@ -19,16 +19,15 @@ dist.dna(x, model = "K80", variance = FALSE, \item{variance}{a logical indicating whether to compute the variances of the distances; defaults to \code{FALSE} so the variances are not computed.} - \item{gamma}{a value for the gamma parameter which is possibly used to - apply a gamma correction to the distances (by default \code{gamma = - FALSE} so no correction is applied).} + \item{gamma}{a value for the gamma parameter possibly used to apply a + correction to the distances (by default no correction is applied).} \item{pairwise.deletion}{a logical indicating whether to delete the sites with missing data in a pairwise way. The default is to delete the sites with at least one missing data for all sequences (ignored if \code{model = "indel"} or \code{"indelblock"}).} \item{base.freq}{the base frequencies to be used in the computations - (if applicable, i.e. if \code{method = "F84"}). By default, the - base frequencies are computed from the whole sample of sequences.} + (if applicable). By default, the base frequencies are computed from + the whole set of sequences.} \item{as.matrix}{a logical indicating whether to return the results as a matrix. The default is to return an object of class \link[stats]{dist}.} @@ -123,12 +122,12 @@ dist.dna(x, model = "K80", variance = FALSE, \item{\code{paralin}: }{Lake (1994) developed the paralinear distance which can be viewed as another variant of the Barry--Hartigan distance.} - \item{\code{indel}: }{this counts the number of sites where there an + \item{\code{indel}: }{this counts the number of sites where there is an insertion/deletion gap in one sequence and not in the other.} \item{\code{indelblock}: }{same than before but contiguous gaps are - counted as a single unit. Note that the distance between `-A-' and - `A--' is 3 because there are three different blocks of gaps, whereas + counted as a single unit. Note that the distance between \code{-A-} and + \code{A--} is 3 because there are three different blocks of gaps, whereas the ``indel'' distance will be 2.} }} \value{ diff --git a/man/mantel.test.Rd b/man/mantel.test.Rd index 949678e..07dfc39 100644 --- a/man/mantel.test.Rd +++ b/man/mantel.test.Rd @@ -55,8 +55,7 @@ mantel.test(m1, m2, nperm = 999, graph = FALSE, London: Chapman & Hall. } \author{ - Original code in S by Ben Bolker \email{bolker@zoo.ufl.edu}, ported - to \R by Julien Claude \email{claude@isem.univ-montp2.fr} + Original code in S by Ben Bolker, ported to \R by Julien Claude } \examples{ q1 <- matrix(runif(36), nrow = 6) diff --git a/man/node.depth.Rd b/man/node.depth.Rd index e4c7bf9..0741c7a 100644 --- a/man/node.depth.Rd +++ b/man/node.depth.Rd @@ -1,6 +1,6 @@ \name{node.depth} \alias{node.depth} -\alias{node.depth.length} +\alias{node.depth.edgelength} \alias{node.height} \alias{node.height.clado} \title{Depth and Heights of Nodes and Tips} @@ -9,7 +9,7 @@ } \usage{ node.depth(phy) -node.depth.length(phy) +node.depth.edgelength(phy) node.height(phy) node.height.clado(phy) } @@ -20,7 +20,7 @@ node.height.clado(phy) \code{node.depth} computes the depth of a node as the number of tips which are its descendants. The value of 1 is given to the tips. - \code{node.depth.length} does the same but using branch lengths. + \code{node.depth.edgelength} does the same but using branch lengths. \code{node.height} computes the heights of nodes and tips as plotted by a phylogram. diff --git a/man/nodelabels.Rd b/man/nodelabels.Rd index c499694..5c44f3f 100644 --- a/man/nodelabels.Rd +++ b/man/nodelabels.Rd @@ -88,8 +88,7 @@ edgelabels(text, edge, adj = c(0.5, 0.5), frame = "rect", \code{show.tip.label}) of \code{plot.phylo} in most cases (see the examples). } -\author{Emmanuel Paradis, Ben Bolker \email{bolker@zoo.ufl.edu}, and Jim - Lemon} +\author{Emmanuel Paradis, Ben Bolker, and Jim Lemon} \seealso{ \code{\link{plot.phylo}}, \code{\link{edges}}, \code{\link{mixedFontLabel}} diff --git a/man/plot.phylo.Rd b/man/plot.phylo.Rd index f19db41..ee89287 100644 --- a/man/plot.phylo.Rd +++ b/man/plot.phylo.Rd @@ -94,12 +94,12 @@ \item{plot}{a logical controlling whether to draw the tree. If \code{FALSE}, the graphical device is set as if the tree was plotted, and the coordinates are saved as well.} - \item{layout}{the number of trees to be plotted simultaneously.} - \item{\dots}{further arguments to be passed to \code{plot} or to - \code{plot.phylo}.} \item{rotate.tree}{for "fan", "unrooted", or "radial" trees: the rotation of the whole tree in degrees (negative values are accepted).} + \item{layout}{the number of trees to be plotted simultaneously.} + \item{\dots}{further arguments to be passed to \code{plot} or to + \code{plot.phylo}.} } \description{ These functions plot phylogenetic trees on the current graphical diff --git a/man/print.phylo.Rd b/man/print.phylo.Rd index 91917f8..f1ad306 100644 --- a/man/print.phylo.Rd +++ b/man/print.phylo.Rd @@ -23,7 +23,7 @@ \value{ NULL. } -\author{Ben Bolker \email{bolker@zoo.ufl.edu} and Emmanuel Paradis} +\author{Ben Bolker and Emmanuel Paradis} \seealso{ \code{\link{read.tree}}, \code{\link{summary.phylo}}, \code{\link[base]{print}} for the generic \R function diff --git a/man/read.caic.Rd b/man/read.caic.Rd index 016d8a6..39bc2a1 100644 --- a/man/read.caic.Rd +++ b/man/read.caic.Rd @@ -19,12 +19,7 @@ read.caic(file, brlen = NULL, skip = 0, comment.char = "#", ...) Read a tree from a file in the format used by the CAIC and MacroCAIc program. } \value{ -an object of class "phylo" with the following components: -\item{edge}{a two-column matrix of mode character where each row represents an edge of the tree; the nodes and the tips are symbolized with numbers (these numbers are not treated as numeric, hence the mode character); the nodes are represented with negative numbers (the root being "-1"), and the tips are represented with positive numbers. For each row, the first column gives the ancestor. This representation allows an easy manipulation of the tree, particularly if it is rooted.} -\item{edge.length}{a numeric vector giving the lengths of the branches given by edge.} -\item{tip.label}{a vector of mode character giving the names of the tips; the order of the names in this vector corresponds to the (positive) number in edge.} -\item{node.label}{(optional) a vector of mode character giving the names of the nodes (set to NULL if not available in the file).} -\item{root.edge}{(optional) a numeric value giving the length of the branch at the root is it exists (NULL otherwise).} + an object of class \code{"phylo"}. } \references{ Purvis, A. and Rambaut, A. (1995) Comparative analysis by independent diff --git a/man/read.nexus.Rd b/man/read.nexus.Rd index 8a668d1..5594e0e 100644 --- a/man/read.nexus.Rd +++ b/man/read.nexus.Rd @@ -8,7 +8,8 @@ read.nexus(file, tree.names = NULL) \item{file}{a file name specified by either a variable of mode character, or a double-quoted string.} \item{tree.names}{if there are several trees to be read, a vector of - mode character that gives names to the individual trees.} + mode character giving names to the individual trees (by default, + this uses the labels in the NEXUS file if these are present).} } \description{ This function reads one or several trees in a NEXUS file. @@ -18,8 +19,7 @@ read.nexus(file, tree.names = NULL) NEXUS standard (but see the restriction below on TRANSLATION tables). Only the block ``TREES'' is read; the other data can be read with other functions (e.g., \code{\link{read.dna}}, - \code{\link[utils]{read.table}}, ...). A trace of the original data is - kept with the attribute \code{"origin"} (see below). + \code{\link[utils]{read.table}}, \dots). If a TRANSLATION table is present it is assumed that only the tip labels are translated and they are all translated with integers @@ -39,27 +39,7 @@ read.nexus(file, tree.names = NULL) message is issued. } \value{ - an object of class \code{"phylo"} with the following components: - \item{edge}{a two-column matrix of mode character where each row - represents an edge of the tree; the nodes and the tips are - symbolized with numbers (these numbers are not treated as numeric, - hence the mode character); the nodes are represented with negative - numbers (the root being \code{"-1"}), and the tips are represented with - positive numbers. For each row, the first column gives the - ancestor. This representation allows an easy manipulation of the - tree, particularly if it is rooted.} - \item{edge.length}{a numeric vector giving the lengths of the - branches given by \code{edge}.} - \item{tip.label}{a vector of mode character giving the names of the - tips; the order of the names in this vector corresponds to the - (positive) number in \code{edge}.} - \item{node.label}{(optional) a vector of mode character giving the - names of the nodes (set to \code{NULL} if not available in the file).} - \item{root.edge}{(optional) a numeric value giving the length of the - branch at the root is it exists (\code{NULL} otherwise).} - - If several trees are read in the file, the returned object is of class - \code{"multiPhylo"}, and is a list of objects of class \code{"phylo"}. + an object of class \code{"phylo"} or of class \code{"multiPhylo"}. } \references{ Maddison, D. R., Swofford, D. L. and Maddison, W. P. (1997) NEXUS: an diff --git a/man/woodmouse.Rd b/man/woodmouse.Rd index be62ae0..d90ce66 100644 --- a/man/woodmouse.Rd +++ b/man/woodmouse.Rd @@ -17,9 +17,9 @@ data(woodmouse) } \source{ Michaux, J. R., Magnanou, E., Paradis, E., Nieberding, C. and Libois, - R. (2003) Mitochondrial phylogeography of the Woodmouse (Apodemus - sylvaticus) in the Western Palearctic region. \emph{Molecular - Ecology}, \bold{12}, 685--697. + R. (2003) Mitochondrial phylogeography of the Woodmouse + (\emph{Apodemus sylvaticus}) in the Western Palearctic region. + \emph{Molecular Ecology}, \bold{12}, 685--697. } \seealso{ \code{\link{read.dna}}, \code{\link{DNAbin}}, \code{\link{dist.dna}} diff --git a/man/yule.Rd b/man/yule.Rd index 40998f9..c9a07de 100644 --- a/man/yule.Rd +++ b/man/yule.Rd @@ -10,7 +10,7 @@ yule(phy, use.root.edge = FALSE) edge in the calculations.} } \description{ - This function fits by maximum likelihood a Yule model, i.e. a + This function fits by maximum likelihood a Yule model, i.e., a birth-only model to the branching times computed from a phylogenetic tree. }