Seemingly different results from Morpho and geomorph on the same dataset 1 post by 1 author

52 views
Skip to first unread message

lv xiao

unread,
May 10, 2020, 2:54:15 PM5/10/20
to geomorph R package
Using boneLM dataset from Morpho package, I performed GPA using Morpho and geomroph package but found that the results differ.

library(Morpho)
library(geomorph)

require(rgl)
data(boneData)

################################################################################
# Ignoring symmetry
################################################################################
# GPA in Morpho using ProcGPA
procM <- ProcGPA(boneLM, scale = TRUE, reflection = TRUE, CSinit = TRUE,  
 pcAlign = TRUE)
dat1 <- procM$rotated

# GPA in geomorph using gpagen
procG <- gpagen(boneLM, ProcD = FALSE, Proj = TRUE)
dat2 <- procG$coords

# Angle calculation
AngleFromMorpho <- c(t(dat1[,,1])) - c(t(dat1[,,3]))
AngleFromGeomorph <- c(t(dat2[,,1])) - c(t(dat2[,,3]))
angle.calc(AngleFromMorpho, AngleFromGeomorph) * (180/pi)
# [1] 126.6105 #The direction representing shape difference between specimen 1 and 3 calculated from both packages differ by 126 degrees. Not in the same direction!

################################################################################
# Considering the symmetric component
################################################################################
# GPA in Morpho using procSym
left <- c(4,6,8)
right <- c(3,5,7)
pairedLM <- cbind(left,right)
symprocM <- procSym(boneLM, scale = TRUE, reflect = TRUE, CSinit = TRUE,
   orp = TRUE, pairedLM = pairedLM, bending = TRUE, 
   pcAlign = TRUE)
dat3 <- symprocM$Symtan

# GPA in geomorph using bilat.symmetry
symprocG <- bilat.symmetry(boneLM, land.pairs = pairedLM, object.sym = TRUE, 
      ind = 1:dim(boneLM)[3])
dat4 <- symprocG$symm.shape

# Angle calculation
AngleFromMorpho2 <- c(t(dat3[1,])) - c(t(dat3[3,]))
AngleFromGeomorph2 <- c(t(dat4[,,1])) - c(t(dat4[,,3]))
angle.calc(AngleFromMorpho2, AngleFromGeomorph2) * (180/pi)
# [1] 95.43279 #The direction representing symmetric component of shape difference between specimen 1 and 3 calculated from both packages differ by 95 degrees. Not in the same direction!


I have set orthogonal projection in both functions and also using bending energy as the criteria for minimization. However, the direction representing shape difference from the 1st and 3rd specimen calculated from the two packages differ by 126 degrees for total shape and by 95 degrees for the symmetric component. The differences are obviously not trivial. So how should we perceive such difference?

Regards,
Lv

Murat Maga

unread,
May 10, 2020, 3:36:58 PM5/10/20
to geomorph R package
I don't with symmetry analysis much, but doesn't geomorph::bilat.symmetry require GPA fitted coordinates as input?

Mike Collyer

unread,
May 10, 2020, 3:46:24 PM5/10/20
to geomorph-...@googlegroups.com
I ran you first example and got an angle of:
 > angle.calc(AngleFromMorpho, AngleFromGeomorph) * (180/pi)
[1] 6.05645

I get the same thing calculating this more “by hand”
> acos(RRPP:::vec.cor.matrix(rbind(as.vector(AngleFromGeomorph), as.vector(AngleFromMorpho))))*180/pi
        [,1]    [,2]
[1,] 0.00000 6.05645
[2,] 6.05645 0.00000

I also did this:
> two.b.pls(dat1, dat2)

Call:
two.b.pls(A1 = dat1, A2 = dat2) 



r-PLS: 1

P-value: 0.001

Effect Size: 11.9136

Based on 1000 random permutations

Data sets from the two GPAs are perfectly correlated.  I also plotted all specimens for each and got the following


It looks to me that the difference is because you used a full procrustes fit in one and partial in the other, which is probably trivial.  Also, I’m not sure if ProcGPA projects data into tangent space (when I changed Proj = FALSE for gpagen, the angle decreased a bit.

I applied your logic to all specimen 1 to specimen j vectors possible and confirmed that the angle is not a constant:

> L1 <- lapply(1:80, function(j) dat1[,,1] - dat1[,,j])
> L2 <- lapply(1:80, function(j) dat2[,,1] - dat2[,,j])
> unlist(Map(function(l1,l2) angle.calc(l1, l2) * 180/pi, L1, L2))
 [1]       NaN  9.865832  6.022882  7.807051 10.606452 10.418479 10.204809 10.286363  8.581027 10.486946
[11]  7.909168  7.780875  8.513055  9.698315  7.495479  9.717612  9.212518 10.883615  7.782530  9.557724
[21] 10.637266 10.083121  8.566128  9.186111 10.034336  8.519749  9.308942 10.836399 11.793672  8.957580
[31]  9.526284 10.629357 10.339176  8.497879  8.973746 10.699193  8.689414  7.155042  7.421062  8.095965
[41]  9.741411 11.509007  9.802505  9.116305 12.638174 11.953633 11.507306 11.762795 12.146291  8.087124
[51] 11.643558  9.733017 10.537742  8.206541  9.146253 11.761873 11.440937 11.857554 11.138740 12.577323
[61] 10.008671  8.864206  8.578276  9.035430  9.267385  8.640474  9.729710  9.137216 10.743659  9.653137
[71] 10.638879 10.243554  8.301272 10.608700 11.240292  9.419586  8.771738 10.840267  7.844298 11.557135

So I am do not know how to perceive this.  Strange that the different methods produce configurations that are perfectly correlated.  The vector angles have to scale configurations, which are apparently different size so the angles might correspond just to a difference in scale. But a certain explanation eludes me.

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 view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/9402944b-6a82-4c51-a9ed-7b57e5690004%40googlegroups.com.

Mike Collyer

unread,
May 10, 2020, 3:52:55 PM5/10/20
to geomorph R package
Murat,

bilat.symmetry can handle multiple inputs, including:


One of either A 3D array (p x k x n) containing raw landmarks (requiring GPA to be performed) or a gpagen object (if GPA has been previously performed) or a geomorphShapes object (requiring GPA to be performed). Any gpagen argument should work within bilat.symmetry.


Cheers!
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.

lv xiao

unread,
May 11, 2020, 1:32:09 PM5/11/20
to geomorph R package
Thank you Mike for your explanation. I performed my first example again and still got an angle of 126.6105 rather than 6.05645. Am I missing anything? I am on geomorph stable release version 3.2.1 and Morpho v2.8. Is it because of version differences?

As I know, the difference between full and partial procrustes fit is that the former involves scaling while the latter does not. I explicitly set scale to TRUE in ProcGPA in my example. Does this mean I performed full procrustes fit using ProcGPA and partial procrustes fit using gpagen? Is it possible to perform both in geomorph? How to decide which to choose? An additional question is does gpagen perform reflection procrustes? There is the reflection argument in ProcGPA but not in gpagen.

Thank you.

Lv
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.

Adams, Dean [EEOB]

unread,
May 11, 2020, 2:15:15 PM5/11/20
to geomorph-...@googlegroups.com

Lv, I think you missed a more important point form Mike’s email which was that the PLS correlation was 1.0.  That means, apart from a rotation, the resulting shapes are the same.  Thus, it doesn’t matter.


Dean

 

Dr. Dean C. Adams

Director of Graduate Education, EEB Program

Professor

Department of Ecology, Evolution, and Organismal Biology

Iowa State University

https://www.eeob.iastate.edu/faculty/adams/

phone: 515-294-3834

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.

 

--

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 view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/d2fca68f-6ad2-476e-9f8d-9ea496f30011%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages