Minor differences in gpagen for .nts and Morphologika file format and a typo in geomroph user manual

160 views
Skip to first unread message

lv xiao

unread,
Dec 27, 2017, 12:24:16 AM12/27/17
to geomorph R package
Dear all,

I have 10 3D coordinates in both .nts and Morphologika format, both of which are exported from Checkpoint software. I performed GPA separately for the two file types:

library(geomorph)
library
(abind)

################################################################################
#            Import data in .nts format                                        #
################################################################################


#Extract .nts file name (only file name, not content is included in filelist)
filelist_nts
<- Sys.glob(file.path("C:\\Users\\Patrick\\Desktop\\nose", "*.nts"))


#Read mulitiple .nts files
mydata_nts
<- readmulti.nts(filelist_nts)


#Concatenate the .nts files and convert into 3D matrix
dat_3dmat_nts
<- NULL


for (i in 1:length(filelist_nts)) {
 dat_3dmat_nts
[[i]] <- matrix(mydata_nts[,,1], 31, 3, byrow = T)
}
#Note: 31 is the total number of landmarks


#Convert 3D matrix to 3D array
dat_3d_nts
<- array(, dim = c(31, 3, length(filelist_nts)))


for (i in 1:length(filelist_nts)) {
    dat_3d_nts
[,,i] <- abind(dat_3dmat_nts[[i]],along=3)
}


#GPA
surfslide
<- matrix(7:31) #landmark 7 to 31 are semilandmarks
dat
.gpa_nts = gpagen(dat_3d_nts, surfaces=surfslide)

################################################################################
#            Import data in Morphologika format                                #
################################################################################
#Extract .nts file name (only file name, not content is included in filelist)
filelist
<- Sys.glob(file.path("C:\\Users\\Patrick\\Desktop\\nose", "*.txt"))


#Read mulitiple .nts files
source
("read.multi.morphologika.R")
mydata
<- read.multi.morphologika(filelist)


#GPA
surfslide
<- matrix(7:31) #landmark 7 to 31 are semilandmarks
dat
.gpa = gpagen(mydata, surfaces=surfslide)

################################################################################
#                       Comparison of results                                  #
################################################################################
summary
(dat.gpa_nts)


Call:
gpagen
(A = dat_3d_nts, surfaces = surfslide)

Generalized Procrustes Analysis
with Partial Procrustes Superimposition


6 fixed landmarks
25 semilandmarks (sliders)
3-dimensional landmarks
3 GPA iterations to converge
Minimized squared Procrustes Distance used

Consensus (mean) Configuration


                 X            Y            Z
 
[1,]  0.149033026  0.161431665 -0.069663734
 
[2,]  0.165411723 -0.143059241  0.005752025
 
[3,]  0.214278642  0.122338393 -0.091593120
 
[4,]  0.235672465 -0.004419269 -0.015677844
 
[5,]  0.222846649 -0.152249528 -0.095393508
 
[6,]  0.165342880  0.016867304  0.110490576
 
[7,] -0.195549396 -0.083873997 -0.015896968
 
[8,] -0.132579520 -0.113336644 -0.031600202
 
[9,] -0.068919107 -0.146265347 -0.041783286
[10,] -0.005390720 -0.177165080 -0.053960341
[11,]  0.057082971 -0.206407110 -0.072070823
[12,] -0.192582003 -0.036197029  0.016465332
[13,] -0.128714822 -0.044099393  0.030119063
[14,] -0.053189589 -0.054101381  0.046582825
[15,]  0.036912094 -0.064068698  0.055568884
[16,]  0.180015742 -0.067938060  0.064715446
[17,] -0.189943930  0.008119313  0.018792057
[18,] -0.117102936  0.015301704  0.040610894
[19,] -0.044380559  0.021057274  0.067256631
[20,]  0.031057942  0.021850685  0.090763046
[21,]  0.109220293  0.017857593  0.110360449
[22,] -0.187993137  0.046058193 -0.006349508
[23,] -0.119396917  0.055065844  0.007909814
[24,] -0.043604826  0.068361901  0.023935634
[25,]  0.040634536  0.079696374  0.037845562
[26,]  0.177882004  0.096560531  0.036552103
[27,] -0.188969277  0.085184924 -0.049879151
[28,] -0.125109675  0.100036634 -0.050361938
[29,] -0.061828200  0.117576676 -0.049834030
[30,]  0.002428279  0.126734998 -0.056373524
[31,]  0.067435366  0.133080770 -0.063282364


> summary(dat.gpa)

Call:
gpagen
(A = mydata, surfaces = surfslide)

Generalized Procrustes Analysis
with Partial Procrustes Superimposition


6 fixed landmarks
25 semilandmarks (sliders)
3-dimensional landmarks
6 GPA iterations to converge
Minimized squared Procrustes Distance used


Consensus (mean) Configuration

                 X             Y             Z
 
[1,]  0.142753284 -0.1902803428 -0.0669980866
 
[2,]  0.175804956  0.1615797704 -0.0487901736
 
[3,]  0.224785788 -0.1530122156 -0.0601337896
 
[4,]  0.254383925 -0.0152623782  0.0056141688
 
[5,]  0.246757348  0.1343512987 -0.0648858979
 
[6,]  0.152628612 -0.0080163116  0.1177992640
 
[7,] -0.172629294  0.0922175011 -0.0160502255
 
[8,] -0.106171022  0.1119059992 -0.0283509674
 
[9,] -0.040360229  0.1342891324 -0.0383863705
[10,]  0.027582259  0.1535492310 -0.0466090724
[11,]  0.096331530  0.1761425940 -0.0615396429
[12,] -0.180623122  0.0550733585  0.0082337282
[13,] -0.134718451  0.0558534680  0.0142758715
[14,] -0.067738050  0.0625716711  0.0260129904
[15,]  0.027064589  0.0700470545  0.0458877968
[16,]  0.199552303  0.0745183023  0.0556386666
[17,] -0.183417803  0.0078609803  0.0128126960
[18,] -0.137061282  0.0002462614  0.0227331217
[19,] -0.085389117 -0.0021160162  0.0369784295
[20,] -0.003992894 -0.0054926905  0.0729222120
[21,]  0.076389564 -0.0090757372  0.0970901184
[22,] -0.184774608 -0.0367797656 -0.0044709913
[23,] -0.140935271 -0.0444924350 -0.0005256126
[24,] -0.076955875 -0.0597173925  0.0065516108
[25,]  0.015476885 -0.0762898517  0.0339576579
[26,]  0.181775646 -0.1033123336  0.0538462289
[27,] -0.187086784 -0.0756390871 -0.0359902119
[28,] -0.127328979 -0.0948627683 -0.0375288621
[29,] -0.067857881 -0.1173792357 -0.0382772212
[30,] -0.006116685 -0.1342381834 -0.0405331426
[31,]  0.058139656 -0.1495650366 -0.0443285292

It can be seen that there are slight differences in mean configurations. May I please ask does this difference have an impact on the results of analysis and why would there be such slight difference?

By the way, I noted that in page 19 of Quick Guide to geomorph 3.0.5 7 August 2017, the following snippet of code:
source("read.multi.morphologika.R")
filelist <- list.files(pattern = "*.txt") ## list all morpholgika files
mydata <- read.multi.morphologika("morphologikaexample.txt")
was used to import multiple Morphologika files that each contain a single specimen. However, a filelist instead of a  single file should be included as the argument for read.multi.morphologika function. The correct code should be:
source("read.multi.morphologika.R")
filelist
<- list.files(pattern = "*.txt") ## list all morpholgika files
mydata
<- read.multi.morphologika(filelist)

Thank you!



Sample in Morphologika format.rar
Sample in nts format.rar

Mike Collyer

unread,
Dec 27, 2017, 9:12:26 AM12/27/17
to geomorph-...@googlegroups.com
Did you check to make sure that dat_3dmat_nts and mydata were the same?  The gpagen is not doing anything different but if different data are provided, different results will ensue.  It seems that your manipulations to get to the data needed for GPA is what caused the discrepancy.  To answer your question, yes, this is an issue.  If you are making conclusions on data analysis for data that is not appropriate, your conclusions could be inappropriate too.  

Hope that helps
Mike

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/1ecd15b5-e1b9-4328-899f-0b979c20d3f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Sample in Morphologika format.rar><Sample in nts format.rar>

lv xiao

unread,
Dec 27, 2017, 10:19:10 AM12/27/17
to geomorph R package
Hi, thank you Dr. Mike. I did note a typo in my code, which resulted in slightly different results. The code dat_3dmat_nts[[i]] <- matrix(mydata_nts[,,1], 31, 3, byrow = T) should be changed to dat_3dmat_nts[[i]] <- matrix(mydata_nts[,,i], 31, 3, byrow = T)!
Mike

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages