[adegenet-commits] r277 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 1 13:26:54 CEST 2009


Author: jombart
Date: 2009-04-01 13:26:54 +0200 (Wed, 01 Apr 2009)
New Revision: 277

Modified:
   pkg/R/basicMethods.R
Log:
fixed summary genind for PA 


Modified: pkg/R/basicMethods.R
===================================================================
--- pkg/R/basicMethods.R	2009-04-01 11:07:15 UTC (rev 276)
+++ pkg/R/basicMethods.R	2009-04-01 11:26:54 UTC (rev 277)
@@ -126,20 +126,44 @@
 ############################
 setMethod ("summary", "genind", function(object, ...){
   x <- object
-  if(!inherits(x,"genind")) stop("To be used with a genind object")
+  if(!is.genind(x)) stop("Provided object is not a valid genind.")
+
+
   if(is.null(x at pop)){
     x at pop <- factor(rep(1,nrow(x at tab)))
     x at pop.names <- ""
     names(x at pop.names) <- "P1"
   }
 
+  ## BUILD THE OUTPUT ##
+  ## type-independent stuff
   res <- list()
 
   res$N <- nrow(x at tab)
 
   res$pop.eff <- as.numeric(table(x at pop))
-  names(res$pop.eff) <- names(x at pop.names)
+  names(res$pop.eff) <- x at pop.names
 
+  ## PA case ##
+  if(x at type=="PA"){
+      ## % of missing data
+      res$NA.perc <- 100*sum(is.na(x at tab))/prod(dim(x at tab))
+
+      ## display and return
+      listlab <- c("# Total number of genotypes: ",
+                   "# Population sample sizes: ",
+                   "# Percentage of missing data: ")
+      cat("\n",listlab[1],res[[1]],"\n")
+      for(i in 2:3){
+          cat("\n",listlab[i],"\n")
+          print(res[[i]])
+      }
+
+      return(invisible(res))
+  }
+
+
+  ## codom case ##
   res$loc.nall <- x at loc.nall
 
   temp <- genind2genpop(x,quiet=TRUE)@tab



More information about the adegenet-commits mailing list