[adegenet-commits] r847 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Mar 10 16:50:01 CET 2011


Author: jombart
Date: 2011-03-10 16:50:01 +0100 (Thu, 10 Mar 2011)
New Revision: 847

Modified:
   pkg/R/dapc.R
   pkg/R/find.clust.R
Log:
dudi argument handled by find.clusters


Modified: pkg/R/dapc.R
===================================================================
--- pkg/R/dapc.R	2011-03-10 11:15:16 UTC (rev 846)
+++ pkg/R/dapc.R	2011-03-10 15:50:01 UTC (rev 847)
@@ -34,15 +34,21 @@
     }
     cumVar <- 100 * cumsum(pcaX$eig)/sum(pcaX$eig)
 
+    if(!REDUCEDIM){
+        myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$li),length(pcaX$eig)))
+    } else {
+        myCol <- "black"
+    }
+
     ## select the number of retained PC for PCA
     if(is.null(n.pca) & pca.select=="nbEig"){
-        plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA")
+        plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol)
         cat("Choose the number PCs to retain (>=1): ")
         n.pca <- as.integer(readLines(n = 1))
     }
 
     if(is.null(perc.pca) & pca.select=="percVar"){
-        plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA")
+        plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol)
         cat("Choose the percentage of variance to retain (0-100): ")
         nperc.pca <- as.numeric(readLines(n = 1))
     }
@@ -229,23 +235,19 @@
 
 
     ## select the number of retained PC for PCA
+    if(!REDUCEDIM){
+        myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$scores),length(pcaX$eig)))
+    } else {
+        myCol <- "black"
+    }
+    
     if(is.null(n.pca) & pca.select=="nbEig"){
-        if(!REDUCEDIM){
-            myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$scores),length(pcaX$eig)))
-        } else {
-            myCol <- "black"
-        }
         plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol)
         cat("Choose the number PCs to retain (>=1): ")
         n.pca <- as.integer(readLines(n = 1))
     }
 
     if(is.null(perc.pca) & pca.select=="percVar"){
-        if(!REDUCEDIM){
-            myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$scores),length(pcaX$eig)))
-        } else {
-            myCol <- "black"
-        }
         plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol)
         cat("Choose the percentage of variance to retain (0-100): ")
         nperc.pca <- as.numeric(readLines(n = 1))

Modified: pkg/R/find.clust.R
===================================================================
--- pkg/R/find.clust.R	2011-03-10 11:15:16 UTC (rev 846)
+++ pkg/R/find.clust.R	2011-03-10 15:50:01 UTC (rev 847)
@@ -34,13 +34,14 @@
 
     ## SOME GENERAL VARIABLES ##
     N <- nrow(x)
+    REDUCEDIM <- is.null(dudi)
     min.n.clust <- 2
     max.n.clust <- max(max.n.clust, 2)
 
     ## PERFORM PCA ##
     maxRank <- min(dim(x))
 
-    if(is.null(dudi)){
+    if(REDUCEDIM){
         pcaX <- dudi.pca(x, center = center, scale = scale, scannf = FALSE, nf=maxRank)
     } else {
         if(!inherits(dudi,"dudi")) stop("dudi provided but is not a dudi object")
@@ -49,8 +50,13 @@
 
     ## select the number of retained PC for PCA
     if(is.null(n.pca)){
+        if(!REDUCEDIM){
+            myCol <- rep(c("black", "lightgrey"), c(ncol(pcaX$li),length(pcaX$eig)))
+        } else {
+            myCol <- "black"
+        }
         cumVar <- 100 * cumsum(pcaX$eig)/sum(pcaX$eig)
-        plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA")
+        plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA", col=myCol)
         cat("Choose the number PCs to retain (>=1): ")
         n.pca <- NA
         while(is.na(n.pca)){



More information about the adegenet-commits mailing list