[adegenet-commits] r282 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 1 15:45:47 CEST 2009


Author: jombart
Date: 2009-04-01 15:45:47 +0200 (Wed, 01 Apr 2009)
New Revision: 282

Modified:
   pkg/R/handling.R
Log:
Commented out the isPoly for genpop object... it doesn't make much sense.


Modified: pkg/R/handling.R
===================================================================
--- pkg/R/handling.R	2009-04-01 13:26:56 UTC (rev 281)
+++ pkg/R/handling.R	2009-04-01 13:45:47 UTC (rev 282)
@@ -545,11 +545,22 @@
 setMethod("isPoly", signature(x="genind"), function(x, by=c("locus","allele"), thres=1/100){
 
     ## misc checks
-    checkType(x)
+    ## checkType(x)
     if(!is.genind(x)) stop("x is not a valid genind object")
     by <- match.arg(by)
 
-    ## main computations
+
+    ## main computations ##
+
+    ## PA case ##
+    if(x at type=="PA") {
+        allNb <- apply(x at tab, 2, mean, na.rm=TRUE) # allele frequencies
+        toKeep <- (allNb >= thres) & (allNb <= (1-thres))
+        return(toKeep)
+    }
+
+
+    ## codom case ##
     allNb <- apply(x at tab, 2, sum, na.rm=TRUE) # allele absolute frequencies
 
     if(by=="locus"){
@@ -580,7 +591,17 @@
     if(!is.genpop(x)) stop("x is not a valid genind object")
     by <- match.arg(by)
 
-    ## main computations
+
+    ## main computations ##
+    ## PA case ##
+    if(x at type=="PA") {
+        allNb <- apply(x at tab, 2, mean, na.rm=TRUE) # allele frequencies
+        toKeep <- (allNb >= thres) & (allNb <= (1-thres))
+        return(toKeep)
+    }
+
+
+    ## codom case ##
     allNb <- apply(x at tab, 2, sum, na.rm=TRUE) # alleles absolute frequencies
 
     if(by=="locus"){



More information about the adegenet-commits mailing list