[adegenet-commits] r314 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 20 13:17:16 CEST 2009


Author: jombart
Date: 2009-05-20 13:17:16 +0200 (Wed, 20 May 2009)
New Revision: 314

Modified:
   pkg/R/seqTrack.R
Log:
corrected .ambigDates


Modified: pkg/R/seqTrack.R
===================================================================
--- pkg/R/seqTrack.R	2009-05-20 10:52:41 UTC (rev 313)
+++ pkg/R/seqTrack.R	2009-05-20 11:17:16 UTC (rev 314)
@@ -213,23 +213,25 @@
 
 
 
-#############
-## .checkTime
-#############
+###############
+## .ambigDates
+###############
 ## x: result of seqTrack
 ## mu0: mutation rate / site / year
 ## p: threshold probability for a sequence not to mutate
-.checkTime <- function(x, mu0, seq.dates, seq.length, p=0.99){
+.ambigDates <- function(x, mu0, seq.dates, seq.length, p=0.99){
     mu <- mu0/365 # mutation rate / site / day
     t <- 0:1000 # in days
     Pt <- (1-mu)^(t*seq.length)
     ##plot(Pt,ylim=c(0,1))
     nbDays <- which.min(Pt>p)-1
 
+    isNA <- is.na(unlist(x[2,]))
     date.to <- seq.dates[unlist(x[1,])]
     date.from <- seq.dates[unlist(x[2,])]
 
     res <- (date.to-date.from) < nbDays*2
+    res[is.na(res)] <- FALSE
     return(res)
 
 } # end checkTime
@@ -297,7 +299,7 @@
 
 
     ## LOOK FOR AMBIGUOUS DATES ##
-    isAmbig <- .checkTime(res.ini, mu0, seq.dates, seq.length, p=0.99)
+    isAmbig <- .ambigDates(res.ini, mu0, seq.dates, seq.length, p=0.99)
     if(!any(isAmbig)){
         cat("\nNo ambiguity in dates was found; unique solution returned.\n")
         return(res)
@@ -333,7 +335,7 @@
 
 
     ## RESULT ##
-    res <- res.cur
+    res <- list(res=res.cur, permutID=permuted, newDates=dates.cur)
     nperm <- length(permuted)
     cat("\nBest result found after",nperm,"permutations of ambiguous dates\n")
     return(res)



More information about the adegenet-commits mailing list