[adegenet-commits] r355 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 4 00:15:48 CEST 2009


Author: jombart
Date: 2009-06-04 00:15:46 +0200 (Thu, 04 Jun 2009)
New Revision: 355

Modified:
   pkg/R/simuFlu.R
Log:
It works nicely !!! As expected, output growth is exponential.
We could cope with this by using sub-samplings, or chosing lower transmission rates, or...


Modified: pkg/R/simuFlu.R
===================================================================
--- pkg/R/simuFlu.R	2009-06-03 21:39:38 UTC (rev 354)
+++ pkg/R/simuFlu.R	2009-06-03 22:15:46 UTC (rev 355)
@@ -13,7 +13,7 @@
 
     ## GENERAL VARIABLES ##
     NUCL <- c("a","t","c","g")
-    res <- list(seq=list(), date=integer(), ances=integer())
+    res <- list(seq=list(), dates=integer(), ances=integer())
     toExpand <- logical()
 
 
@@ -65,7 +65,7 @@
         toExpand[idx] <<- FALSE # this one is no longer to expand
         nbDes <- nb.dupli()
         if(nbDes==0) return(NULL) # stop if no descendant
-        newDates <- date.dupli(date) # find dates for descendants
+        newDates <- sapply(1:nbDes, function(i) date.dupli(date)) # find dates for descendants
         newDates <- newDates[newDates <= Tmax] # don't store future sequences
         nbDes <- length(newDates)
         if(nbDes==0) return(NULL) # stop if no suitable date
@@ -74,6 +74,7 @@
         res$dates <<- c(res$dates, newDates) # append to general output
         res$ances <<- c(res$ances, rep(idx, nbDes)) # append to general output
         toExpand <<- c(toExpand, rep(TRUE, nbDes))
+        return(NULL)
     }
 
 
@@ -87,8 +88,8 @@
 
     ## simulations: isn't simplicity beautiful?
     while(any(toExpand)){
-        idx <- which.min(toExpand)
-        expand.one.strain(seq[[idx]], date[idx], idx)
+        idx <- min(which(toExpand))
+        expand.one.strain(res$seq[[idx]], res$dates[idx], idx)
     }
 
     return(res)



More information about the adegenet-commits mailing list