[Ecopd-commits] r52 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 26 19:19:23 CET 2009


Author: regetz
Date: 2009-10-26 19:19:22 +0100 (Mon, 26 Oct 2009)
New Revision: 52

Modified:
   pkg/NAMESPACE
   pkg/R/pd.R
   pkg/man/pd.Rd
Log:
added 'method' argument to pd function, and removed commPD function


Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2009-10-26 18:06:34 UTC (rev 51)
+++ pkg/NAMESPACE	2009-10-26 18:19:22 UTC (rev 52)
@@ -6,7 +6,6 @@
 export(`minTL<-`)
 
 export(caterpillar)
-export(commPD)
 export(genera)
 export(getMinTL)
 export(pd)
@@ -21,8 +20,6 @@
 
 export(phylo4com)
 export(pd)
-export(ancestralEdgeLength)
-export(nodes)
 export(PAE)
 export(IAC)
 export(ED)

Modified: pkg/R/pd.R
===================================================================
--- pkg/R/pd.R	2009-10-26 18:06:34 UTC (rev 51)
+++ pkg/R/pd.R	2009-10-26 18:19:22 UTC (rev 52)
@@ -1,5 +1,10 @@
 # basic pd calculation
-pd <- function(phy) {
+pd <- function(phy, method=c("traditional", "polytomy", "yule")) {
+  ## if using non-traditional pd, adjust tip lengths based on abundance
+  method <- match.arg(method)
+  if (method %in% c("polytomy", "yule")) {
+    phy <- weightByAbund(phy, method)
+  } 
   # exclude root edge from calculation (if it exists)
   if (isRooted(phy)) {
     nonroot.nodes <- setdiff(nodeId(phy), rootNode(phy))
@@ -106,13 +111,3 @@
   return(tree)
 
 }
-
-# calculate PD value for a single community
-commPD <- function(tree, method=c("traditional", "polytomy", "yule")) {
-  method <- match.arg(method)
-  if (method == "traditional") {
-    pd(tree)
-  } else {
-    pd(weightByAbund(tree, method))
-  } 
-}

Modified: pkg/man/pd.Rd
===================================================================
--- pkg/man/pd.Rd	2009-10-26 18:06:34 UTC (rev 51)
+++ pkg/man/pd.Rd	2009-10-26 18:19:22 UTC (rev 52)
@@ -5,10 +5,11 @@
   Calculates PD (phylogenetic diversity) for a phylogeny
 }
 \usage{
-  pd(phy)
+  pd(phy, method=c("traditional", "polytomy", "yule"))
 }
 \arguments{
-  \item{phy}{a \code{phylo4} object (or one that inherits from it)}
+  \item{phy}{A \code{phylo4d} object.}
+  \item{method}{Method for calculating pd.}
 }
 \details{
   TODO
@@ -23,4 +24,8 @@
 \examples{
   data(weeds)
   pd(weeds$A)
+
+  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