[adegenet-commits] r784 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 26 16:59:54 CET 2011


Author: jombart
Date: 2011-01-26 16:59:54 +0100 (Wed, 26 Jan 2011)
New Revision: 784

Modified:
   pkg/R/SNPbin.R
   pkg/R/import.R
Log:
Now being more clever when reading messed up data: erroneous info is stored in $other, so that one can figure out what's wrong after reading the data in.


Modified: pkg/R/SNPbin.R
===================================================================
--- pkg/R/SNPbin.R	2011-01-26 15:36:32 UTC (rev 783)
+++ pkg/R/SNPbin.R	2011-01-26 15:59:54 UTC (rev 784)
@@ -148,7 +148,7 @@
 
     x <- .Object
     input <- list(...)
-    if(length(input)==1) names(input) <- "gen"
+    if(length(input)==1 && is.null(names(input))) names(input) <- "gen"
 
 
     ## HANDLE INPUT$GEN ##
@@ -309,9 +309,16 @@
             }
         }
 
+
     } # end if non-empty @gen
 
 
+    ## HANDLE INPUT$OTHER ##
+    if(!is.null(input$other)){
+        x at other <- input$other
+    }
+
+
     ## RETURN OBJECT ##
     names(x at gen) <- NULL # do not store ind.names twice
     return(x)

Modified: pkg/R/import.R
===================================================================
--- pkg/R/import.R	2011-01-26 15:36:32 UTC (rev 783)
+++ pkg/R/import.R	2011-01-26 15:59:54 UTC (rev 784)
@@ -841,6 +841,7 @@
 
     n.loc <- unique(sapply(res, nLoc))
     n.ind <- length(res)
+    other <- list()
 
     if(length(n.loc)>1) {
         print(n.loc)
@@ -848,24 +849,29 @@
     }
 
     if(!is.null(misc.info$position) && length(misc.info$position)!=n.loc) {
+        other$position <- misc.info$position
         misc.info$position <- NULL
-        warning("vector of positions of the SNPs does not match the number of SNPs - ignoring this information")
+        warning("vector of positions of the SNPs does not match the number of SNPs - storing this information in @other")
     }
     if(!is.null(misc.info$allele) && length(misc.info$allele)!=n.loc) {
+        other$allele <- misc.info$allele
         misc.info$allele <- NULL
-        warning("vector of alleles of the SNPs does not match the number of SNPs - ignoring this information")
+        warning("vector of alleles of the SNPs does not match the number of SNPs - storing this information in @other")
     }
     if(!is.null(misc.info$chromosome) && length(misc.info$chromosome)!=n.loc) {
+        other$chromosome <- misc.info$chromosome
         misc.info$chromosome <- NULL
-        warning("vector of chromosomes of the SNPs does not match the number of SNPs - ignoring this information")
+        warning("vector of chromosomes of the SNPs does not match the number of SNPs - storing this information in @other")
     }
     if(!is.null(misc.info$population) && length(misc.info$population)!=n.ind) {
+        other$population <- misc.info$population
         misc.info$population <- NULL
-        warning("vector of population of the individuals does not match the number of individuals - ignoring this information")
+        warning("vector of population of the individuals does not match the number of individuals - storing this information in @other")
     }
     if(!is.null(misc.info$ploidy) && length(misc.info$ploidy)>1 && length(misc.info$ploidy)!=n.ind) {
-        isc.info$ploidy <- NULL
-        warning("vector of ploidy of the individuals has more than one value but does not match the number of individuals - ignoring this information")
+        other$ploidy <- misc.info$ploidy
+        misc.info$ploidy <- NULL
+        warning("vector of ploidy of the individuals has more than one value but does not match the number of individuals - storing this information in @other")
     }
 
 



More information about the adegenet-commits mailing list