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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 23 20:34:54 CET 2014


Author: jarioksa
Date: 2014-03-23 20:34:54 +0100 (Sun, 23 Mar 2014)
New Revision: 2864

Modified:
   pkg/vegan/R/tabasco.R
   pkg/vegan/inst/ChangeLog
Log:
take care that names match in clusters and data in tabasco

Modified: pkg/vegan/R/tabasco.R
===================================================================
--- pkg/vegan/R/tabasco.R	2014-03-22 06:57:05 UTC (rev 2863)
+++ pkg/vegan/R/tabasco.R	2014-03-23 19:34:54 UTC (rev 2864)
@@ -28,6 +28,15 @@
             }
             if (!is.null(site.ind))
                 stop("'site.ind' cannot be used with dendrogram")
+            ## The tree/dendrogam and input data must be ordered
+            ## identically. It could be regarded as a "user error" if
+            ## they are not, but this could be really frustrating and
+            ## give obscure errors, and therefore we take care of
+            ## identical ordering here
+            if (inherits(use, "hclust") && !is.null(hclust$labels))
+                x <- x[use$labels,]
+            else # dendrogram
+                x <- x[labels(use),]
             ## Reorder tree if Rowv specified
             if (isTRUE(Rowv)) {
                 ## order by first CA axis -- decorana() is fastest
@@ -83,6 +92,11 @@
             sp.ind <- as.dendrogram(sp.ind)
         }
         sptree <- sp.ind
+        ## Reorder data to match order in the dendrogam (see 'use' above)
+        if (inherits(sptree, "hclust"))
+            x <- x[, sptree$labels]
+        else # dendrogram
+            x <- x[, labels(sptree)]
         ## Consider reordering species tree
         if (isTRUE(Colv) && !is.null(site.ind)) {
             sptree <- reorder(sptree, wascores(order(site.ind), x),

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2014-03-22 06:57:05 UTC (rev 2863)
+++ pkg/vegan/inst/ChangeLog	2014-03-23 19:34:54 UTC (rev 2864)
@@ -56,7 +56,10 @@
 	used for reordering of dendrograms. Earlier "hclust" objects were
 	changed to dendrograms, but now we provide reorder.hclust() and
 	rev.hclust() in vegan, and can use improved method of ordering the
-	table.
+	table. Dendrogram and hclust labels must match the community data
+	names, and now the community matrix is internally reordered to
+	match the dendrograms. This requires that the clusterings do have
+	labels attributes.
 
 	* treedive, treedist: default is now match.force = TRUE, and
 	treedive() gained new argument 'verbose' to turn of most messages



More information about the Vegan-commits mailing list