[Ecopd-commits] r83 - in branches/single-tree: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Nov 18 19:24:45 CET 2009
Author: regetz
Date: 2009-11-18 19:24:45 +0100 (Wed, 18 Nov 2009)
New Revision: 83
Modified:
branches/single-tree/R/pd.R
branches/single-tree/man/pd.Rd
Log:
added pd method for phylo4 trees, and updated documentation
Modified: branches/single-tree/R/pd.R
===================================================================
--- branches/single-tree/R/pd.R 2009-11-18 16:10:46 UTC (rev 82)
+++ branches/single-tree/R/pd.R 2009-11-18 18:24:45 UTC (rev 83)
@@ -6,6 +6,19 @@
standardGeneric("pd")
})
+setMethod("pd", signature(x="phylo4"),
+ function(x, method=c("traditional")) {
+ method <- match.arg(method)
+ if (isRooted(x)) {
+ nonroot.nodes <- setdiff(nodeId(x), rootNode(x))
+ tot.length <- sum(edgeLength(x, nonroot.nodes))
+ } else {
+ tot.length <- sum(edgeLength(x))
+ }
+ return(tot.length)
+ }
+)
+
setMethod("pd", signature(x="phylo4d"), function(x,
method=c("traditional", "polytomy", "yule"), ...) {
phyc <- phylo4com(x, ...)
Modified: branches/single-tree/man/pd.Rd
===================================================================
--- branches/single-tree/man/pd.Rd 2009-11-18 16:10:46 UTC (rev 82)
+++ branches/single-tree/man/pd.Rd 2009-11-18 18:24:45 UTC (rev 83)
@@ -4,6 +4,7 @@
\alias{pd-methods}
\alias{pd,phylo4com-method}
\alias{pd,phylo4d-method}
+\alias{pd,phylo4-method}
\title{Calculate phylogenetic diversity}
\description{
Calculates PD (phylogenetic diversity) for a phylogeny
@@ -13,17 +14,23 @@
"yule"))
\S4method{pd}{phylo4d}(x, method = c("traditional", "polytomy",
"yule"), \dots)
+ \S4method{pd}{phylo4}(x, method = c("traditional"))
}
\arguments{
- \item{x}{A \code{phylo4com} or \code{phylo4d} object.}
+ \item{x}{A \code{phylo4com}, \code{phylo4d}, or \code{phylo4} object.}
\item{method}{Method for calculating pd.}
\item{\dots}{additional arguments to be passed to other methods}
}
\details{
TODO
+
+ When applied to a \code{phylo4} tree, traditional PD is the only
+ option (because the object contains no abundance data in this case).
}
\value{
- A numeric vector of length equal to the number of communities.
+ For \code{phylo4com} or \code{phylo4d}, a numeric vector of length
+ equal to the number of communities. For \code{phylo4}, a single
+ numeric value for the tree.
}
\references{
TODO
@@ -31,7 +38,12 @@
\author{Jim Regetz (regetz at nceas.ucsb.edu)}
\examples{
pd(weeds)
+
+ # traditional pd of the master tree
+ pd(phylo4(weeds))
+
# minTL(weeds$A) <- getMinTL(weeds$A, genera(weeds$A))
# pd(weeds$A, "polytomy")
# pd(weeds$A, "yule")
+
}
More information about the Ecopd-commits
mailing list