[Vegan-commits] r485 - in pkg: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Aug 25 18:39:58 CEST 2008
Author: jarioksa
Date: 2008-08-25 18:39:58 +0200 (Mon, 25 Aug 2008)
New Revision: 485
Modified:
pkg/R/treedive.R
pkg/inst/ChangeLog
pkg/man/treedive.Rd
Log:
treedive tries to match 'comm' and 'tree', docs tell to use oecosimu for testing
Modified: pkg/R/treedive.R
===================================================================
--- pkg/R/treedive.R 2008-08-25 07:29:25 UTC (rev 484)
+++ pkg/R/treedive.R 2008-08-25 16:39:58 UTC (rev 485)
@@ -1,9 +1,21 @@
`treedive` <-
- function(comm, tree)
+ function(comm, tree, match.force = FALSE)
{
if (!inherits(tree, "hclust"))
stop("'clus' must be an 'hclust' result object")
m <- as.matrix(cophenetic(tree))
+ ## Check tree/comm match by names
+ if (match.force || ncol(comm) != length(tree$order)) {
+ fnd <- colnames(comm) %in% tree$labels
+ if (!all(fnd)) {
+ warning("not all names of 'comm' found in 'tree'")
+ comm <- comm[, fnd]
+ }
+ fnd <- tree$labels %in% colnames(comm)
+ if (!all(fnd))
+ warning("not all names of 'tree' found in 'comm'")
+ comm <- comm[, tree$labels[fnd]]
+ }
## Repeat for sites
div <- numeric(nrow(comm))
for (i in 1:nrow(comm)) {
@@ -12,6 +24,7 @@
cl <- update(tree, d = d)
div[i] <- treeheight(cl)
}
+ names(div) <- rownames(comm)
div
}
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2008-08-25 07:29:25 UTC (rev 484)
+++ pkg/inst/ChangeLog 2008-08-25 16:39:58 UTC (rev 485)
@@ -5,6 +5,10 @@
Version 1.14-10 (opened August 21, 2008)
+ * treedive: tries to match 'comm' and 'tree' names if forced (by
+ an arg), or when sizes do not match. Output vector has names. Docs
+ discuss estimating signifcance using oecosimu().
+
* oecosimu: accepts now a vector of statistics and plain
statistics instead of the list item statistics. This means that
things like species richness for sites can be analysed with
Modified: pkg/man/treedive.Rd
===================================================================
--- pkg/man/treedive.Rd 2008-08-25 07:29:25 UTC (rev 484)
+++ pkg/man/treedive.Rd 2008-08-25 16:39:58 UTC (rev 485)
@@ -10,7 +10,7 @@
}
\usage{
-treedive(comm, tree)
+treedive(comm, tree, match.force = FALSE)
treeheight(tree)
}
@@ -18,6 +18,10 @@
\item{comm}{Community data frame or matrix.}
\item{tree}{A dendrogram which for \code{treedive} must be for species
(columns).}
+ \item{match.force}{Force matching of column names in \code{comm} and
+ labels in \code{tree}. If \code{FALSE}, matching only happens when
+ dimensions differ, and in that case the species must be in identical
+ order in both.}
}
\details{
Function \code{treeheight} finds the sum of lengths of connecting
@@ -43,6 +47,10 @@
and usually the recommended clustering method is UPGMA (\code{method =
"average"} in function \code{\link{hclust}}) (Podani and Schmera
2006).
+
+ It is possible to analyse the non-randomness of functional diversity
+ using \code{\link{oecosimu}}. This provided specifying an adequate
+ Null model, and the results will change with this choice.
}
\value{
@@ -69,9 +77,12 @@
## the example uses taxonomy
data(dune)
data(dune.taxon)
-d <- taxa2dist(dune.taxon)
+d <- taxa2dist(dune.taxon, varstep=TRUE)
cl <- hclust(d, "aver")
treedive(dune, cl)
+## Significance test using Null model communities.
+## The current choice fixes both species and site totals.
+oecosimu(dune, treedive, "quasiswap", tree = cl)
}
\keyword{ univar }
More information about the Vegan-commits
mailing list