[Vegan-commits] r1228 - in branches/1.17: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jun 13 08:32:37 CEST 2010


Author: jarioksa
Date: 2010-06-13 08:32:37 +0200 (Sun, 13 Jun 2010)
New Revision: 1228

Added:
   branches/1.17/R/treedist.R
Modified:
   branches/1.17/DESCRIPTION
   branches/1.17/inst/ChangeLog
   branches/1.17/inst/NEWS
   branches/1.17/man/treedive.Rd
Log:
add treedist.R to the release branch (and hints of release date)

Modified: branches/1.17/DESCRIPTION
===================================================================
--- branches/1.17/DESCRIPTION	2010-06-13 05:49:24 UTC (rev 1227)
+++ branches/1.17/DESCRIPTION	2010-06-13 06:32:37 UTC (rev 1228)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
 Version: 1.17-3
-Date: June 3, 2010 (not yet released)
+Date: June 15, 2010 (scheduled)
 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, 
    R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, 
    Helene Wagner  

Copied: branches/1.17/R/treedist.R (from rev 1227, pkg/vegan/R/treedist.R)
===================================================================
--- branches/1.17/R/treedist.R	                        (rev 0)
+++ branches/1.17/R/treedist.R	2010-06-13 06:32:37 UTC (rev 1228)
@@ -0,0 +1,21 @@
+`treedist` <-
+    function(x, tree, ...)
+{
+    n <- nrow(x)
+    ABJ <- matrix(0, n , n)
+    dmat <- as.matrix(cophenetic(tree))
+    for(j in 1:n)
+        for (k in j:n) {
+            jk <- x[j,] > 0 | x[k,] > 0
+            if (sum(jk) > 1)
+                ABJ[k, j] <- treeheight(update(tree, d = as.dist(dmat[jk, jk]))) 
+        }
+    A <- diag(ABJ)
+    AB <- as.dist(outer(A, A, "+"))
+    ABJ <- as.dist(ABJ)
+    out <- (2 * ABJ - AB)/ABJ
+    attr(out, "method") <- "treedist"
+    attr(out, "call") <- match.call()
+    attr(out, "Labels") <- row.names(x)
+    out
+}

Modified: branches/1.17/inst/ChangeLog
===================================================================
--- branches/1.17/inst/ChangeLog	2010-06-13 05:49:24 UTC (rev 1227)
+++ branches/1.17/inst/ChangeLog	2010-06-13 06:32:37 UTC (rev 1228)
@@ -2,8 +2,11 @@
 
 VEGAN RELEASE VERSIONS at http://cran.r-project.org/
 
-Version 1.17-3 (not yet released)
+Version 1.17-3 (release scheduled for June 15, 2010)
 
+	* copied treedist.R from the devel version and merged its
+	documentation (r1205 plus fixes and speed-up r1207:1209).
+
 	* merge r1211:1213: mantel and mantel.partial speed-ups.
 
 	* merge r1210: tsallis a bit faster.

Modified: branches/1.17/inst/NEWS
===================================================================
--- branches/1.17/inst/NEWS	2010-06-13 05:49:24 UTC (rev 1227)
+++ branches/1.17/inst/NEWS	2010-06-13 06:32:37 UTC (rev 1228)
@@ -10,8 +10,8 @@
     - anova.cca and permutest.cca: permutations of cca result is
       faster and now nearly equally fast (or slow) in rda and cca. 
 
-    - betadisper: 'type = "median"' (teh default) was not computing
-      the spatial median on the real and imagninary axes separately.
+    - betadisper: 'type = "median"' (the default) was not computing
+      the spatial median on the real and imaginary axes separately.
       Reported by Marek Omelka.
 
     - cca, rda and capscale failed when Condition() was a factor, but
@@ -72,6 +72,12 @@
       allows using lower rank presentation of fitted values
       (including rank = 0). 
 
+    - treedist: new function to find dissimilarities of species
+      property trees of communities. The property trees can be, e.g.,
+      functional diversity trees, taxonomies or phylogenies. Similar
+      in spirit to UniFrac distance (C. Lozupone & R. Knight, Appl
+      Environ Microbiol 71:8225-8235; 2005), but completely different
+      in design and works only with binary data.
 
 		NEW FEATURES AND FIXES IN VEGAN 1.17-1
 

Modified: branches/1.17/man/treedive.Rd
===================================================================
--- branches/1.17/man/treedive.Rd	2010-06-13 05:49:24 UTC (rev 1227)
+++ branches/1.17/man/treedive.Rd	2010-06-13 06:32:37 UTC (rev 1228)
@@ -1,6 +1,7 @@
 \name{treedive}
 \alias{treedive}
 \alias{treeheight}
+\alias{treedist}  
 
 \title{ Functional Diversity estimated from a Species Dendrogram}
 \description{
@@ -12,16 +13,18 @@
 \usage{
 treedive(comm, tree, match.force = FALSE)
 treeheight(tree)
+treedist(x, tree, ...)
 }
 
 \arguments{
-  \item{comm}{Community data frame or matrix.}
+  \item{comm, x}{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.}
+  \item{\dots}{Other arguments passed to functions (ignored).}
 }
 \details{
   Function \code{treeheight} finds the sum of lengths of connecting
@@ -40,6 +43,16 @@
   reconstructing the dendrogram for the subset of the cophenetic
   distance matrix for species occurring in each site.
 
+  Function \code{treedist} finds the dissimilarities among
+  trees. Pairwise dissimilarity of two trees is found by combining
+  species in a common tree and seeing how much of the tree height is
+  shared and how much is unique. The current function uses a Jaccard
+  like approach and defines dissimilarity as the total unshared height
+  proportional of the total height of the combined tree. The idea is
+  similar as in the UniFrac distance (Lozupone and Knight 2005), but
+  the implementation is completely different and only works in the
+  presence absence framework.
+
   The functions need a dendrogram of species traits as an input. If
   species traits contain \code{\link{factor}} or \code{\link{ordered}}
   factor variables, it is recommended to use Gower distances for mixed
@@ -53,10 +66,17 @@
   Null model, and the results will change with this choice.
 }
 
-\value{
-  A vector of diversity values or a single tree height.
+\value{ 
+  A vector of diversity values or a single tree height, or a
+  dissimilarity structure that inherits from \code{\link{dist}} and
+  can be used similarly.  
 }
+
 \references{
+  Lozupone, C. and Knight, R. 2005. UniFrac: a new phylogenetic method
+  for comparing microbial communities. \emph{Applied and Environmental
+  Microbiology} 71, 8228--8235.
+
   Petchey, O.L. and Gaston, K.J. 2002. Functional diversity (FD), species
   richness and community composition. \emph{Ecology Letters} 5,
   402--411.
@@ -81,8 +101,11 @@
 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)
+## The current choice fixes only site totals.
+oecosimu(dune, treedive, "r0", tree = cl)
+## Clustering of tree distances
+dtree <- treedist(dune, cl)
+plot(hclust(dtree, "aver"))
 }
 
 \keyword{ univar }



More information about the Vegan-commits mailing list