[adegenet-commits] r93 - in pkg: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Apr 10 19:34:14 CEST 2008


Author: jombart
Date: 2008-04-10 19:34:14 +0200 (Thu, 10 Apr 2008)
New Revision: 93

Modified:
   pkg/R/monmonier.R
   pkg/TODO
Log:
Fixed the bug with bd.length.
Must check why the algorithm stops to early:
try the first example of manpage, with bd.length=600 => no error but dir2 could go further.


Modified: pkg/R/monmonier.R
===================================================================
--- pkg/R/monmonier.R	2008-04-10 17:02:52 UTC (rev 92)
+++ pkg/R/monmonier.R	2008-04-10 17:34:14 UTC (rev 93)
@@ -30,7 +30,6 @@
 D <- as.matrix(dist)
 ## matrix of distances among neighbours
 D <- M*D
-maxS <- sum(D>0)/2 # maxS: maximum increment of s1 and s2 in main function (= number of local distances)
 
 ## set/check the threshold value of the distances among neighbours
 ## default: the median of all distances among neighbours
@@ -253,8 +252,8 @@
     ## logical handling the exansion of a boundary
     keepExpanding <- ((current.bd.length < bd.length)
                       && ((currentDir1$val>Dlim)|(currentDir2$val>Dlim))
-                      && s1 < maxS
-                      && s2 < maxS )
+                      && s1 < nrow(matSegVal)
+                      && s2 < nrow(matSegVal) )
 
     #### This while loop has the following behavior:
     ## as long as the keepExpanding is true, we try to expand the boundary by 
@@ -319,8 +318,8 @@
         ## update the logical for the while loop
         keepExpanding <- ((current.bd.length < bd.length)
                           && ((currentDir1$val>Dlim)|(currentDir2$val>Dlim))
-                          && s1 < maxS-1
-                          && s2 < maxS-1 )
+                          && s1 <= nrow(matSegVal)
+                          && s2 <= nrow(matSegVal) )
         
         ## handle the looping of a boundary
         if(hasExpanded && (current.bd.length>3) && allowLoop){
@@ -348,7 +347,7 @@
         ## output for debugging
          cat("\n","s1:",s1,"s2:",s2,"i1:",i1,"i2:",i2,"D1:",
             currentDir1$val,"D2:",currentDir2$val,"Dlim:",Dlim,
-            "maxS",maxS,"\n")
+            "nrow(matSegVal)",nrow(matSegVal),"\n")
 
     } # end of one given run
 

Modified: pkg/TODO
===================================================================
--- pkg/TODO	2008-04-10 17:02:52 UTC (rev 92)
+++ pkg/TODO	2008-04-10 17:34:14 UTC (rev 93)
@@ -29,7 +29,7 @@
 * df2genind fails when entirely non-type individuals exist -- done (TJ)
 * optimize.monmonier: check the way final object is constructed: can fail when the function is called inside another function
 * monmonier: fails on a regular grid; must be a problem in the C code detecting colinearity between two segments
-* monmonier: bug when bd.length is abnormally high. 
+* monmonier: bug when bd.length is abnormally high -- mainly fixed, but sometimes stops to early (TJ) 
 *
 
 # DOCUMENTATION ISSUES:



More information about the adegenet-commits mailing list