]> git.donarmstrong.com Git - ape.git/commitdiff
removing NPRS + change bind.tree.Rd to avoid crash during R CMD check ape
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Mon, 17 May 2010 07:02:07 +0000 (07:02 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Mon, 17 May 2010 07:02:07 +0000 (07:02 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@120 6e262413-ae40-0410-9e79-b911bd7a66b7

17 files changed:
ChangeLog
DESCRIPTION
R/ace.R
R/ape-defunct.R
R/nprs.R [deleted file]
man/NPRS.criterion.Rd [deleted file]
man/ace.Rd
man/ape-defunct.Rd
man/ape-internal.Rd
man/ape-package.Rd
man/bind.tree.Rd
man/chronoMPL.Rd
man/chronogram.Rd [deleted file]
man/chronopl.Rd
man/landplants.Rd
man/ratogram.Rd [deleted file]
src/nprsfunc.c [deleted file]

index 0e8021260d28bed95db39a36b15ab75bd782feb2..aa93c53dcbea22fccc55b7a439a96f91c28381f2 100644 (file)
--- 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
 
index aa5fd013f129c10eca02e679e26bd7fbc883ae6a..7f0b4455b3ac9bdcb955ca21b276eef0160723e4 100644 (file)
@@ -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 <Emmanuel.Paradis@ird.fr>
 Depends: R (>= 2.6.0)
 Suggests: gee
diff --git a/R/ace.R b/R/ace.R
index 9ea659001688562e42f6e6f557b22720ad0830b2..87ed1f2e60503d1e8de35d00ff94aafcd82582b6 100644 (file)
--- 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, ])
+    }
 }
index 8c5306010ec2c257cf202975c64c9f087270e469..c89dc06738df17dd295a6f644659d7918d5d5837 100644 (file)
@@ -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 (file)
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 (file)
index d98424a..0000000
+++ /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}
index 1e711fdaece40483ea439729a76dc2022026ea73..f440027d34297bcf7857f78ab7b879883a06bf23 100644 (file)
@@ -1,5 +1,6 @@
 \name{ace}
 \alias{ace}
+\alias{print.ace}
 \alias{logLik.ace}
 \alias{deviance.ace}
 \alias{AIC.ace}
 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
index 346c24a1d1e76efadeb025e16ac240da57b7dec8..95dc2ec684cfbd02230537e878e4d89c4756a449 100644 (file)
@@ -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}
index 3f48719f813fd9b863b4b482177e517a8ca0f1da..7aaad77b8a88f34d42c05b38c9666c6e4b72f501 100644 (file)
@@ -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}
index d64b39bc078e5cd294e0c05304f7978e5f6b9862..30fa3cd659c3057284b1485f2fc7012fe99005cd 100644 (file)
@@ -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 <Emmanuel.Paradis@ird.fr>
 }
index 58464e051114cab41c5b6662523f72e8fbcb641d..f7de459f80f2752d5f8c51f5d479dc6643b6b463 100644 (file)
@@ -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()
index 4c2f85040b6a66a17e76169bb794e656e5772296..fb1a6f49db3eb54a1c6c64e74a6f8e74dadfc118 100644 (file)
@@ -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 (file)
index 5d01102..0000000
+++ /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}
index 728195b7ec37143bd0455356bdd06d119aa99c74..6a5366c51524c43a7bd66ae4b788fbc94d58a12a 100644 (file)
@@ -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}
index 06f838d6e26cdd510888bb59c69c13c6f591ab84..837a274c40b71d6c6ba931fc7f3e90cc00bf8cac 100644 (file)
@@ -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 (file)
index 42feb2c..0000000
+++ /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 (file)
index 5d4f5dd..0000000
+++ /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 <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-/*============================================================================*/
-
-#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<tree_nedges;i++) {
-  tree_lowerNodes[i]=lowerNodes[i];
-  tree_upperNodes[i]=upperNodes[i];
-  tree_edgeLengths[i]=(edgeLengths[i]<*minEdgeLength)?*minEdgeLength:edgeLengths[i];
- }
-
- tree_ntips=*ntips;
-
- for(i=0;i<tree_ntips;i++) {
-  strcpy(tree_tipLabels[i],tipLabels[i]);
- }
-
- nparams=0;
- for(i=0;i<tree_nedges;i++) {
-  if(tree_lowerNodes[i]<0&&tree_upperNodes[i]<0) {index[-tree_upperNodes[i]]=nparams++;}
-  if(tree_upperNodes[i]<0) ancestor[-tree_upperNodes[i]]=tree_lowerNodes[i];   
- }
-
- *result=0;
-}
-
-/*============================================================================*/
-
-void getNFreeParams(int *result) { *result=nparams; }
-
-/*============================================================================*/
-
-void getNEdges(int *result) { *result=tree_nedges; }
-
-/*============================================================================*/
-
-void getEdgeLengths(double *result) {
- int i;
-
- for(i=0;i<tree_nedges;i++) result[i]=tree_edgeLengths[i];
-
-}
-
-/*============================================================================*/
-
-double age(double *params,int node) {
- double prod;
-
- if(node>=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<tree_nedges;i++) {
-  low=tree_lowerNodes[i]; upp=tree_upperNodes[i];
-  if(low<0&&upp<0)  result[i]=*scale*(age(params,low)-age(params,upp));
-  else              result[i]=*scale*age(params,low);
- }
-
-}
-
-/*============================================================================*/
-
-void getRates(double *params,double *scale,double *result) {
- int i,low,upp;
-
- for(i=0;i<tree_nedges;i++) {
-  low=tree_lowerNodes[i]; upp=tree_upperNodes[i];
-  if(low<0&&upp<0)  result[i]=tree_edgeLengths[i]/(*scale*(age(params,low)-age(params,upp)));
-  else              result[i]=tree_edgeLengths[i]/(*scale*age(params,low));
- }
-
-}
-
-/*============================================================================*/
-
-
-/* note on the choice of parameters:
- * 
- * in order to obtain a chronogram we optimize the
- * relative heights of each internal node, i.e. to
- * each internal node (minus the root) we assign a number
- * between 0 and 1 (MINPARAM - MAXPARAM).
- *
- * To obtain the actual height of a node the relative heights
- * of the nodes have to multiplied (in fact we work on the log-scale
- * so we simply sum).
- */
-
-
-/* internal objective function - parameters are on log scale */
-void nprsObjectiveFunction(
- double *params,
- int *expo,
- double *result
-) {
- int p,k,j;
- double me,rk,rj,sum,scale=1.0,durations[ARRLEN],rates[ARRLEN];
-
- p=*expo;
-                  
- getDurations(params,&scale,durations);
-
- for(k=0;k<tree_nedges;k++) rates[k]=tree_edgeLengths[k]/durations[k];
-
- me=0.; for(k=0;k<tree_nedges;k++) me+=rates[k]; me/=tree_nedges;
-
- sum=0.;
-
- for(k=0;k<tree_nedges;k++) {                      rk=rates[k];
-  for(j=0;j<tree_nedges;j++) { if(j==k) continue;  rj=rates[j];
-   if(tree_lowerNodes[j]==-1)                  sum+=pow(fabs(me-rj),p);  else
-   if(tree_upperNodes[k]==tree_lowerNodes[j])  sum+=pow(fabs(rk-rj),p);
-  }
- }
-
- *result=sum;
-
-}
-
-
-/* check parameter bounds on log scale */
-int checkLogParams(double *params)
-{
-   int i;
-   for(i=0; i<nparams; i++)
-   {
-     if(params[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<tree_nedges;i++)
-  if(tree_lowerNodes[i]==node)
-   return(tree_edgeLengths[i]+ageAlongEdges(tree_upperNodes[i])); 
-
- return(0.);
-}
-
-/* compute set of parameters for a given clock-like tree */
-void getExternalParams(double *result) {
- int i;
-
- for(i=0;i<tree_nedges;i++) {
-  if(tree_lowerNodes[i]<0&&tree_upperNodes[i]<0)
-   result[index[-tree_upperNodes[i]]]
-    =-log(ageAlongEdges(tree_lowerNodes[i])/ageAlongEdges(tree_upperNodes[i]));
- }
-
-}
-
-/*============================================================================*/