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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 14 19:49:05 CET 2013


Author: psolymos
Date: 2013-01-14 19:49:04 +0100 (Mon, 14 Jan 2013)
New Revision: 2369

Modified:
   pkg/vegan/R/clamtest.R
   pkg/vegan/inst/ChangeLog
Log:
clamtest fixes: dimnames bug and solution for an extreme case.

Modified: pkg/vegan/R/clamtest.R
===================================================================
--- pkg/vegan/R/clamtest.R	2013-01-14 08:32:50 UTC (rev 2368)
+++ pkg/vegan/R/clamtest.R	2013-01-14 18:49:04 UTC (rev 2369)
@@ -19,7 +19,7 @@
         stop("number of groups must be 2")
     glabel <- as.character(unique(groups))
     if (is.null(colnames(comm)))
-        colnames(comm) <- paste("Species", 1:nrow(comm), sep=".")
+        colnames(comm) <- paste("Species", 1:ncol(comm), sep=".")
     if (any(colSums(comm) <= 0))
         stop("'comm' contains zero sum columns")
     spp <- colnames(comm)
@@ -73,14 +73,28 @@
     ## finding Xmin and Ymin values for Xseq and Yseq
     Xmins <- sapply(Yseq, function(z) rootfun(z, C1, C2, n, m, upper=max(X)))
     Ymins <- sapply(Xseq, function(z) rootfun(z, C2, C1, m, n, upper=max(Y)))
+
+    ## needed to tweak original set of rules (extreme case reported
+    ## by Richard Telford failed here)
+    if (all(is.na(Xmins)))
+        Xmins[1] <- 1
+    if (all(is.na(Ymins)))
+        Ymins[1] <- 1
+
     minval <- list(data.frame(x=Xseq[!is.na(Ymins)], y=Ymins[!is.na(Ymins)]),
         data.frame(x=Xmins[!is.na(Xmins)], y=Yseq[!is.na(Xmins)]))
+
     ## shared but too rare
     Ymin <- Ymins[1]
     Xmin <- Xmins[1]
     sr <- X < Xmin & Y < Ymin
-    tmp1 <- approx(c(Xmin, 1), c(1, Ymin), xout=1:Xmin)
-    tmp2 <- approx(c(1, Ymin), c(Xmin, 1), xout=1:Ymin)
+
+    ## consequence of manually setting Xmin/Ymin resolved here
+    tmp1 <- if (Xmin==1)
+        list(x=1, y=Xmin) else approx(c(Xmin, 1), c(1, Ymin), xout=1:Xmin)
+    tmp2 <- if (Ymin==1)
+        list(x=1, y=Ymin) else approx(c(1, Ymin), c(Xmin, 1), xout=1:Ymin)
+
     for (i in 1:S) {
         if (X[i] %in% tmp1$x)
             sr[i] <- Y[i] < tmp1$y[which(X[i]==tmp1$x)]

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2013-01-14 08:32:50 UTC (rev 2368)
+++ pkg/vegan/inst/ChangeLog	2013-01-14 18:49:04 UTC (rev 2369)
@@ -4,6 +4,14 @@
 
 Version 2.1-23 (opened January 8, 2013)
 
+	* clamtest: Richard Telford reported an extreme case 
+	{rbind(a=c(1,0,5,10,4),b=c(0,10,5,2,1))} where
+	clamtest failed due to inadequately setting up minimum
+	abundance thresholds for rare species. The issue is solved
+	by hard coding the minimum values to be 1 when no suitable 
+	solution is found. Also, clamtest failed when the community matrix 
+	had no column names, this is now fixed.
+
 	* capscale: It was wrongly assumed that eigenvalues could be used
 	in normalization of species scores, but this worked only with
 	Euclidean distances. Now normalization is done explicitly with



More information about the Vegan-commits mailing list