[adegenet-commits] r283 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 1 15:46:35 CEST 2009
Author: jombart
Date: 2009-04-01 15:46:35 +0200 (Wed, 01 Apr 2009)
New Revision: 283
Modified:
pkg/R/handling.R
Log:
Data handling is fine with PA.
Modified: pkg/R/handling.R
===================================================================
--- pkg/R/handling.R 2009-04-01 13:45:47 UTC (rev 282)
+++ pkg/R/handling.R 2009-04-01 13:46:35 UTC (rev 283)
@@ -583,42 +583,42 @@
-## genpop method ##
-setMethod("isPoly", signature(x="genpop"), function(x, by=c("locus","allele"), thres=1/100){
+## ## genpop method ##
+## setMethod("isPoly", signature(x="genpop"), function(x, by=c("locus","allele"), thres=1/100){
- ## misc checks
- checkType(x)
- if(!is.genpop(x)) stop("x is not a valid genind object")
- by <- match.arg(by)
+## ## misc checks
+## checkType(x)
+## if(!is.genpop(x)) stop("x is not a valid genind object")
+## by <- match.arg(by)
- ## 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)
- }
+## ## 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
+## ## codom case ##
+## allNb <- apply(x at tab, 2, sum, na.rm=TRUE) # alleles absolute frequencies
- if(by=="locus"){
- f1 <- function(vec){
- if(sum(vec) < 1e-10) return(FALSE)
- vec <- vec/sum(vec, na.rm=TRUE)
- if(sum(vec >= thres) >= 2) return(TRUE)
- return(FALSE)
- }
+## if(by=="locus"){
+## f1 <- function(vec){
+## if(sum(vec) < 1e-10) return(FALSE)
+## vec <- vec/sum(vec, na.rm=TRUE)
+## if(sum(vec >= thres) >= 2) return(TRUE)
+## return(FALSE)
+## }
- toKeep <- tapply(allNb, x at loc.fac, f1)
- } else { # i.e. if mode==allele
- toKeep <- allNb >= thres
- }
+## toKeep <- tapply(allNb, x at loc.fac, f1)
+## } else { # i.e. if mode==allele
+## toKeep <- allNb >= thres
+## }
- return(toKeep)
-}) # end isPoly
+## return(toKeep)
+## }) # end isPoly
More information about the adegenet-commits
mailing list