# HG changeset patch # User mb2013 # Date 1400570797 14400 # Node ID 5aaede6275f941e580401c4a105066edde807191 # Parent 7012f7336e61131b59ebbbc6cb769f99d5bb772f Uploaded diff -r 7012f7336e61 -r 5aaede6275f9 PCA.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PCA.R Tue May 20 03:26:37 2014 -0400 @@ -0,0 +1,22 @@ +# The tool PCA creates a Principal Component Analysis on Procrustes coordinates. +# MB + +#commands of commandline +args <- commandArgs(TRUE) +#input file: procrustes coordinates +input <- args[1] +#output file +output <- args[2] +output2 <- args[3] + +#package geomorph +suppressMessages(library("geomorph")) + +#reading of coordinates +read <- read.csv(file <- input,header = TRUE) +#principal component analysis with princomp, using covariance matrix of coordinates +pca <- princomp(x=cov(read)) + +#output pca scores +write.csv(pca$scores,output, row.names = FALSE) +write.csv(pca$sdev, output2, row.names = FALSE)