[adegenet-commits] r325 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 27 17:07:23 CEST 2009


Author: jombart
Date: 2009-05-27 17:07:23 +0200 (Wed, 27 May 2009)
New Revision: 325

Modified:
   pkg/R/seqTrack.R
Log:
new color method for plotSeq


Modified: pkg/R/seqTrack.R
===================================================================
--- pkg/R/seqTrack.R	2009-05-27 14:49:53 UTC (rev 324)
+++ pkg/R/seqTrack.R	2009-05-27 15:07:23 UTC (rev 325)
@@ -141,18 +141,37 @@
 
     ## FIND THE COLOR FOR EDGES ##
     if(is.null(col)){
-        w <- as.numeric(x[,3])
-        w <- max(w) - w
-        w <- w-min(w)
-        w <- 1+ w/max(w) * 99
+        if(is.null(mu0) & is.null(seq.length)) {
+            col <- "black"
+        } else {
+            w <- .pAbeforeB(x$ances.date, x$date, mu0, seq.length, 1000)
+            w <- max(w) - w
+            w <- w-min(w)
+            w <- 1+ w/max(w) * 99
 
-        opalette <- palette()
-        on.exit(palette(opalette))
-        palette(heat.colors(100))
+            opalette <- palette()
+            on.exit(palette(opalette))
+            palette(heat.colors(100))
 
-        col <- w
+            col <- w
+        }
     }
 
+    ## THIS WAS USED WHEN COLOR REPRESENTED THE NUMBER OF MUTATIONS ##
+    ##  if(is.null(col)){
+    ##         w <- as.numeric(x[,3])
+    ##         w <- max(w) - w
+    ##         w <- w-min(w)
+    ##         w <- 1+ w/max(w) * 99
+
+    ##         opalette <- palette()
+    ##         on.exit(palette(opalette))
+    ##         palette(heat.colors(100))
+
+    ##         col <- w
+    ##     }
+
+
     ## recycle col
     col <- rep(col,length=length(x.from))
 
@@ -226,6 +245,7 @@
                       col=col[nullLength], seq.col=col[nullLength], add=TRUE, ...)
     }
 
+
     ## RESULT ##
     res <- data.frame(x.from, y.from, x.to, y.to)
     return(invisible(res))
@@ -354,13 +374,17 @@
     res <- sapply(1:length(p), f1) # proba for all days
     res <- sum(res) # sum
     return(res)
-} # end .pAbeforeB
+}
 
+.pAbeforeB <- Vectorize(.pAbeforeB, vectorize.args=c("dateA","dateB")) ## end .pAbeforeB
 
 
 
 
 
+
+
+
 #####################
 ## optimize.seqTrack
 #####################



More information about the adegenet-commits mailing list