[adegenet-commits] r746 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Dec 25 01:22:55 CET 2010


Author: jombart
Date: 2010-12-25 01:22:55 +0100 (Sat, 25 Dec 2010)
New Revision: 746

Modified:
   pkg/R/SNPbin.R
Log:
minor change to .bin2raw 


Modified: pkg/R/SNPbin.R
===================================================================
--- pkg/R/SNPbin.R	2010-12-24 17:06:03 UTC (rev 745)
+++ pkg/R/SNPbin.R	2010-12-25 00:22:55 UTC (rev 746)
@@ -230,10 +230,6 @@
 ## function to code multiple SNPs on a byte
 ## 8 combinations of SNPs can be coded onto a single byte (0->255)
 .bin2raw <- function(vecSnp){
-    ## was required in pure-R version
-    ## SNPCOMB <- as.matrix(expand.grid(rep(list(c(0,1)), 8)))
-    ## colnames(SNPCOMB) <- NULL
-
     ## handle missing data
     NAposi <- which(is.na(vecSnp))
     if(length(NAposi)>0){
@@ -241,7 +237,8 @@
     }
 
 
-    nbBytes <- 1+ length(vecSnp) %/% 8
+    nbBytes <- length(vecSnp) %/% 8
+    if(length(vecSnp) %% 8 > 0) {nbBytes <- nbBytes +1}
     ori.length <- length(vecSnp)
     new.length <- 8*nbBytes
     vecSnp <- c(vecSnp, rep(0, new.length-ori.length)) # fill the end with 0 of necessary



More information about the adegenet-commits mailing list