From 821974300c3d4c88584832e3f4b2c99ed56601cb Mon Sep 17 00:00:00 2001 From: paradis Date: Fri, 24 Dec 2010 17:32:05 +0000 Subject: [PATCH] some bug fixes and '...' in rTrait*() git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@143 6e262413-ae40-0410-9e79-b911bd7a66b7 --- ChangeLog | 9 +++++++++ DESCRIPTION | 2 +- R/as.phylo.R | 3 ++- R/rTrait.R | 10 +++++----- Thanks | 4 ++-- man/rTraitCont.Rd | 4 +++- man/rTraitDisc.Rd | 2 ++ 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53f4a62..dd37289 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,19 @@ CHANGES IN APE VERSION 2.6-3 +NEW FEATURES + + o rTraitCont() and rTraitDisc() gains a '...' argument used with + user-defined models (suggestion by Gene Hunt). + + BUG FIXES o as.hclust.phylo() now returns an error with unrooted trees. + o as.hclust.phylo() failed with trees with node labels (thanks to + Jinlong Zhang for pointing this bug out). + CHANGES IN APE VERSION 2.6-2 diff --git a/DESCRIPTION b/DESCRIPTION index a9d4511..f5a28e0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape Version: 2.6-3 -Date: 2010-12-14 +Date: 2010-12-24 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 diff --git a/R/as.phylo.R b/R/as.phylo.R index f5a2569..e8d0f66 100644 --- a/R/as.phylo.R +++ b/R/as.phylo.R @@ -1,4 +1,4 @@ -## as.phylo.R (2010-12-14) +## as.phylo.R (2010-12-15) ## Conversion Among Tree Objects @@ -90,6 +90,7 @@ as.hclust.phylo <- function(x, ...) if (!is.binary.tree(x)) stop("the tree is not binary") if (!is.rooted(x)) stop("the tree is not rooted") n <- length(x$tip.label) + x$node.label <- NULL # by Jinlong Zhang (2010-12-15) bt <- sort(branching.times(x)) inode <- as.numeric(names(bt)) N <- n - 1L diff --git a/R/rTrait.R b/R/rTrait.R index 2c04dc6..b87dd6f 100644 --- a/R/rTrait.R +++ b/R/rTrait.R @@ -1,4 +1,4 @@ -## rTrait.R (2010-07-26) +## rTrait.R (2010-12-24) ## Trait Evolution @@ -10,7 +10,7 @@ rTraitDisc <- function(phy, model = "ER", k = if (is.matrix(model)) ncol(model) else 2, rate = 0.1, states = LETTERS[1:k], freq = rep(1/k, k), - ancestor = FALSE, root.value = 1) + ancestor = FALSE, root.value = 1, ...) { if (is.null(phy$edge.length)) stop("tree has no branch length") @@ -56,7 +56,7 @@ rTraitDisc <- if (is.function(model)) { environment(model) <- environment() # to find 'k' - for (i in N:1) x[des[i]] <- model(x[anc[i]], el[i]) + for (i in N:1) x[des[i]] <- model(x[anc[i]], el[i], ...) } else { freq <- rep(freq, each = k) Q <- Q * freq @@ -82,7 +82,7 @@ rTraitDisc <- rTraitCont <- function(phy, model = "BM", sigma = 0.1, alpha = 1, theta = 0, - ancestor = FALSE, root.value = 0, linear = TRUE) + ancestor = FALSE, root.value = 0, linear = TRUE, ...) { if (is.null(phy$edge.length)) stop("tree has no branch length") @@ -102,7 +102,7 @@ rTraitCont <- if (is.function(model)) { environment(model) <- environment() - for (i in N:1) x[des[i]] <- model(x[anc[i]], el[i]) + for (i in N:1) x[des[i]] <- model(x[anc[i]], el[i], ...) } else { model <- pmatch(toupper(model), c("BM", "OU")) if (length(sigma) == 1) sigma <- rep(sigma, N) diff --git a/Thanks b/Thanks index 402c81a..b979f72 100644 --- a/Thanks +++ b/Thanks @@ -8,8 +8,8 @@ Significant bug fixes were provided by C James Bullard, Otto Cordero, Éric Durand, Olivier François, Rich FitzJohn, , Jos Käfer, Bret Larget, Naim Matasci, Nick Matzke, Michael Phelan, Elizabeth Purdom, Dan Rabosky, Filipe Vieira, Tim Wallstrom, -Li-San Wang, Yan Wong, Peter Wragg, and Janet Young. Contact me if I -forgot someone. +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. diff --git a/man/rTraitCont.Rd b/man/rTraitCont.Rd index 6ff3478..908bf00 100644 --- a/man/rTraitCont.Rd +++ b/man/rTraitCont.Rd @@ -3,7 +3,7 @@ \title{Continuous Character Simulation} \usage{ rTraitCont(phy, model = "BM", sigma = 0.1, alpha = 1, theta = 0, - ancestor = FALSE, root.value = 0, linear = TRUE) + ancestor = FALSE, root.value = 0, linear = TRUE, ...) } \arguments{ \item{phy}{an object of class \code{"phylo"}.} @@ -22,6 +22,8 @@ rTraitCont(phy, model = "BM", sigma = 0.1, alpha = 1, theta = 0, \item{root.value}{a numeric giving the value at the root.} \item{linear}{a logical indicating which parameterisation of the OU model to use (see details).} + \item{\dots}{further arguments passed to \code{model} if it is a + function.} } \description{ This function simulates the evolution of a continuous character along a diff --git a/man/rTraitDisc.Rd b/man/rTraitDisc.Rd index ed1919d..e65a54b 100644 --- a/man/rTraitDisc.Rd +++ b/man/rTraitDisc.Rd @@ -24,6 +24,8 @@ rTraitDisc(phy, model = "ER", k = if (is.matrix(model)) ncol(model) else 2, \item{root.value}{an integer giving the value at the root (by default, it's the first state). To have a random value, use \code{root.value = sample(k)}.} + \item{\dots}{further arguments passed to \code{model} if it is a + function.} } \description{ This function simulates the evolution of a discrete character along a -- 2.39.2