[adegenet-commits] r351 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 3 18:16:08 CEST 2009


Author: jombart
Date: 2009-06-03 18:16:06 +0200 (Wed, 03 Jun 2009)
New Revision: 351

Modified:
   pkg/R/seqTrack.R
Log:
optimize.seqTrack no longer crashes, but not all checked.


Modified: pkg/R/seqTrack.R
===================================================================
--- pkg/R/seqTrack.R	2009-06-03 16:00:47 UTC (rev 350)
+++ pkg/R/seqTrack.R	2009-06-03 16:16:06 UTC (rev 351)
@@ -389,7 +389,7 @@
 ## 3) uncomment, adapt, and test code for missing data
 ##
 optimize.seqTrack <- function(nstep=10, step.size=1e3,
-                              seq.names, seq.dates, W, thres=0.1, optim=c("min","max"),
+                              seq.names, seq.dates, W, thres=0.2, optim=c("min","max"),
                               prox.mat=NULL, mu0, seq.length,
                               rMissDate=.rUnifTimeSeq, ...){
 
@@ -498,13 +498,22 @@
                 ##}
             } # end for j
 
-            ## retain thres% of the dates ##
+            ## retain a given % (thres) of the dates ##
             toKeep <- valRes < quantile(valRes, thres) ## NOT WORKING FOR optim==max !!!
-            date <- date[,toKeep] # retained posterior
+
+            date <- date[,toKeep,drop=FALSE] # retained posterior
             newDates <- apply(date, 1, function(vec)
                               sample(vec, size=step.size, replace=TRUE)) # new prior
             newDates <- t(newDates)
 
+            ## DEBUGING ##
+            cat("\ntoKeep:\n")
+            print(toKeep)
+            cat("\nhead date (posterior):\n")
+            print(head(date))
+            ## END DEBUGING ##
+
+
             ## re-initialize posterior distributions
             if(i<nstep){
                 ## ances <- integer(0) # not needed now
@@ -512,6 +521,7 @@
                 ## ances.date <- character(0) # not needed now
                 valRes <- numeric(0)
             } # end if
+
         } # end for i
 
         ##  ## dates: new prior taken from obtained posterior
@@ -530,16 +540,6 @@
         ##                                  sample(vec, size=step.size, replace=TRUE, prob=w))
 
 
-        ## 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 ##
-
     } # end if(!any(isMissDate))
 
 



More information about the adegenet-commits mailing list