[Genabel-commits] r2046 - in pkg/GenABEL: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 25 11:00:16 CET 2016


Author: lckarssen
Date: 2016-01-25 11:00:15 +0100 (Mon, 25 Jan 2016)
New Revision: 2046

Modified:
   pkg/GenABEL/ChangeLog
   pkg/GenABEL/R/impute2databel.R
Log:
Add 'snpfile' option to GenABEL's impute2databel()

Thanks to Matthias Wuttke for submitting the patch to the dev list (see http://lists.r-forge.r-project.org/pipermail/genabel-devel/2016-January/001337.html).


Modified: pkg/GenABEL/ChangeLog
===================================================================
--- pkg/GenABEL/ChangeLog	2016-01-20 09:35:09 UTC (rev 2045)
+++ pkg/GenABEL/ChangeLog	2016-01-25 10:00:15 UTC (rev 2046)
@@ -1,6 +1,9 @@
 *** v.
 ()
-
+- impute2databel() now accepts the option "snpfile", a file that contains
+  (short) SNP names. This is useful when using 1000 Genomes data with SNP
+  names that are (too) long for GenABEL/ProbABEL to handle. Thanks to
+  Matthias Wuttke for contributing this patch!
 - Fixed bug #6280: The convert.snp.affymetrix() function uses a
   system("ls") call, which doesn't work on MS Windows. We now use R's
   list.files() function, which is portable and works on all platforms.

Modified: pkg/GenABEL/R/impute2databel.R
===================================================================
--- pkg/GenABEL/R/impute2databel.R	2016-01-20 09:35:09 UTC (rev 2045)
+++ pkg/GenABEL/R/impute2databel.R	2016-01-25 10:00:15 UTC (rev 2046)
@@ -14,6 +14,7 @@
 #' @param old for developers' use only
 #' @param dataOutType the output data type, either "FLOAT" or "DOUBLE" (or
 #'        another DatABEL/filevector type)
+#' @param snpfile file with SNP names in each line (same order as columns in IMPUTE genotype file)
 #'
 #' @return 'databel-class' object
 #'
@@ -21,7 +22,7 @@
 
 
 impute2databel <- function(genofile, samplefile, outfile,
-                           makeprob = TRUE, old = FALSE, dataOutType = "FLOAT")
+                           makeprob = TRUE, old = FALSE, dataOutType = "FLOAT", snpfile = NA)
 {
   if (!require(DatABEL))
     stop("this function requires the DatABEL package to be installed")
@@ -36,6 +37,13 @@
       warning("The non-float dataOutType is not fully supported; your outputs may be in 'FLOAT'...",
               immediate. = TRUE);
 
+  rowNamesSetting = 2
+  if (!is.na(snpfile)) {
+    if (missing(snpfile))
+      stop("snpfile file not found")
+    rowNamesSetting = snpfile
+  }
+
   ## extract snp names (varnames)
   ## if (tmpname != "")
   ##     text2databel(infile=genofile,outfile=outfile,
@@ -47,7 +55,7 @@
   tmpname <- get_temporary_file_name()
   tmp_fv  <- text2databel(infile=genofile,
                           outfile=tmpname,
-                          rownames=2,
+                          rownames=rowNamesSetting,
                           skipcols=5,
                           ## skiprows,
                           transpose=TRUE,



More information about the Genabel-commits mailing list