Aligning the specimens and sliding the semi-landmarks (Generalized Procrustes Superimposistion)

-make sure the geomorph package is loaded in R

Import the .nts files for all  specimens:

make sure R is in the working directory of all the landmark files
filelist <- list.files(pattern = ".nts")
specimens <- readmulti.nts(filelist)


filelist:
[1] "morton1103ply_flipped.nts"       "morton1103ply.nts"            
 [3] "morton1188ply_flipped.nts"       "morton1188ply.nts"            
 [5] "morton1192ply_flipped.nts"       "morton1192ply.nts"            
 [7] "morton1306ply_flipped.nts"       "morton1306ply.nts"            
 [9] "morton1306plyerror_flipped.nts"  "morton1306plyerror.nts"      
[11] "morton1306plyerror2_flipped.nts" "morton1306plyerror2.nts"      
[13] "morton1319ply_flipped.nts"       "morton1319ply.nts"            
[15] "morton1329ply_flipped.nts"       "morton1329ply.nts"            
[17] "morton1486ply_flipped.nts"       "morton1486ply.nts"            
[19] "morton1973ply_flipped.nts"       "morton1973ply.nts"            
[21] "morton25ply_flipped.nts"         "morton25ply.nts"              
[23] "morton413ply_flipped.nts"        "morton413ply.nts"            
[25] "morton422ply_flipped.nts"        "morton422ply.nts"            
[27] "morton432ply_flipped.nts"        "morton432ply.nts"            
[29] "morton434ply_flipped.nts"        "morton434ply.nts"            
[31] "morton451ply_flipped.nts"        "morton451ply.nts"            
[33] "morton51ply_flipped.nts"         "morton51ply.nts"              
[35] "morton547ply_flipped.nts"        "morton547ply.nts"            
[37] "morton631ply_flipped.nts"        "morton631ply.nts"            
[39] "morton645ply_flipped.nts"        "morton645ply.nts"            
[41] "morton646ply_flipped.nts"        "morton646ply.nts"            
[43] "morton762ply_flipped.nts"        "morton762ply.nts"            
[45] "morton772ply_flipped.nts"        "morton772ply.nts"            
[47] "morton778ply_flipped.nts"        "morton778ply.nts"            
[49] "morton787ply_flipped.nts"        "morton787ply.nts"            
[51] "morton808ply_flipped.nts"        "morton808ply.nts"            
[53] "morton901ply_flipped.nts"        "morton901ply.nts"            
[55] "morton902ply_flipped.nts"        "morton902ply.nts"            
[57] "morton913ply_flipped.nts"        "morton913ply.nts"            
[59] "morton913plyerror_flipped.nts"   "morton913plyerror.nts"        
[61] "morton913plyerror2_flipped.nts"  "morton913plyerror2.nts"      
[63] "morton915ply_flipped.nts"        "morton915ply.nts"


curves <- as.matrix(read.csv("curveslide.csv", header=T))
sliders <- as.matrix(read.csv("surfslide.csv", header=T))

Generalized Procrustes Analysis

-first align the specimens without the semi=landmark sliding

gpaspecimens <- gpagen(specimens, Proj = TRUE, ProcD = TRUE, PrinAxes = TRUE, ShowPlot = TRUE)

-save the workspace now, R tends to crash at the next step
- slide the semi-landmarks

gpaspecimens_slid <- gpagen(gpaspecimens$coords, Proj = TRUE, ProcD = TRUE, PrinAxes = TRUE, ShowPlot = TRUE, curve = curves, surfaces = sliders)

Extract the new coordinates into a separeate variable:

gpaspecimens_slid_coords <- gpaspecimens_slid$coords


**ignore the variables that have the word error in them, they were for a test of the landmark placement error that was an incorrect method and not used in the analysis**

No comments:

Post a Comment