From d3e42fb930a0a07268080eb795ff696b4c8af67b Mon Sep 17 00:00:00 2001 From: paradis Date: Mon, 17 May 2010 07:02:07 +0000 Subject: [PATCH] removing NPRS + change bind.tree.Rd to avoid crash during R CMD check ape git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@120 6e262413-ae40-0410-9e79-b911bd7a66b7 --- ChangeLog | 2 + DESCRIPTION | 4 +- R/ace.R | 30 +++-- R/ape-defunct.R | 12 ++ R/nprs.R | 179 ------------------------------ man/NPRS.criterion.Rd | 63 ----------- man/ace.Rd | 6 +- man/ape-defunct.Rd | 11 +- man/ape-internal.Rd | 13 --- man/ape-package.Rd | 8 +- man/bind.tree.Rd | 4 +- man/chronoMPL.Rd | 3 +- man/chronogram.Rd | 59 ---------- man/chronopl.Rd | 3 +- man/landplants.Rd | 3 - man/ratogram.Rd | 56 ---------- src/nprsfunc.c | 250 ------------------------------------------ 17 files changed, 57 insertions(+), 649 deletions(-) delete mode 100644 R/nprs.R delete mode 100644 man/NPRS.criterion.Rd delete mode 100644 man/chronogram.Rd delete mode 100644 man/ratogram.Rd delete mode 100644 src/nprsfunc.c diff --git a/ChangeLog b/ChangeLog index 0e80212..aa93c53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,8 @@ DEPRECATED & DEFUNCT o evolve.phylo() and plot.ancestral() have been removed. + o chronogram(), ratogram(), and NPRS.criterion() have been removed. + OTHER CHANGES diff --git a/DESCRIPTION b/DESCRIPTION index aa5fd01..7f0b445 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: ape Version: 2.5-2 -Date: 2010-05-06 +Date: 2010-05-14 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 +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, Korbinian Strimmer, Damien de Vienne Maintainer: Emmanuel Paradis Depends: R (>= 2.6.0) Suggests: gee diff --git a/R/ace.R b/R/ace.R index 9ea6590..87ed1f2 100644 --- a/R/ace.R +++ b/R/ace.R @@ -1,4 +1,4 @@ -## ace.R (2010-04-23) +## ace.R (2010-05-12) ## Ancestral Character Estimation @@ -238,16 +238,22 @@ print.ace <- function(x, digits = 4, ...) print(x$call) cat("\n") cat(" Log-likelihood:", x$loglik, "\n\n") - cat("Rate index matrix:\n") ratemat <- x$index.matrix - dimnames(ratemat)[1:2] <- dimnames(x$lik.anc)[2] - print(ratemat, na.print = ".") - cat("\n") - npar <- length(x$rates) - estim <- data.frame(1:npar, round(x$rates, digits), round(x$se, digits)) - cat("Parameter estimates:\n") - names(estim) <- c("rate index", "estimate", "std-err") - print(estim, row.names = FALSE) - cat("\nScaled likelihoods at the root (type 'x$lik.anc' to get them for all nodes):\n") - print(x$lik.anc[1, ]) + if (is.null(ratemat)) { # to be improved + class(x) <- NULL + x$loglik <- x$call <- NULL + print(x) + } else { + dimnames(ratemat)[1:2] <- dimnames(x$lik.anc)[2] + cat("Rate index matrix:\n") + print(ratemat, na.print = ".") + cat("\n") + npar <- length(x$rates) + estim <- data.frame(1:npar, round(x$rates, digits), round(x$se, digits)) + cat("Parameter estimates:\n") + names(estim) <- c("rate index", "estimate", "std-err") + print(estim, row.names = FALSE) + cat("\nScaled likelihoods at the root (type 'x$lik.anc' to get them for all nodes):\n") + print(x$lik.anc[1, ]) + } } diff --git a/R/ape-defunct.R b/R/ape-defunct.R index 8c53060..c89dc06 100644 --- a/R/ape-defunct.R +++ b/R/ape-defunct.R @@ -21,3 +21,15 @@ evolve.phylo <- function(phy, value, var) plot.ancestral <- function(...) .Defunct(msg = '\'plot.ancestral\' has been removed from ape, see help("ape-defunct") for details.') + +chronogram <- function(...) + .Defunct(msg = '\'chronogram\' has been removed from ape, + see help("ape-defunct") for details.') + +ratogram <- function(...) + .Defunct(msg = '\'ratogram\' has been removed from ape, + see help("ape-defunct") for details.') + +NPRS.criterion <- function(...) + .Defunct(msg = '\'NPRS.criterion\' has been removed from ape, + see help("ape-defunct") for details.') diff --git a/R/nprs.R b/R/nprs.R deleted file mode 100644 index dadd994..0000000 --- a/R/nprs.R +++ /dev/null @@ -1,179 +0,0 @@ -## nprs.R (2003-07-11) - -## Nonparametric Rate Smoothing Method by Sanderson - -## Copyright 2003 Gangolf Jobb and Korbinian Strimmer - -## This file is part of the R-package `ape'. -## See the file ../COPYING for licensing issues. - -setTree <- - function(lowerNodes,upperNodes,edgeLengths,minEdgeLength,tipLabels) - .C( - "setTree", - as.integer(lowerNodes), - as.integer(upperNodes), - as.double(edgeLengths), - as.double(minEdgeLength), - as.integer(length(edgeLengths)), - as.character(tipLabels), - as.integer(length(tipLabels)), - result=integer(1), - PACKAGE = "ape" - )$result - -getNFreeParams <- - function() - .C( - "getNFreeParams", - result=integer(1), - PACKAGE = "ape" - )$result - -getNEdges <- - function() - .C( - "getNEdges", - result=integer(1), - PACKAGE = "ape" - )$result - -getEdgeLengths <- - function() - .C( - "getEdgeLengths", - result=double(getNEdges()), - PACKAGE = "ape" - )$result - -objFuncLogScale <- - function(params,expo) - .C( - "objFuncLogScale", - as.double(params), - as.integer(expo), - result=double(1), - PACKAGE = "ape" - )$result - -getDurations <- - function(params,scale) - .C( - "getDurations", - as.double(params), - as.double(scale), - result=double(getNEdges()), - PACKAGE = "ape" - )$result - -getRates <- - function(params,scale) - .C( - "getRates", - as.double(params), - as.double(scale), - result=double(getNEdges()), - PACKAGE = "ape" - )$result - -getExternalParams <- - function() - .C( - "getExternalParams", - result=double(getNFreeParams()), - PACKAGE = "ape" - )$result - -### private functions - -prepareTree <- function(phy, minEdgeLength = 1e-06) -{ - len <- phy$edge.length - if (length(len) > 2048) stop("Only 2048 branches in tree allowed!") - low <- phy$edge[, 1] # edges in the tree - upp <- phy$edge[, 2] - setTree(low, upp, len, minEdgeLength, phy$tip.labels) -} - -optimTree <- function(phy, expo = 2) # call prepareTree first -{ - dur <- rep(log(0.5), getNFreeParams() ) # start value - objL <- function(d) objFuncLogScale(d, expo) - opt <- optim(dur, objL, method = "BFGS") - return(opt) -} - -### this is just for testing purposes, to get the tree we are -### actually using when there are many small branch lengths -phylogram <- function(phy, ...) -{ - if (class(phy) != "phylo") stop("object \"phy\" is not of class \"phylo\"") - - ## added by EP for the new coding of "phylo" (2006-10-04): - phy <- new2old.phylo(phy) - ## End - - prepareTree(phy, ...) - ##opt <- optimTree(phy, ...) - - newTree <- phy - newTree$edge.length <- getEdgeLengths() - - ans <- newTree - old2new.phylo(ans) -} - -### public functions - -chronogram <- function(phy, scale = 1, expo = 2, minEdgeLength = 1e-06) -{ - if (class(phy) != "phylo") stop("object \"phy\" is not of class \"phylo\"") - - ## added by EP for the new coding of "phylo" (2006-10-04): - phy <- new2old.phylo(phy) - ## End - - prepareTree(phy, minEdgeLength = minEdgeLength) - opt <- optimTree(phy, expo = expo) - - newTree <- phy - newTree$edge.length <- getDurations(opt$par, scale) - - ans <- newTree - old2new.phylo(ans) -} - -ratogram <- function(phy, scale = 1, expo = 2, minEdgeLength = 1e-06) -{ - if (class(phy) != "phylo") - stop("object \"phy\" is not of class \"phylo\"") - - ## added by EP for the new coding of "phylo" (2006-10-04): - phy <- new2old.phylo(phy) - ## End - - prepareTree(phy, minEdgeLength = minEdgeLength) - opt <- optimTree(phy, expo = expo) - - newTree <- phy - newTree$edge.length <- getRates(opt$par, scale) - - ans <- newTree - old2new.phylo(ans) -} - -NPRS.criterion <- function(phy, chrono, expo = 2, minEdgeLength = 1e-06) -{ - if (!is.ultrametric(chrono)) - stop("tree \"chrono\" is not ultrametric (clock-like)") - - ## added by EP for the new coding of "phylo" (2006-10-04): - phy <- new2old.phylo(phy) - chrono <- new2old.phylo(chrono) - ## End - - prepareTree(chrono, minEdgeLength = minEdgeLength) - parms <- getExternalParams() - prepareTree(phy, minEdgeLength = minEdgeLength) - objFuncLogScale(parms, expo) -} diff --git a/man/NPRS.criterion.Rd b/man/NPRS.criterion.Rd deleted file mode 100644 index d98424a..0000000 --- a/man/NPRS.criterion.Rd +++ /dev/null @@ -1,63 +0,0 @@ -\name{NPRS.criterion} -\alias{NPRS.criterion} -\title{Objective Function Employed in Nonparametric Rate Smoothing} -\usage{ -NPRS.criterion(phy, chrono, expo = 2, minEdgeLength = 1e-06) -} -\arguments{ - \item{phy}{A non-clock-like phylogenetic tree (i.e. an object of class - \code{"phylo"}), where the branch lengths are measured in - substitutions.} - \item{chrono}{A chronogram, i.e. a clock-like tree (i.e. an object of - class \code{"phylo"}), where the branch lengths are measured in - absolute time.} - \item{expo}{Exponent in the objective function (default value: 2)} - \item{minEdgeLength}{Minimum edge length in the phylogram (default - value: 1e-06). If any branch lengths are smaller then they will be - set to this value.} -} -\description{ - \code{NPRS.criterion} computes the objective function to be minimized - in the NPRS (nonparametric rate smoothing) algorithm described in - Sanderson (1997). -} -\details{ - Please refer to Sanderson (1997) for mathematical details. Note that - is is not computationally efficient to optimize the branch lengths in - a chronogram by using \code{NPRS.criterion} - please use - \code{\link{chronogram}} instead. -} -\value{ - \code{NPRS.criterion} returns the value of the objective function given - a phylogram and a chronogram. -} -\author{Gangolf Jobb (\url{http://www.treefinder.de}) and Korbinian - Strimmer (\url{http://www.stat.uni-muenchen.de/~strimmer/}) -} -\seealso{ - \code{\link{ratogram}}, \code{\link{chronogram}} -} -\references{ - Sanderson, M. J. (1997) A nonparametric approach to estimating - divergence times in the absence of rate constancy. \emph{Molecular - Biology and Evolution}, \bold{14}, 1218--1231. -} -\examples{ -# get tree -data("landplants.newick") # example tree in NH format -tree.landplants <- read.tree(text = landplants.newick) - -# plot tree -tree.landplants -plot(tree.landplants, label.offset = 0.001) - -# estimate chronogram -chrono.plants <- chronogram(tree.landplants) - -# plot -plot(chrono.plants, label.offset = 0.001) - -# value of NPRS function for our estimated chronogram -NPRS.criterion(tree.landplants, chrono.plants) -} -\keyword{manip} diff --git a/man/ace.Rd b/man/ace.Rd index 1e711fd..f440027 100644 --- a/man/ace.Rd +++ b/man/ace.Rd @@ -1,5 +1,6 @@ \name{ace} \alias{ace} +\alias{print.ace} \alias{logLik.ace} \alias{deviance.ace} \alias{AIC.ace} @@ -9,13 +10,15 @@ ace(x, phy, type = "continuous", method = "ML", CI = TRUE, model = if (type == "continuous") "BM" else "ER", scaled = TRUE, kappa = 1, corStruct = NULL, ip = 0.1) +\method{print}{ace}(x, digits = 4, ...) \method{logLik}{ace}(object, ...) \method{deviance}{ace}(object, ...) \method{AIC}{ace}(object, ..., k = 2) \method{anova}{ace}(object, ...) } \arguments{ - \item{x}{a vector or a factor.} + \item{x}{a vector or a factor; an object of class \code{"ace"} in the + case of \code{print}.} \item{phy}{an object of class \code{"phylo"}.} \item{type}{the variable type; either \code{"continuous"} or \code{"discrete"} (or an abbreviation of these).} @@ -37,6 +40,7 @@ ace(x, phy, type = "continuous", method = "ML", CI = TRUE, structure to be used (this also gives the assumed model).} \item{ip}{the initial value(s) used for the ML estimation procedure when \code{type == "discrete"} (possibly recycled).} + \item{digits}{the number of digits to be printed.} \item{object}{an object of class \code{"ace"}.} \item{k}{a numeric value giving the penalty per estimated parameter; the default is \code{k = 2} which is the classical Akaike diff --git a/man/ape-defunct.Rd b/man/ape-defunct.Rd index 346c24a..95dc2ec 100644 --- a/man/ape-defunct.Rd +++ b/man/ape-defunct.Rd @@ -12,6 +12,9 @@ \alias{theta.s} \alias{evolve.phylo} \alias{plot.ancestral} +\alias{chronogram} +\alias{ratogram} +\alias{NPRS.criterion} \title{Defunct Ape Functions} \description{ These functions have been removed from \pkg{ape} or moved to another @@ -30,6 +33,9 @@ theta.k(x, n = NULL, k = NULL) theta.s(s, n, variance = FALSE) evolve.phylo(phy, value, var) plot.ancestral(...) +chronogram(...) +ratogram(...) +NPRS.criterion(...) } \details{ \code{klastorin} has been removed because it does not seem to be used @@ -44,6 +50,9 @@ plot.ancestral(...) 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}}. + the new function \code{\link{rTraitCont}}. + + \code{chronogram}, \code{ratogram}, and \code{NPRS.criterion} have + ceased to be maintained: consider using \code{\link{chronopl}}. } \keyword{internal} diff --git a/man/ape-internal.Rd b/man/ape-internal.Rd index 3f48719..7aaad77 100644 --- a/man/ape-internal.Rd +++ b/man/ape-internal.Rd @@ -8,19 +8,6 @@ \alias{mant.zstat} \alias{lower.triang} \alias{clado.build} -\alias{getDurations} -\alias{getEdgeLengths} -\alias{getExternalParams} -\alias{getNEdges} -\alias{getNFreeParams} -\alias{getRates} -\alias{objFuncLogScale} -\alias{optimTree} -\alias{phylogram} -\alias{prepareTree} -\alias{setTree} -\alias{nEdges} -\alias{nNodes} \alias{phylogram.plot} \alias{cladogram.plot} \alias{circular.plot} diff --git a/man/ape-package.Rd b/man/ape-package.Rd index d64b39b..30fa3cd 100644 --- a/man/ape-package.Rd +++ b/man/ape-package.Rd @@ -20,10 +20,10 @@ 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 + Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, 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/man/bind.tree.Rd b/man/bind.tree.Rd index 58464e0..f7de459 100644 --- a/man/bind.tree.Rd +++ b/man/bind.tree.Rd @@ -89,8 +89,8 @@ title("x") plot(z, show.node.label = TRUE, font = 1, root.edge = TRUE) title("z <- bind.tree(x, y, 2, .1)") -x <- rtree(100) -y <- rtree(100) +x <- rtree(50) +y <- rtree(50) x$root.edge <- y$root.edge <- .2 z <- x + y plot(y, show.tip.label = FALSE, root.edge = TRUE); axisPhylo() diff --git a/man/chronoMPL.Rd b/man/chronoMPL.Rd index 4c2f850..fb1a6f4 100644 --- a/man/chronoMPL.Rd +++ b/man/chronoMPL.Rd @@ -53,8 +53,7 @@ chronoMPL(phy, se = TRUE, test = TRUE) } \author{Emmanuel Paradis} \seealso{ - \code{\link{chronogram}}, \code{\link{ratogram}}, - \code{\link{NPRS.criterion}}, \code{\link{chronopl}} + \code{\link{chronopl}} } \examples{ tr <- rtree(10) diff --git a/man/chronogram.Rd b/man/chronogram.Rd deleted file mode 100644 index 5d01102..0000000 --- a/man/chronogram.Rd +++ /dev/null @@ -1,59 +0,0 @@ -\name{chronogram} -\alias{chronogram} - -\title{Chronogram Computed by Nonparametric Rate Smoothing} -\usage{ -chronogram(phy, scale = 1, expo = 2, minEdgeLength = 1e-06) -} -\arguments{ - \item{phy}{A phylogenetic tree (i.e. an object of class - \code{"phylo"}), where the branch lengths are measured in substitutions.} - \item{scale}{Age of the root in the inferred chronogram (default value: 0). } - \item{expo}{Exponent in the objective function (default value: 2)} - \item{minEdgeLength}{Minimum edge length in the phylogram (default - value: 1e-06). If any branch lengths are smaller then they will be - set to this value.} -} -\description{ - \code{chronogram} computes a chronogram from a phylogram by applying the NPRS - (nonparametric rate smoothing) algorithm described in Sanderson (1997). -} -\details{ - Please refer to Sanderson (1997) for mathematical details -} -\value{ -\code{chronogram} returns an object of class \code{"phylo"}. The branch lengths of this -tree will be clock-like and scaled so that the root node has age 1 (or the value -set by the option \code{scale} -} -\author{ - Gangolf Jobb (\url{http://www.treefinder.de}) and -Korbinian Strimmer (\url{http://www.stat.uni-muenchen.de/~strimmer/}) -} -\seealso{ -\code{\link{ratogram}}, \code{\link{NPRS.criterion}}. -} -\references{ - Sanderson, M. J. (1997) A nonparametric approach to estimating - divergence times in the absence of rate constancy. \emph{Molecular - Biology and Evolution}, \bold{14}, 1218--1231. -} -\examples{ -# get tree -data("landplants.newick") # example tree in NH format -tree.landplants <- read.tree(text = landplants.newick) - -# plot tree -tree.landplants -plot(tree.landplants, label.offset = 0.001) - -# estimate chronogram -chrono.plants <- chronogram(tree.landplants) - -# plot -plot(chrono.plants, label.offset = 0.001) - -# value of NPRS function for our estimated chronogram -NPRS.criterion(tree.landplants, chrono.plants) -} -\keyword{manip} diff --git a/man/chronopl.Rd b/man/chronopl.Rd index 728195b..6a5366c 100644 --- a/man/chronopl.Rd +++ b/man/chronopl.Rd @@ -100,7 +100,6 @@ chronopl(phy, lambda, age.min = 1, age.max = NULL, } \author{Emmanuel Paradis} \seealso{ - \code{\link{chronogram}}, \code{\link{ratogram}}, - \code{\link{NPRS.criterion}}, \code{\link{chronoMPL}} + \code{\link{chronoMPL}} } \keyword{models} diff --git a/man/landplants.Rd b/man/landplants.Rd index 06f838d..837a274 100644 --- a/man/landplants.Rd +++ b/man/landplants.Rd @@ -17,9 +17,6 @@ data(landplants.newick) data example in the software package r8s (\url{http://ginger.ucdavis.edu/r8s/}). } -\seealso{ -\code{\link{chronogram}}, \code{\link{ratogram}}, \code{\link{NPRS.criterion}}. -} \references{ Sanderson, M. J. (1997) A nonparametric approach to estimating divergence times in the absence of rate constancy. \emph{Molecular diff --git a/man/ratogram.Rd b/man/ratogram.Rd deleted file mode 100644 index 42feb2c..0000000 --- a/man/ratogram.Rd +++ /dev/null @@ -1,56 +0,0 @@ -\name{ratogram} -\alias{ratogram} - -\title{Ratogram Computed by Nonparametric Rate Smoothing} -\usage{ -ratogram(phy, scale = 1, expo = 2, minEdgeLength = 1e-06) -} -\arguments{ - \item{phy}{A phylogenetic tree (i.e. an object of class \code{"phylo"}), where - the branch lengths are measured in substitutions.} - - \item{scale}{Age of the root in the chronogram corresponding to the inferred ratogram(default value: 0). } - - \item{expo}{Exponent in the objective function (default value: 2)} - \item{minEdgeLength}{Minimum edge length in the phylogram (default value: 1e-06). If any branch lengths are - smaller then they will be set to this value. } -} -\description{ - - \code{ratogram} computes a ratogram from a phylogram by applying the NPRS - (nonparametric rate smoothing) algorithm described in Sanderson (1997). -} -\details{ - Please refer to Sanderson (1997) for mathematical details -} -\value{ -\code{chronogram} returns an object of class \code{"phylo"}. The branch lengths of this -tree will be the absolute rates estimated for each branch. -} -\author{Gangolf Jobb (\url{http://www.treefinder.de}) and -Korbinian Strimmer (\url{http://www.stat.uni-muenchen.de/~strimmer/}) -} -\seealso{ -\code{\link{chronogram}}, \code{\link{NPRS.criterion}}. -} -\references{ - Sanderson, M. J. (1997) A nonparametric approach to estimating - divergence times in the absence of rate constancy. \emph{Molecular - Biology and Evolution}, \bold{14}, 1218--1231. -} -\examples{ -# get tree -data("landplants.newick") # example tree in NH format -tree.landplants <- read.tree(text = landplants.newick) - -# plot tree -tree.landplants -plot(tree.landplants, label.offset = 0.001) - -# estimate ratogram -rato.plants <- ratogram(tree.landplants) - -# plot -plot(rato.plants, label.offset = 0.001) -} -\keyword{manip} diff --git a/src/nprsfunc.c b/src/nprsfunc.c deleted file mode 100644 index 5d4f5dd..0000000 --- a/src/nprsfunc.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * nprsfunc.c - * - * (c) 2003 Gangolf Jobb and Korbinian Strimmer - * - * Functions for nonparametric rate smoothing (NPRS) - * (see MJ Sanderson. 1997. MBE 14:1218-1231) - * - * This code may be distributed under the GNU GPL - */ - - -#include -#include -#include - -/*============================================================================*/ - -#define EPS 1e-6 -#define LARGENUM 1e99 - -/* original scale */ -#define MINPARAM EPS -#define MAXPARAM 1-EPS -#define STARTPARAM 0.5 - - -/* log scale */ -#define MINLPARAM log(MINPARAM) -#define MAXLPARAM log(MAXPARAM) -#define STARTLPARAM log(STARTPARAM) - -#define ARRLEN 2048 -#define LABLEN 64 - -#define index aperates_index - -int tree_lowerNodes[ARRLEN]; -int tree_upperNodes[ARRLEN]; -double tree_edgeLengths[ARRLEN]; -int tree_nedges; -char tree_tipLabels[ARRLEN][LABLEN]; -int tree_ntips; - -int nparams,index[ARRLEN],ancestor[ARRLEN]; - -/*============================================================================*/ - -void setTree( - int *lowerNodes, - int *upperNodes, - double *edgeLengths, - double *minEdgeLength, - int *nedges, - char **tipLabels, - int *ntips, - int *result -) { - int i; - - tree_nedges=*nedges; - - for(i=0;i=0) return(0.0); - if(node==-1) return(1.0); - - prod=0.0; - while(node!=-1) {prod+=params[index[-node]]; node=ancestor[-node];} - - return(exp(prod)); -} - - -void getDurations(double *params,double *scale,double *result) { - int i,low,upp; - - for(i=0;i MAXLPARAM || params[i] < MINLPARAM) return 0; /* out of bounds */ - } - return 1; /* within bounds */ -} - - - -/* - * public objective function - * - parameters are on log scale - * - if parameters are out of bounds function returns large value - */ -void objFuncLogScale( - double *params, - int *expo, - double *result -) -{ - - if( checkLogParams(params) == 0 ) /* out of bounds */ - { - *result = LARGENUM; - } - else - { - nprsObjectiveFunction(params, expo, result); - } -} - - -/*============================================================================*/ - - -double ageAlongEdges(int node) { /* tree must be clock-like */ - int i; - - if(node>=0) return(0.); - - for(i=0;i