[Vegan-commits] r1338 - in pkg/vegan: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 19 10:15:02 CEST 2010


Author: jarioksa
Date: 2010-10-19 10:15:01 +0200 (Tue, 19 Oct 2010)
New Revision: 1338

Modified:
   pkg/vegan/R/treedist.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/treedive.Rd
Log:
treedist works with zero height trees and man tells that dissimilarity range is 0..2

Modified: pkg/vegan/R/treedist.R
===================================================================
--- pkg/vegan/R/treedist.R	2010-10-18 12:35:34 UTC (rev 1337)
+++ pkg/vegan/R/treedist.R	2010-10-19 08:15:01 UTC (rev 1338)
@@ -4,16 +4,18 @@
     n <- nrow(x)
     ABJ <- matrix(0, n , n)
     dmat <- as.matrix(cophenetic(tree))
-    for(j in 1:n)
+    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
+    out[ABJ==0] <- 0
     attr(out, "method") <- "treedist"
     attr(out, "call") <- match.call()
     attr(out, "Labels") <- row.names(x)

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-10-18 12:35:34 UTC (rev 1337)
+++ pkg/vegan/inst/ChangeLog	2010-10-19 08:15:01 UTC (rev 1338)
@@ -4,6 +4,11 @@
 
 Versin 1.18-14 (opened October 15, 2010)
 
+	* treedist: works now with zero-height trees (for instance, only
+	one item in a tree). Help page now tells that tree distances are
+	in range 0..2 instead of 0..1, since combining two trees may add a
+	new common root. 
+
 	* isomap: returns only axes associated with positive eigenvalues.
 
 	* wcmdscale: give two goodness of fit statistics for 'k' axes: one

Modified: pkg/vegan/man/treedive.Rd
===================================================================
--- pkg/vegan/man/treedive.Rd	2010-10-18 12:35:34 UTC (rev 1337)
+++ pkg/vegan/man/treedive.Rd	2010-10-19 08:15:01 UTC (rev 1338)
@@ -50,10 +50,12 @@
   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.
+  proportional of the total height of the combined tree. However, the
+  index is not limited to the maximum of one, since combining two trees
+  may add a new root, and therefore the maximum dissimilarity is two.
+  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}}



More information about the Vegan-commits mailing list