annotate Procrustes.R @ 13:fc4bc4ab91b7 draft

Uploaded
author mb2013
date Tue, 20 May 2014 03:28:13 -0400
parents 064592f816c6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
064592f816c6 Uploaded
mb2013
parents:
diff changeset
1 #Procrustes tool for performing procrustes analysis on landmark data
064592f816c6 Uploaded
mb2013
parents:
diff changeset
2 #MB
064592f816c6 Uploaded
mb2013
parents:
diff changeset
3
064592f816c6 Uploaded
mb2013
parents:
diff changeset
4 #commandline arguments
064592f816c6 Uploaded
mb2013
parents:
diff changeset
5 args <- commandArgs(TRUE)
064592f816c6 Uploaded
mb2013
parents:
diff changeset
6 #input
064592f816c6 Uploaded
mb2013
parents:
diff changeset
7 input <- args[1]
064592f816c6 Uploaded
mb2013
parents:
diff changeset
8 nb_landmarks <- args[2]
064592f816c6 Uploaded
mb2013
parents:
diff changeset
9 nb_dimension <- 3
064592f816c6 Uploaded
mb2013
parents:
diff changeset
10 output <- args[3]
064592f816c6 Uploaded
mb2013
parents:
diff changeset
11 outputcentroid <- args[4]
064592f816c6 Uploaded
mb2013
parents:
diff changeset
12
064592f816c6 Uploaded
mb2013
parents:
diff changeset
13 #package geomorph
064592f816c6 Uploaded
mb2013
parents:
diff changeset
14 suppressMessages(library("geomorph"))
064592f816c6 Uploaded
mb2013
parents:
diff changeset
15
064592f816c6 Uploaded
mb2013
parents:
diff changeset
16 #reading input file (landmark coordinates)
064592f816c6 Uploaded
mb2013
parents:
diff changeset
17 read <- read.csv(file <- input,header = FALSE)
064592f816c6 Uploaded
mb2013
parents:
diff changeset
18
064592f816c6 Uploaded
mb2013
parents:
diff changeset
19 #creating good array with arrayspecs
064592f816c6 Uploaded
mb2013
parents:
diff changeset
20 new_array <- arrayspecs(read,as.integer(nb_landmarks),as.integer(nb_dimension))
064592f816c6 Uploaded
mb2013
parents:
diff changeset
21
064592f816c6 Uploaded
mb2013
parents:
diff changeset
22 #perform procrustes with gpagen
064592f816c6 Uploaded
mb2013
parents:
diff changeset
23 output_procrustes <- gpagen(A=new_array, ShowPlot= FALSE)
064592f816c6 Uploaded
mb2013
parents:
diff changeset
24 #turn array for PCA
064592f816c6 Uploaded
mb2013
parents:
diff changeset
25 output_procrustes_coo <- t(two.d.array(output_procrustes$coords))
064592f816c6 Uploaded
mb2013
parents:
diff changeset
26 #output procrustes coordinates
064592f816c6 Uploaded
mb2013
parents:
diff changeset
27 write.csv(output_procrustes_coo,output, row.names = FALSE)
064592f816c6 Uploaded
mb2013
parents:
diff changeset
28 #output procrustes centroid size
064592f816c6 Uploaded
mb2013
parents:
diff changeset
29 write.csv(output_procrustes$Csize,outputcentroid, row.names = FALSE)