[adegenet-commits] r1105 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Apr 5 15:03:25 CEST 2013


Author: jombart
Date: 2013-04-05 15:03:25 +0200 (Fri, 05 Apr 2013)
New Revision: 1105

Modified:
   pkg/R/sequences.R
Log:
Adjusted behaviour for rare alleles

Modified: pkg/R/sequences.R
===================================================================
--- pkg/R/sequences.R	2013-04-05 12:48:01 UTC (rev 1104)
+++ pkg/R/sequences.R	2013-04-05 13:03:25 UTC (rev 1105)
@@ -36,10 +36,9 @@
         vec <- as.character(locus)
         vec[!vec %in% exp.char] <- NA
         N <- sum(!is.na(vec)) # N: number of sequences
-        if(N==0) return(NULL) # escape if untyped locus
-        alleles <- names(which(table(vec)/N >= polyThres ))
-        if(length(alleles)<2) return(NULL) # escape if no polymorphism
-        vec[!vec %in% alleles] <- NA
+        if(N==0 || sum(table(vec)/N >= polyThres )<2) return(NULL) # escape if untyped locus or no SNPs
+        alleles <- unique(na.omit(vec))
+        ## vec[!vec %in% alleles] <- NA # this would replace rare alleles by NAs
         out <- sapply(alleles, function(e) 1*(vec==e))
         colnames(out) <- paste(posi, alleles, sep=".")
         return(out)



More information about the adegenet-commits mailing list