[adegenet-commits] r155 - pkg/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jul 14 00:29:35 CEST 2008
Author: jombart
Date: 2008-07-14 00:29:35 +0200 (Mon, 14 Jul 2008)
New Revision: 155
Modified:
pkg/man/scale.Rd
Log:
added an interesting example to scaleGen doc (binomial scaling is great!)
Modified: pkg/man/scale.Rd
===================================================================
--- pkg/man/scale.Rd 2008-07-10 12:19:02 UTC (rev 154)
+++ pkg/man/scale.Rd 2008-07-13 22:29:35 UTC (rev 155)
@@ -47,7 +47,31 @@
}
\author{Thibaut Jombart \email{jombart at biomserv.univ-lyon1.fr} }
\examples{
+## load data
+data(microbov)
+obj <- genind2genpop(microbov)
+## compare different scaling
+X1 <- scaleGen(obj)
+X2 <- scaleGen(obj,met="bin")
+
+if(require(ade4)){
+## compute PCAs
+pcaObj <- dudi.pca(obj,scale=FALSE,scannf=FALSE) # pca with no scaling
+pcaX1 <- dudi.pca(X1,scale=FALSE,scannf=FALSE) # pca with usual scaling
+pcaX2 <- dudi.pca(X2,scale=FALSE,scannf=FALSE) # pca with scaling for binomial variance
+
+## change signs of loadings if needed
+if(cor(pcaX1$c1[,1],pcaX2$c1[,1]) < 0) {pcaX1$c1[,1] <- -pcaX1$c1[,1]}
+if(cor(pcaX1$c1[,2],pcaX2$c1[,2]) < 0) {pcaX1$c1[,2] <- -pcaX1$c1[,2]}
+
+## graphics
+par(mfrow=c(2,2))
+barplot(pcaObj$eig,main="Eigenvalues\n no scaling")
+barplot(pcaX1$eig,main="Eigenvalues\n usual scaling")
+barplot(pcaX2$eig,main="Eigenvalues\n 'binomial' scaling")
+s.match(pcaX1$c1,pcaX2$c1,clab=0,sub="usual -> binom")
}
+}
\keyword{methods}
\keyword{manip}
More information about the adegenet-commits
mailing list