[adegenet-commits] r776 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 24 19:24:38 CET 2011


Author: jombart
Date: 2011-01-24 19:24:37 +0100 (Mon, 24 Jan 2011)
New Revision: 776

Modified:
   pkg/R/SNPbin.R
   pkg/R/import.R
Log:
A few changes to read.snp: replaced some 'stop' with warnings.


Modified: pkg/R/SNPbin.R
===================================================================
--- pkg/R/SNPbin.R	2011-01-24 17:55:06 UTC (rev 775)
+++ pkg/R/SNPbin.R	2011-01-24 18:24:37 UTC (rev 776)
@@ -28,8 +28,9 @@
                                     loc.names = "charOrNULL",
                                     loc.all = "charOrNULL",
                                     ploidy = "intOrNULL",
+                                    pop = "factorOrNULL",
                                     other = "list"),
-         prototype(gen = list(), n.loc = integer(0), ind.names = NULL, loc.names = NULL, loc.all = NULL, ploidy=NULL, other=list()))
+         prototype(gen = list(), n.loc = integer(0), ind.names = NULL, loc.names = NULL, loc.all = NULL, ploidy=NULL, pop=NULL, other=list()))
 
 
 
@@ -297,6 +298,17 @@
             }
         }
 
+        
+        ## HANDLE INPUT$POP ##
+        if(!is.null(input$pop)){
+            ## check length consistency
+            if(length(input$pop) != nInd(x)){
+                warning("Inconsistent length for pop - ignoring this argument.")
+            } else {
+                x at pop <- factor(pop)
+            }
+        }
+
     } # end if non-empty @gen
 
 

Modified: pkg/R/import.R
===================================================================
--- pkg/R/import.R	2011-01-24 17:55:06 UTC (rev 775)
+++ pkg/R/import.R	2011-01-24 18:24:37 UTC (rev 776)
@@ -805,14 +805,29 @@
 
     if(length(n.loc)>1) {
         print(n.loc)
-        stop("Differing numbers of loci detected between individuals.")
+        warning("!!! Differing numbers of loci detected between individuals !!!")
     }
 
-    if(!is.null(misc.info$position) && length(misc.info$position)!=n.loc) stop("vector of positions of the SNPs does not match the number of SNPs")
-    if(!is.null(misc.info$allele) && length(misc.info$allele)!=n.loc) stop("vector of alleles of the SNPs does not match the number of SNPs")
-    if(!is.null(misc.info$chromosome) && length(misc.info$chromosome)!=n.loc) stop("vector of chromosomes of the SNPs does not match the number of SNPs")
-    if(!is.null(misc.info$population) && length(misc.info$population)!=n.ind) stop("vector of population of the individuals does not match the number of individuals")
-    if(!is.null(misc.info$ploidy) && length(misc.info$ploidy)>1 && length(misc.info$ploidy)!=n.ind) stop("vector of ploidy of the individuals has more than one value but does not match the number of individuals")
+    if(!is.null(misc.info$position) && length(misc.info$position)!=n.loc) {
+        misc.info$position <- NULL
+        warning("vector of positions of the SNPs does not match the number of SNPs - ignoring this information")
+    }
+    if(!is.null(misc.info$allele) && length(misc.info$allele)!=n.loc) {
+        misc.info$allele <- NULL
+        warning("vector of alleles of the SNPs does not match the number of SNPs - ignoring this information")
+    }
+    if(!is.null(misc.info$chromosome) && length(misc.info$chromosome)!=n.loc) {
+        misc.info$chromosome <- NULL
+        warning("vector of chromosomes of the SNPs does not match the number of SNPs - ignoring this information")
+    }
+    if(!is.null(misc.info$population) && length(misc.info$population)!=n.ind) {
+        misc.info$population <- NULL
+        warning("vector of population of the individuals does not match the number of individuals - ignoring this information")
+    }
+    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")
+    }
 
 
     ## BUILD OUTPUT ##
@@ -825,7 +840,7 @@
         other <- list()
     }
 
-    res <- new("genlight", gen=res, ind.names=ind.names, loc.names=misc.info$position, loc.all=misc.info$allele, ploidy=misc.info$ploidy, other=other)
+    res <- new("genlight", gen=res, ind.names=ind.names, loc.names=misc.info$position, loc.all=misc.info$allele, ploidy=misc.info$ploidy, pop=misc.info$population, other=other)
 
     if(!quiet) cat("\n...done.\n\n")
 



More information about the adegenet-commits mailing list