[adegenet-commits] r588 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 23 17:54:16 CET 2010


Author: jombart
Date: 2010-02-23 17:54:16 +0100 (Tue, 23 Feb 2010)
New Revision: 588

Modified:
   pkg/R/seqTrack.R
Log:
No need for generation time to guess most likely ancestor.


Modified: pkg/R/seqTrack.R
===================================================================
--- pkg/R/seqTrack.R	2010-02-23 16:26:28 UTC (rev 587)
+++ pkg/R/seqTrack.R	2010-02-23 16:54:16 UTC (rev 588)
@@ -200,7 +200,7 @@
 ## the 'proximity when going from i to j'
 ##
 seqTrack.default <- function(x, x.names, x.dates, best=c("min","max"),
-                     prox.mat=NULL, gen.time=NULL, mu=NULL, haplo.length=NULL, ...){
+                     prox.mat=NULL, mu=NULL, haplo.length=NULL, ...){
 
     ## CHECKS ##
     best <- match.arg(best)
@@ -274,13 +274,13 @@
 
         ## If several ancestors remain, take the one closest to the average generation time.
         if(length(ances)>1){
-            if(is.null(gen.time) | !D.ARE.MUT | is.null(mu) | is.null(haplo.length)) { # if we don't have generation time, or if dist. are not nb of mutations
+            if(!D.ARE.MUT | is.null(mu) | is.null(haplo.length)) { # if we don't have mutation rates / haplo length, or if dist. are not nb of mutations
                 ances <- ances[which.min(x.dates[ances])] # take the oldest ancestor
-            } else { # if we have generation time and distances are mutations
+            } else { # if distances are mutations and we've got mu and L
                 timeDiff <- as.numeric(difftime(x.dates[idx], x.dates[ances], units="day")) # days between candidates and target
-                nbGen <- round(timeDiff / gen.time) # number of generations
+                ##nbGen <- round(timeDiff / gen.time) # number of generations
                 nbMut <- x[ances, idx]
-                prob <- dbinom(nbMut, nbGen*haplo.length, mu)
+                prob <- dbinom(nbMut, timeDiff*haplo.length, mu)
                 ances <- ances[which.max(prob)] # take the most likely ancestor
             }
         }



More information about the adegenet-commits mailing list