[adegenet-commits] r805 - in pkg: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 10 19:10:44 CET 2011


Author: jombart
Date: 2011-02-10 19:10:44 +0100 (Thu, 10 Feb 2011)
New Revision: 805

Modified:
   pkg/DESCRIPTION
   pkg/R/SNPbin.R
Log:
Corrected the [ method for genlight.
Is now immediate when subsetting only rows, fixed the all NAs rows and columns which used to be removed.


Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2011-02-10 15:22:01 UTC (rev 804)
+++ pkg/DESCRIPTION	2011-02-10 18:10:44 UTC (rev 805)
@@ -1,9 +1,9 @@
 Package: adegenet
-Version: 1.2-9
+Version: 1.3-0
 Date: 2010/11/05
 Title: adegenet: a R package for the multivariate analysis of genetic markers.
 Author:  Thibaut Jombart <t.jombart at imperial.ac.uk>
-  with contributions of: Peter Solymos, Francois Balloux
+  with contributions of: Ismail Ahmed, Peter Solymos, Francois Balloux
   and contributed datasets from: Katayoun Moazami-Goudarzi, Denis Laloe,
   Dominique Pontier, Daniel Maillard, Francois Balloux
 Maintainer: Thibaut Jombart <t.jombart at imperial.ac.uk>

Modified: pkg/R/SNPbin.R
===================================================================
--- pkg/R/SNPbin.R	2011-02-10 15:22:01 UTC (rev 804)
+++ pkg/R/SNPbin.R	2011-02-10 18:10:44 UTC (rev 805)
@@ -584,12 +584,11 @@
 
 
 
-## lightgen
 setMethod("[", signature(x="genlight", i="ANY", j="ANY", drop="ANY"), function(x, i, j, ...) {
     if (missing(i)) i <- TRUE
     if (missing(j)) j <- TRUE
 
-    ## subset individuals
+    ## SUBSET INDIVIDUALS ##
     x at gen <- x at gen[i]
     x at ind.names <- x at ind.names[i]
     if(!is.null(x at ploidy)) {
@@ -598,13 +597,13 @@
         ori.ploidy <- NULL
     }
 
-    ## subset loci
-    x <- as.matrix(x)[, j, drop=FALSE]
-    x <- x[!apply(x, 1, function(e) all(is.na(e))), , drop=FALSE] # remove indiv that are all NAs
-    x <- x[, !apply(x, 2, function(e) all(is.na(e))), drop=FALSE] # remove loci that are all NAs
-
-    x <- new("genlight", gen=x, ploidy=ori.ploidy)
-
+    ## SUBSET LOCI ##
+    if(length(j)==1 && is.logical(j) && j){ # no need to subset SNPs
+        return(x)
+    } else { # need to subset SNPs
+        x <- as.matrix(x)[, j, drop=FALSE]
+        x <- new("genlight", gen=x, ploidy=ori.ploidy)
+    }
     return(x)
 }) # end [] for SNPbin
 



More information about the adegenet-commits mailing list