[Picante-commits] r96 - in branches/gsoc: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 11 05:57:39 CEST 2008
Author: mrhelmus
Date: 2008-06-11 05:57:39 +0200 (Wed, 11 Jun 2008)
New Revision: 96
Added:
branches/gsoc/R/specaccum.PSR.R
branches/gsoc/man/specaccum.PSR.Rd
Removed:
branches/gsoc/R/specaccum.PSR.r
Log:
Documentation for specaccum.PSR
Added: branches/gsoc/R/specaccum.PSR.R
===================================================================
--- branches/gsoc/R/specaccum.PSR.R (rev 0)
+++ branches/gsoc/R/specaccum.PSR.R 2008-06-11 03:57:39 UTC (rev 96)
@@ -0,0 +1,43 @@
+specaccum.PSR<-function (samp, tree, permutations = 100, method = "random", ...)
+{
+
+#function adapted from the vegan package specaccum
+
+ x <- as.matrix(samp)
+ n <- nrow(x)
+ p <- ncol(x)
+ if (p == 1)
+ {
+ x <- t(x)
+ n <- nrow(x)
+ p <- ncol(x)
+ }
+ accumulator <- function(x,ind,tree)
+ {
+ n <- nrow(x)
+ p <- ncol(x)
+ xx<-x
+ xx[1:n,1:p]<-0
+ xx[apply(x[ind, ], 2, cumsum)>0]<-1
+ PSV<-PSVcalc(xx,tree,compute.var=FALSE)
+ PSV[,1]*PSV[,2]
+ }
+ METHODS <- c("collector", "random", "exact", "rarefaction",
+ "coleman")
+ method <- match.arg(method, METHODS)
+
+ specaccum <- sdaccum <- sites <- perm <- NULL
+ perm <- array(dim = c(n, permutations))
+ for (i in 1:permutations)
+ {
+ r.x=0
+ while(length(r.x)<n){r.x <- accumulator(x, sample(n),tree)}
+ perm[, i]<-r.x
+ }
+ sites <- 1:n
+ specaccum <- apply(perm, 1, mean)
+ sdaccum <- apply(perm, 1, sd)
+ out <- list(call = match.call(), method = method, sites = sites, richness = specaccum, sd = sdaccum, perm = perm)
+ class(out) <- "specaccum"
+ out
+}
\ No newline at end of file
Deleted: branches/gsoc/R/specaccum.PSR.r
===================================================================
--- branches/gsoc/R/specaccum.PSR.r 2008-06-11 01:55:42 UTC (rev 95)
+++ branches/gsoc/R/specaccum.PSR.r 2008-06-11 03:57:39 UTC (rev 96)
@@ -1,43 +0,0 @@
-specaccum.PSR<-function (samp, Cmatrix, permutations = 100, method = "random", ...)
-{
-
-#function adapted from the vegan package specaccum
-
- x <- as.matrix(samp)
- n <- nrow(x)
- p <- ncol(x)
- if (p == 1)
- {
- x <- t(x)
- n <- nrow(x)
- p <- ncol(x)
- }
- accumulator <- function(x,ind,Cmatrix)
- {
- n <- nrow(x)
- p <- ncol(x)
- xx<-x
- xx[1:n,1:p]<-0
- xx[apply(x[ind, ], 2, cumsum)>0]<-1
- PSV<-PSVcalc(xx,Cmatrix,compute.var=FALSE)
- PSV[,1]*PSV[,2]
- }
- METHODS <- c("collector", "random", "exact", "rarefaction",
- "coleman")
- method <- match.arg(method, METHODS)
-
- specaccum <- sdaccum <- sites <- perm <- NULL
- perm <- array(dim = c(n, permutations))
- for (i in 1:permutations)
- {
- r.x=0
- while(length(r.x)<n){r.x <- accumulator(x, sample(n),Cmatrix)}
- perm[, i]<-r.x
- }
- sites <- 1:n
- specaccum <- apply(perm, 1, mean)
- sdaccum <- apply(perm, 1, sd)
- out <- list(call = match.call(), method = method, sites = sites, richness = specaccum, sd = sdaccum, perm = perm)
- class(out) <- "specaccum"
- out
-}
\ No newline at end of file
Added: branches/gsoc/man/specaccum.PSR.Rd
===================================================================
--- branches/gsoc/man/specaccum.PSR.Rd (rev 0)
+++ branches/gsoc/man/specaccum.PSR.Rd 2008-06-11 03:57:39 UTC (rev 96)
@@ -0,0 +1,37 @@
+\name{specaccum.PSR}
+\alias{specaccum.PSR}
+
+\title{ Phylogenetic Species Richness Sample-Based Rarefaction Curve }
+\description{
+ Finds a sample-based rarefaction curve for phylogentic species richness for a set of samples.
+}
+\usage{
+specaccum.PSR(samp, tree, permutations = 100, method = "random", ...)
+}
+
+\arguments{
+ \item{samp}{ Community data matrix }
+ \item{tree}{ A phylo tree object or a phylogenetic covariance matrix}
+ \item{permutations}{ Number of permutations with method method= "random" }
+ \item{method} { Species accumulation method, currently only "random" is supported which add samples in random order. }
+ \item{...}{ Other parameters to functions }
+}
+
+\value{
+The function returns an object of class "specaccum" with items:
+
+\item{call}{ Function call. }
+\item{method}{ Accumulator method. }
+\item{sites}{ Number of sites/samples. For method = "rarefaction" this is the average number of sites corresponding to a certain number of individuals.}
+\item{richness}{ The phylogenetic species richness corresponding to number of sites/samples. With method = "collector" this is the observed phylogenetic species richness, for other methods the average or expected phylogenetic species richness. }
+\item{sd}{ The standard deviation of phylogenetic apecies accumulation curve (or its standard error). This is NULL in method = "collector", and it is estimated from permutations in method = "random", and from analytic equations in other methods. }
+\item{perm}{ Permutation results with method = "random" and NULL in other cases. Each column in perm holds one permutation. }
+}
+
+\references{ Gotelli N.J. & Colwell R.K. (2001) Quantifying biodiversity: procedures and pitfalls in the measurement and comparison of species richness. Ecology Letters, 4, 379-391\cr
+ Helmus M.R., Bland T.J., Williams C.K. & Ives A.R. (2007) Phylogenetic measures of biodiversity. American Naturalist, 169, E68-E83 }
+\author{ Matthew Helmus \email{mrhelmus at gmail.com}
+ }
+\seealso{ \code{\link{calcPSR}}, \code{\link{specaccum}}}
+
+\keyword{univar}
More information about the Picante-commits
mailing list