11
|
1 #Procrustes tool for performing procrustes analysis on landmark data
|
|
2 #MB
|
|
3
|
|
4 #commandline arguments
|
|
5 args <- commandArgs(TRUE)
|
|
6 #input
|
|
7 input <- args[1]
|
|
8 nb_landmarks <- args[2]
|
|
9 nb_dimension <- 3
|
|
10 output <- args[3]
|
|
11 outputcentroid <- args[4]
|
|
12
|
|
13 #package geomorph
|
|
14 suppressMessages(library("geomorph"))
|
|
15
|
|
16 #reading input file (landmark coordinates)
|
|
17 read <- read.csv(file <- input,header = FALSE)
|
|
18
|
|
19 #creating good array with arrayspecs
|
|
20 new_array <- arrayspecs(read,as.integer(nb_landmarks),as.integer(nb_dimension))
|
|
21
|
|
22 #perform procrustes with gpagen
|
|
23 output_procrustes <- gpagen(A=new_array, ShowPlot= FALSE)
|
|
24 #turn array for PCA
|
|
25 output_procrustes_coo <- t(two.d.array(output_procrustes$coords))
|
|
26 #output procrustes coordinates
|
|
27 write.csv(output_procrustes_coo,output, row.names = FALSE)
|
|
28 #output procrustes centroid size
|
|
29 write.csv(output_procrustes$Csize,outputcentroid, row.names = FALSE)
|