From: paradis Date: Wed, 7 Apr 2010 14:39:56 +0000 (+0000) Subject: removing evolve.phylo + bug fix in as.phylo.hclust X-Git-Url: https://git.donarmstrong.com/?p=ape.git;a=commitdiff_plain;h=9f4eb32b3354f76ec0f13f9ca58ad63b082fecca removing evolve.phylo + bug fix in as.phylo.hclust git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@117 6e262413-ae40-0410-9e79-b911bd7a66b7 --- diff --git a/ChangeLog b/ChangeLog index 1088c13..5b534a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,18 @@ - CHANGES IN APE VERSION 2.5-1 + CHANGES IN APE VERSION 2.5-2 + + +BUG FIXES + + o as.phylo.hclust() used to multiply edge lengths by 2. + + +DEPRECATED & DEFUNCT + + o evolve.phylo() and plot.ancestral() have been removed. + + + + CHANGES IN APE VERSION 2.5-1 NEW FEATURES diff --git a/DESCRIPTION b/DESCRIPTION index f452091..f582fd4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape -Version: 2.5-1 -Date: 2010-03-29 +Version: 2.5-2 +Date: 2010-04-07 Title: Analyses of Phylogenetics and Evolution Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, Gangolf Jobb, Christoph Heibl, Daniel Lawson, Vincent Lefort, Pierre Legendre, Jim Lemon, Yvonnick Noel, Johan Nylander, Rainer Opgen-Rhein, Korbinian Strimmer, Damien de Vienne Maintainer: Emmanuel Paradis diff --git a/R/ape-defunct.R b/R/ape-defunct.R index 96df8f2..8c53060 100644 --- a/R/ape-defunct.R +++ b/R/ape-defunct.R @@ -2,18 +2,22 @@ klastorin <- function(phy) .Defunct(msg = '\'klastorin\' has been removed from ape, see help("ape-defunct") for details.') -mlphylo <- - function(x, phy, model = DNAmodel(), search.tree = FALSE, - quiet = FALSE, value = NULL, fixed = FALSE) +mlphylo <- function(...) .Defunct(msg = '\'mlphylo\' has been removed from ape, see help("ape-defunct") for details.') -DNAmodel <- function(model = "K80", partition = 1, - ncat.isv = 1, invar = FALSE, - equal.isv = TRUE, equal.invar = 1) +DNAmodel <- function(...) .Defunct(msg = '\'DNAmodel\' has been removed from ape, see help("ape-defunct") for details.') -sh.test <- function(..., x, model = DNAmodel(), B = 100) +sh.test <- function(...) .Defunct(msg = '\'sh.test\' has been removed from ape, see help("ape-defunct") for details.') + +evolve.phylo <- function(phy, value, var) + .Defunct(msg = '\'evolve.phylo\' has been removed from ape, + see help("ape-defunct") for details.') + +plot.ancestral <- function(...) + .Defunct(msg = '\'plot.ancestral\' has been removed from ape, + see help("ape-defunct") for details.') diff --git a/R/as.phylo.R b/R/as.phylo.R index e0ee65f..79491d2 100644 --- a/R/as.phylo.R +++ b/R/as.phylo.R @@ -1,8 +1,8 @@ -## as.phylo.R (2007-03-05) +## as.phylo.R (2010-04-06) ## Conversion Among Tree Objects -## Copyright 2005-2007 Emmanuel Paradis +## Copyright 2005-2010 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -47,20 +47,21 @@ as.phylo.hclust <- function(x, ...) edge[j:(j + 1), 1] <- node[i] for (l in 1:2) { k <- j + l - 1L - if (x$merge[i, l] > 0) { - edge[k, 2] <- node[x$merge[i, l]] <- cur.nod + y <- x$merge[i, l] + if (y > 0) { + edge[k, 2] <- node[y] <- cur.nod cur.nod <- cur.nod + 1L - edge.length[k] <- x$height[i] - x$height[x$merge[i, l]] + edge.length[k] <- x$height[i] - x$height[y] } else { - edge[k, 2] <- -x$merge[i, l] + edge[k, 2] <- -y edge.length[k] <- x$height[i] } } j <- j + 2L } if (is.null(x$labels)) - x$labels <- as.character(1:(N + 1)) - obj <- list(edge = edge, edge.length = edge.length, + x$labels <- as.character(1:(N + 1)) + obj <- list(edge = edge, edge.length = edge.length / 2, tip.label = x$labels, Nnode = N) class(obj) <- "phylo" reorder(obj) diff --git a/R/evolve.phylo.R b/R/evolve.phylo.R deleted file mode 100644 index e3fcee8..0000000 --- a/R/evolve.phylo.R +++ /dev/null @@ -1,66 +0,0 @@ -## evolve.tree.R (2005-12-04) - -## Character Simulation under a Brownian Model - -## Copyright 2005 Julien Dutheil - -## This file is part of the R-package `ape'. -## See the file ../COPYING for licensing issues. - -evolve.phylo <- function(phy, value, var) { - if (!("phylo" %in% class(phy))) - stop("object \"phy\" is not of class \"phylo\"") - if (is.null(phy$edge.length)) - stop("tree \" phy\" must have branch lengths.") - nchar <- max(length(value), length(var)) - value <- rep(value, length=nchar) - var <- rep(var, length=nchar) - char.names <- names(value); - - ## added by EP for the new coding of "phylo" (2006-10-04): - phy <- new2old.phylo(phy) - ## End - edges <- phy$edge - nodes <- unique(as.vector(edges)) - n <- length(nodes) # Number of nodes - root <- match("-1", nodes) - states<-list(); - states[["-1"]] <- value - for(node in nodes[-root]) { - edge.index <- match(node, edges[,2]) - edge.length <- phy$edge.length[edge.index] - ancestor <- edges[edge.index, 1] - ancestor.node.index <- match(ancestor, nodes) - ancestor.states <- states[[ancestor.node.index]] - index <- match(node, nodes) - x <- numeric(nchar) - for(i in 1:nchar) { - x[i] <- rnorm(1, mean=ancestor.states[i], sd=sqrt(var[i]*edge.length)) - } - states[[index]] <- x; - } - nodes.states <- as.data.frame(matrix(ncol=nchar, nrow=0)) - if(!is.null(char.names)) names(nodes.states) <- char.names - count <- 1 - for(i in unique(edges[,1])) { - nodes.states[i,] <- states[[match(i, nodes)]] - count <- count + 1 - } - - nl <- length(phy$tip.label) #Number of leaves - leaves.states <- as.data.frame(matrix(ncol=nchar, nrow=0)) - if(!is.null(char.names)) names(leaves.states) <- char.names - count <- 1 - for(i in 1:nl) { - leaves.states[as.character(count),] <- states[[match(as.character(i), nodes)]] - count <- count + 1 - } - - phy[["node.character"]] <- nodes.states; - phy[["tip.character"]] <- leaves.states; - if(! "ancestral" %in% class(phy)) class(phy) <- c("ancestral", class(phy)); - ## added by EP for the new coding of "phylo" (2006-10-04): - phy <- old2new.phylo(phy) - ## End - return(phy) -} diff --git a/R/plot.ancestral.R b/R/plot.ancestral.R deleted file mode 100644 index a53fb1b..0000000 --- a/R/plot.ancestral.R +++ /dev/null @@ -1,34 +0,0 @@ -## plot.ancestral.R (2005-12-04) - -## Plotting Ancestral Characters on a Tree - -## Copyright 2005 Julien Dutheil - -## This file is part of the R-package `ape'. -## See the file ../COPYING for licensing issues. - -plot.ancestral <- function(x, which=names(x$node.character), - n.col=10, col.fun=function(n) rainbow(n, start=0.4, end=0), - plot.node.values=FALSE, - ask = prod(par("mfcol")) < length(which) && dev.interactive(), - ...) -{ - if (!("ancestral" %in% class(x))) - stop("object \"phy\" is not of class \"ancestral\"") - states <- rbind(x$node.character, x$tip.character) - cols <- col.fun(n.col) - if(ask) { - op <- par(ask = TRUE) - on.exit(par(op)) - } - for(state in which) { - a <- states[x$edge[,2],state] - b <- round((n.col-1)*(a-min(a))/(max(a)-min(a)))+1 - if(plot.node.values) { - x$node.label <- x$node.character[,state] - plot.phylo(x, edge.color=cols[b], show.node.label=TRUE, sub=state, ...) - } else { - plot.phylo(x, edge.color=cols[b], sub=state, ...) - } - } -} diff --git a/man/ape-defunct.Rd b/man/ape-defunct.Rd index cb31e02..346c24a 100644 --- a/man/ape-defunct.Rd +++ b/man/ape-defunct.Rd @@ -1,4 +1,5 @@ \name{ape-defunct} +\alias{ape-defunct} \alias{klastorin} \alias{mlphylo} \alias{DNAmodel} @@ -9,6 +10,8 @@ \alias{theta.h} \alias{theta.k} \alias{theta.s} +\alias{evolve.phylo} +\alias{plot.ancestral} \title{Defunct Ape Functions} \description{ These functions have been removed from \pkg{ape} or moved to another @@ -16,18 +19,17 @@ } \usage{ klastorin(phy) -mlphylo(x, phy, model = DNAmodel(), search.tree = FALSE, - quiet = FALSE, value = NULL, fixed = FALSE) -DNAmodel(model = "K80", partition = 1, - ncat.isv = 1, invar = FALSE, - equal.isv = TRUE, equal.invar = 1) -sh.test(..., x, model = DNAmodel(), B = 100) +mlphylo(...) +DNAmodel(...) +sh.test(...) heterozygosity(x, variance = FALSE) H(x, variance = FALSE) nuc.div(x, variance = FALSE, pairwise.deletion = FALSE) theta.h(x, standard.error = FALSE) theta.k(x, n = NULL, k = NULL) theta.s(s, n, variance = FALSE) +evolve.phylo(phy, value, var) +plot.ancestral(...) } \details{ \code{klastorin} has been removed because it does not seem to be used @@ -40,5 +42,8 @@ theta.s(s, n, variance = FALSE) \code{heterozygosity}, \code{nuc.div}, \code{theta.h}, \code{theta.k} and \code{theta.s} have been moved to \pkg{pegas}. + + \code{evolve.phylo} and \code{plot.ancestral} have been deprecated by + the new function \link{\code{rTraitCont}}. } \keyword{internal} diff --git a/man/evolve.phylo.Rd b/man/evolve.phylo.Rd deleted file mode 100644 index b277039..0000000 --- a/man/evolve.phylo.Rd +++ /dev/null @@ -1,48 +0,0 @@ -\name{evolve.phylo} -\alias{evolve.phylo} -\title{Ancestral Character Simulation} -\description{ - Simulate the (independent) evolution of one or several continuous - characters along a given phylogenetic tree under a homogeneous - Brownian model. -} -\usage{ -evolve.phylo(phy, value, var) -} -\arguments{ - \item{phy}{an object of class 'phylo' with branch lengths.} - \item{value}{ancestral states, one by character. The (optional) names - of this vector will be used as character names.} - \item{var}{the variance of each character.} -} -\details{ - Let x be a continuous character. - If it evolves according to a Brownian model, its value at time t follows a normal law with mean x0 and variance t*sigma\_x, - where x0 is the value of the character at time 0, and sigma\_x is the 'inner' variance of the character. - The evolution of a continuous character is performed by letting the character evolve on each branch, from its ancestral root state. - The final state of a branch is the ancestral states of the daughter branches, and so on. -} -\value{ - An object of class 'ancestral', inheriting from the 'phylo' class. The - following components are added: - - \item{node.character}{a data.frame with node ids as rownames and one - column by character, containing all the inner node values for each - character.} - \item{tip.character}{a data.frame with tip ids as rownames and one - column by character, containing all the tip values for each - character.} -} -\author{Julien Dutheil \email{julien.dutheil@univ-montp2.fr}} -\seealso{ - \code{\link{plot.ancestral}}, \code{\link{ace}} -} -\examples{ -data(bird.orders) -x <- rep(0, 5) -names(x) <- c("A", "B", "C", "D", "E") -anc1 <- evolve.phylo(bird.orders, x, 1) -anc2 <- evolve.phylo(bird.orders, x, 1) -cor(anc1$tip.character, anc2$tip.character) -} -\keyword{models} diff --git a/man/plot.ancestral.Rd b/man/plot.ancestral.Rd deleted file mode 100644 index 4279432..0000000 --- a/man/plot.ancestral.Rd +++ /dev/null @@ -1,43 +0,0 @@ -\name{plot.ancestral} -\alias{plot.ancestral} -\title{Plot Ancestral Character Values on a Tree} -\description{ - Plot a phylogenetic tree with edge colors picked according to the - corresponding node ancestral character value. -} -\usage{ -\method{plot}{ancestral}(x, which = names(x$node.character), n.col = 10, -col.fun = function(n) rainbow(n, start = 0.4, end = 0), -plot.node.values = FALSE, -ask = prod(par("mfcol")) < length(which) && dev.interactive(), -...) -} -\arguments{ - \item{x}{An object of class 'ancestral'.} - \item{which}{Which characters to plot. Can be a vecotr of names, or a - vector of indices.} - \item{n.col}{The number of colors to use in the gradient.} - \item{col.fun}{the color function to use.} - \item{plot.node.values}{Should character values used as node labels?} - \item{ask}{Ask before each plot?} - \item{\dots}{Further parameters to pass to the plot.phylo function.} -} -\details{ - This function produces one plot by selected ancestral character. It - uses the plot.phylo function with particular arguments to display edge - colors according to ancestral character values. -} -\author{Julien Dutheil \email{Julien.Dutheil@univ-montp2.fr}} -\seealso{ - \code{\link{plot.phylo}}, \code{\link{evolve.phylo}} -} -\examples{ -data(bird.orders) -x <- rep(0, 4) -names(x) <- c("A", "B", "C", "D") -anc <- evolve.phylo(bird.orders, x, 1) -plot(anc, edge.width = 3, plot.node.values = TRUE) -par(mfrow = c(2, 2), mar = c(5.5, 0, 0, 0)) -plot(anc, edge.width = 3, type = "r") -} -\keyword{hplot}