geomorphR / geomorph

Geomorph is a software package for performing all stages of geometric morphometric shape analysis of landmark points and curves in 2-and-3-dimensions as well as 3D surfaces in the R statistical computing environment. This repository is dedicated to providing stable and beta versions between CRAN uploads
73 stars 20 forks source link

Procrustes residuals values and partial warp scores #17

Closed PhilGossieaux closed 5 years ago

PhilGossieaux commented 6 years ago

Hello everyone,

I am currently trying to extract partial warp scores from my data but I am really not sure about the right method to do so in geomorph. I am using the 3.0.6 version.

To better understand how partial warp scores are estimated, I am trying to get the Procrustes residuals. To do so, I first calculated Procrustes residuals by hand (consensus configuration - landmark coordinates). Here is an example with the plethodon data :

data(plethodon) Y.gpa <- gpagen(plethodon$land) # GPA-alignment Y.gpa$consensus - Y.gpa$coords[,,1] # Procrustes residuals for the first individual

Here are the results I obtain :

              X             Y

[1,] -0.0344125269 0.0007795351 [2,] -0.0173644760 -0.0024695930 [3,] -0.0013939463 -0.0121645486 [4,] -0.0054344476 -0.0015275652 [5,] 0.0042459454 0.0009465181 [6,] -0.0085043603 0.0175240242 [7,] 0.0246763774 -0.0015201942 [8,] -0.0117064381 -0.0093034324 [9,] 0.0046035509 -0.0045212382 [10,] 0.0027063193 0.0035193421 [11,] 0.0417190925 -0.0199987873 [12,] 0.0008649097 0.0287359394

Then, I used the $data function of gpagen (returns a data frame with an n x (pk) matrix of Procrustes residuals and centroid size) to verify my results as follows :

Y.gpa$data[1,]

and obtained :

coords.X.1 coords.Y.1 coords.X.2 coords.Y.2 coords.X.3 coords.Y.3 coords.X.4 coords.Y.4 coords.X.5 1 0.1867449 -0.02601616 0.2106543 -0.09257173 -0.03230658 0.005234662 -0.2763898 >-0.08784332 -0.3149726 coords.Y.5 coords.X.6 coords.Y.6 coords.X.7 coords.Y.7 coords.X.8 coords.Y.8 coords.X.9 coords.Y.9 1 -0.05877959 -0.3174958 -0.04960619 -0.3422491 0.04157688 -0.1765378 0.1096506 >0.01698919 0.1033746 coords.X.10 coords.Y.10 coords.X.11 coords.Y.11 coords.X.12 coords.Y.12 Csize 1 0.1867616 0.07142079 0.3104119 0.08151401 0.54839 -0.09795449 15.22692

The results obtained with $data are actually the coordinates of landmarks after the GPA, not the Procrustes residuals.

Is this normal and can this impact other estimations made by geomorph?

Also, has anyone a method to calculate partial warp scores in geomorph?

Thanks a lot.

mlcollyer commented 6 years ago

Phil,

The results are different because you are adding the step of subtracting the consensus to obtain your values. I think you were confused by our help file interchanging the terms "Procrustes coordinates” and "Procrustes residuals”, which are the same thing. Procrustes residuals refers to the fact that individual landmarks undergo a linear transformation by subtracting the configuration centroid (center of gravity) that along with scaling and rotating, put the original landmarks in a new coordinate system. “Residuals” should not convey that the consensus configuration is subtracted from the coordinates. In fact that is not a good thing to do, as it removes the configuration, altogether.

We should probably update our help page to be less ambiguous but please be aware that Y.gpa$coords are Procrustes residuals.

Cheers! Mike

On Jul 23, 2018, at 9:46 AM, PhilGossieaux notifications@github.com wrote:

Hello everyone,

I am currently trying to extract partial warp scores from my data but I am really not sure about the right method to do so in geomorph. I am using the 3.0.6 version.

To better understand how partial warp scores are estimated, I am trying to get the Procrustes residuals. To do so, I first calculated Procrustes residuals by hand (consensus configuration - landmark coordinates). Here is an example with the plethodon data :

data(plethodon) Y.gpa <- gpagen(plethodon$land) # GPA-alignment Y.gpa$consensus - Y.gpa$coords[,,1] # Procrustes residuals for the first individual

Here are the results I obtain :

          X             Y

[1,] -0.0344125269 0.0007795351 [2,] -0.0173644760 -0.0024695930 [3,] -0.0013939463 -0.0121645486 [4,] -0.0054344476 -0.0015275652 [5,] 0.0042459454 0.0009465181 [6,] -0.0085043603 0.0175240242 [7,] 0.0246763774 -0.0015201942 [8,] -0.0117064381 -0.0093034324 [9,] 0.0046035509 -0.0045212382 [10,] 0.0027063193 0.0035193421 [11,] 0.0417190925 -0.0199987873 [12,] 0.0008649097 0.0287359394

Then, I used the $data function of gpagen (returns a data frame with an n x (pk) matrix of Procrustes residuals and centroid size) to verify my results as follows :

Y.gpa$data[1,]

and obtained :

coords.X.1 coords.Y.1 coords.X.2 coords.Y.2 coords.X.3 coords.Y.3 coords.X.4 coords.Y.4 coords.X.5 1 0.1867449 -0.02601616 0.2106543 -0.09257173 -0.03230658 0.005234662 -0.2763898 >-0.08784332 -0.3149726 coords.Y.5 coords.X.6 coords.Y.6 coords.X.7 coords.Y.7 coords.X.8 coords.Y.8 coords.X.9 coords.Y.9 1 -0.05877959 -0.3174958 -0.04960619 -0.3422491 0.04157688 -0.1765378 0.1096506 >0.01698919 0.1033746 coords.X.10 coords.Y.10 coords.X.11 coords.Y.11 coords.X.12 coords.Y.12 Csize 1 0.1867616 0.07142079 0.3104119 0.08151401 0.54839 -0.09795449 15.22692

The results obtained by hand and those obtained with $data are quite different and I do not understand why. Moreover, I plot the difference between consensus shape and the landmark coordinates of individual #1 https://github.com/geomorphR/geomorph/pull/1 (the one I took as an example here) :

plotRefToTarget(Y.gpa$consensus,Y.gpa$coords[,,1],gridPars=gridPar(pt.bg = "green", pt.size = 1), method="vector",mag=3, label=T)

When I compare the plot to my Procrustes residuals, those calculated by hand make much more sense than those obtained with $data.

Can anyone explain me how $data in gpagen calculates Procrustes residuals?

Finally, has anyone a method to calculate partial warp scores in geomorph?

Thanks a lot.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/geomorphR/geomorph/issues/17, or mute the thread https://github.com/notifications/unsubscribe-auth/AGjactnduhpIsRocxOqjlkpr0cHDpvoXks5uJdPGgaJpZM4VbBlL.

PhilGossieaux commented 6 years ago

Thanks a lot for your answer Mike!

I was indeed confused and thought that Procrustes residuals were the deviations of the landmark coordinates from the position of the respective landmarks in the average of all configurations, as represented by vectors on this type of plot :

plotRefToTarget(Y.gpa$consensus,Y.gpa$coords[,,1],gridPars=gridPar(pt.bg = "green", pt.size = 1), method="vector",mag=2, label=T)

Thanks for the precision!

However, I am still unsure of how to obtain partial warp scores. Could I use Procrustes coordinates as a shape variable in my models since it contains information about how each individual deviates from the consensus shape?

Thanks a lot!

deanadams commented 6 years ago

Phil,

The short answer is yes; you may use the Procrustes shape variables as input for downstream statistical analyses. That is the standard approach in the field.

Partial warp scores are redundant with these and are not needed (see a nice Rohlf paper from 1999 showing this equivalency for statistical analyses). You might also read a review of the current morphometric protocol: say Adams et al. 2013: Hystrix which describes this.

Dean

Dr. Dean C. Adams Director of Graduate Education, EEB Program Professor Department of Ecology, Evolution, and Organismal Biology Iowa State University www.public.iastate.edu/~dcadams/http://www.public.iastate.edu/~dcadams/ phone: 515-294-3834

From: PhilGossieaux notifications@github.com Sent: Monday, July 23, 2018 12:31 PM To: geomorphR/geomorph geomorph@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [geomorphR/geomorph] Procrustes residuals values and partial warp scores (#17)

Thanks a lot for your answer Mike!

I was indeed confused and thought that Procrustes residuals were the deviations of the landmark coordinates from the position of the respective landmarks in the average of all configurations, as represented by vectors on this type of plot :

plotRefToTarget(Y.gpa$consensus,Y.gpa$coords[,,1],gridPars=gridPar(pt.bg = "green", pt.size = 1), method="vector",mag=2, label=T)

Thanks for the precision!

However, I am still unsure of how to obtain partial warp scores. Could I use Procrustes coordinates as a shape variable in my models since it contains information about how each individual deviates from the consensus shape?

Thanks a lot!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/geomorphR/geomorph/issues/17#issuecomment-407138199, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGSvqYevHloK2EKDSD0gnCHvsAx48xmfks5uJghggaJpZM4VbBlL.

PhilGossieaux commented 6 years ago

Thanks a lot for the very quick and helpful answers, it is really appreciated!

Cheers!

Philippine

dnavon commented 5 years ago

I was also looking for a way to extract Procrustes residuals - is it better to use A (the aligned residuals) or Ahat (the predicted residuals)?

deanadams commented 5 years ago

Hard to answer that without more context. What function are you using and how? The function ‘gpagen’ has output $coords for the Procrustes residuals, not $A or $Ahat. So if one wishes the Procrustes residuals $coords from a gpagen object would do it.

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

From: dnavon notifications@github.com Sent: Wednesday, December 19, 2018 2:14 PM To: geomorphR/geomorph geomorph@noreply.github.com Cc: Adams, Dean [EEOBS] dcadams@iastate.edu; State change state_change@noreply.github.com Subject: Re: [geomorphR/geomorph] Procrustes residuals values and partial warp scores (#17)

I was also looking for a way to extract Procrustes residuals - is it better to use A (the aligned residuals) or Ahat (the predicted residuals)?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/geomorphR/geomorph/issues/17#issuecomment-448728895, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGSvqYGNA0ZeeLZPe2BxY50LoCHEfK5Cks5u6p3rgaJpZM4VbBlL.

dnavon commented 5 years ago

Hi Dean, Sorry - what I'm really looking for is size-corrected Procrustes residuals. I've been using the procD.allometry function, and in the literature for that it says $A is the correct output for the Procrustes residuals. $Ahat is the predicted residuals - I'm not sure the difference.

Ultimately I want to do a DFA on these residuals. Originally Craig did a DFA on the partial warps, but the Rohlf paper (and you and Mike) suggests that Procrustes residuals will suffice. I'm trying to analyze some additional traits & compare them to what's already been done, so I want things to be as similar as possible (though I may end up recreating the DFA with the Procrustes residuals so I'm really comparing granny smith apples to granny smith apples).

Thanks for the prompt response - and for your help! I really appreciate it.

deanadams commented 5 years ago

Agh. Makes more sense. The component ‘A’ is just the initial data (Procrustes residuals in this case). Ahat contains the predicted values, which for an allometric regression are size-adjusted values. These are what you want.

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

From: dnavon notifications@github.com Sent: Wednesday, December 19, 2018 5:21 PM To: geomorphR/geomorph geomorph@noreply.github.com Cc: Adams, Dean [EEOBS] dcadams@iastate.edu; State change state_change@noreply.github.com Subject: Re: [geomorphR/geomorph] Procrustes residuals values and partial warp scores (#17)

Hi Dean, Sorry - what I'm really looking for is size-corrected Procrustes residuals. I've been using the procD.allometry function, and in the literature for that it says $A is the correct output for the Procrustes residuals. $Ahat is the predicted residuals - I'm not sure the difference.

Ultimately I want to do a DFA on these residuals. Originally Craig did a DFA on the partial warps, but the Rohlf paper (and you and Mike) suggests that Procrustes residuals will suffice. I'm trying to analyze some additional traits & compare them to what's already been done, so I want things to be as similar as possible (though I may end up recreating the DFA with the Procrustes residuals so I'm really comparing granny smith apples to granny smith apples).

Thanks for the prompt response - and for your help! I really appreciate it.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/geomorphR/geomorph/issues/17#issuecomment-448784880, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGSvqZO3geOyBAipkm6hcKLpJ4k64YLpks5u6snZgaJpZM4VbBlL.

dnavon commented 5 years ago

Thank you so so much!!!

dnavon commented 5 years ago

Out of curiousity....can you explain what exactly the Residual Shape Component (RSC) is? This comes out of using the CAC method in procD.allometry.

I swear that's my last question for tonight.

deanadams commented 5 years ago

The RSC is a vector describing the primary axis of variation orthogonal to the CAC (common allometric component).

If you look at the help file of procD.allometry (or any of our functions), we provide rather extensive descriptions, which include references to the primary literature where these are defined.

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

From: dnavon notifications@github.com Sent: Wednesday, December 19, 2018 6:27 PM To: geomorphR/geomorph geomorph@noreply.github.com Cc: Adams, Dean [EEOBS] dcadams@iastate.edu; State change state_change@noreply.github.com Subject: Re: [geomorphR/geomorph] Procrustes residuals values and partial warp scores (#17)

Out of curiousity....can you explain what exactly the Residual Shape Component (RSC) is? This comes out of using the CAC method in procD.allometry.

I swear that's my last question for tonight.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/geomorphR/geomorph/issues/17#issuecomment-448805582, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGSvqY0L8cuGshtBGDX80Td5MAWcvjpYks5u6tlAgaJpZM4VbBlL.