annotate Csize_plot.R @ 13:fc4bc4ab91b7 draft

Uploaded
author mb2013
date Tue, 20 May 2014 03:28:13 -0400
parents f3b7f86db21e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
1 #The Csize tool creates a plot with a Principal Component
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
2 #and the centroid size (created with a procrustes analysis)
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
3 #MB
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
4
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
5
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
6 #commandline arguments
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
7 args <- commandArgs(TRUE)
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
8
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
9 #inputs
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
10 input_PCA <- args[1]
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
11 input_Csize <- args[2]
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
12 main_title <- args[3]
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
13 x_title <- args[4]
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
14 y_title <- args[5]
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
15 x_column <- args[6]
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
16 names <- args [7] #sample names in one file
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
17 output <- args[8]
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
18
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
19 #library geomorph
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
20 suppressMessages(library("geomorph"))
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
21 #reading of the input files
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
22 read <- read.csv(file <- input_PCA, header = TRUE) #principal components
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
23 read2 <- read.csv(file <- input_Csize, header = TRUE) #centroid size
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
24 read3 <- scan(file <- names, what = "", quiet = TRUE)
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
25 pca1 <- read[,as.integer(x_column)] #principal component
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
26 read2 <- read2[,1] #centroid size
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
27
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
28 #output
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
29 png(output)
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
30
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
31 #creating plot with pca and centroid size
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
32 suppressMessages(plot(pca1,read2, main = main_title, xlab = x_title, ylab = y_title, pch=20,cex=0.6))
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
33 #adding labels to datapoints
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
34 text(pca1,read2,labels = read3, pos = 3, cex = 0.6, col = 'red')
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
35
f3b7f86db21e Uploaded
mb2013
parents:
diff changeset
36 graphics.off()