[adegenet-commits] r348 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 3 16:05:44 CEST 2009


Author: jombart
Date: 2009-06-03 16:05:43 +0200 (Wed, 03 Jun 2009)
New Revision: 348

Modified:
   pkg/R/seqTrack.R
Log:
Found a source of errors. Weighted sampling looses a date at each step (because weights are so that minimum weight is set to 0). 
Now got rid of weighted sampling.


Modified: pkg/R/seqTrack.R
===================================================================
--- pkg/R/seqTrack.R	2009-06-02 23:46:32 UTC (rev 347)
+++ pkg/R/seqTrack.R	2009-06-03 14:05:43 UTC (rev 348)
@@ -503,18 +503,30 @@
             if(length(valRes)==0) { # if no simul are retained
                 warning(paste("No simulation was retained at the given threshold at step",i))
             } else {
-                if(optim=="min"){ # define weights for further samplings
-                    w <- max(valRes,na.rm=TRUE) - valRes
-                    w <- w/sum(w)
-                } else {
-                    w <- valRes
-                    w <- w/sum(w)
-                }
+                ##  if(optim=="min"){ # define weights for further samplings
+                ##                     w <- max(valRes,na.rm=TRUE) - valRes
+                ##                     w <- w/sum(w)
+                ##                 } else {
+                ##                     w <- valRes
+                ##                     w <- w/sum(w)
+                ##                 }
 
 
                 ## new dates
+                ## DEBUGING ##
+                temp <- apply(date,1,function(vec) length(unique(vec)))
+                cat("\n i =", i, "j =", j, "Number of dates per sequence:\n")
+                print(temp)
+                cat("\nHead of date:\n")
+                print(head(date))
+                ## cat("\nProba vector:\n")
+                ## print(w)
+                ## END DEBUGING ##
+
+                ## newDates <- apply(date, 1, function(vec) #  used a weighted sampling
+                ##                                  sample(vec, size=step.size, replace=TRUE, prob=w))
                 newDates <- apply(date, 1, function(vec)
-                                  sample(vec, size=step.size, replace=TRUE, prob=w))
+                                  sample(vec, size=step.size, replace=TRUE))
                 newDates <- t(newDates)
 
                 ## re-initialize posterior distributions



More information about the adegenet-commits mailing list