PLS interactions

217 views
Skip to first unread message

Tyler Serdar

unread,
Aug 3, 2021, 9:59:44 AM8/3/21
to geomorph R package
Hi all,

i am a student that has worked with the geomorph package a little and I believe I understand the basic functions. Now, I am working with partial least squares, and I seem to be stuck. Maybe you can help?

I sampled the shape of individuals two times, with 4 weeks in-between. During this 4-week period, I have exposed them to two different treatments. Now, I would like to examine whether the shape of individuals has changed differently between treatments. In linear model terms, this would be studying either the treatment interaction or having a measure of the difference in shape as dependent variable.

I have been trying to work with the function two.b.pls, but I struggle in specifying the interaction. Alternatively, I would love to have a function in geomorph that allows me to extract the difference in shape for each individual, so I can analyze it with lm.RRPP. morphol.disparity sounds good at first glance but does not allow specifying two values per individual.

Thank you for your time and help!
Tyler

Bryan H. Juarez

unread,
Aug 3, 2021, 11:14:47 AM8/3/21
to geomorph-...@googlegroups.com
Hi Tyler, 

Partial least squares is used to assess the maximum covariation between two matrices in terms of linear combinations of the variables within each original matrix, it is not typically used for assessing treatment effects or interactions in the way you describe. Perhaps what you need is procD.pgls (in geomorph) or lm.rrpp (in RRPP).

Your coordinates output from gpagen should give coordinates for each individual that you can analyze in a linear model. I am confused as to why you want to compare two individuals or supply two values per individual, a bit more explanation would help. 

Best, 
Bryan Juarez

--
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/d554e9e2-1c5d-4dee-aebe-7391f0c3c6c7n%40googlegroups.com.


--
Bryan H. Juarez, PhD 
He/Him
NSF Postdoctoral Scholar
O'Connell and Hadly Labs
Biology Dept.
Stanford University
Twitter: @bhjuarez


Tyler Serdar

unread,
Aug 3, 2021, 11:26:50 AM8/3/21
to geomorph R package
Bryan,

thank you for your answer. I want to see if the treatments induces different  _changes_ in the shape over time. That is why I need to assess shape from each individual once before and once after the treatment.

Imagine it as the geometric morphometric equivalent of this (I replace shape by weight here for simplicity): 

Weight after treatment ~ Weight before treatment x treatment

or, in simpler terms:

Change in weight ~ treatment

Tyler

Bryan H. Juarez

unread,
Aug 3, 2021, 11:41:11 AM8/3/21
to geomorph-...@googlegroups.com
If I am understanding correctly, it seems you should be able to answer those questions using the output from your linear models. For example, if you are interested in knowing the effect of a treatment on your (before and after) groups, you can do this by looking at the regression coefficient for treatment in your linear model. 

If you are wanting to compare the coordinates of two shape configurations, plotRefToTarget would be a place to start your search. Others may provide better solutions for your specific issue.

Best,
Bryan

Tyler Serdar

unread,
Aug 4, 2021, 5:08:34 AM8/4/21
to geomorph R package
Dear Bryan,

you are correct. However, my issue is getting a model with an interaction to run. I only get errors. I have no idea what I am doing wrong. Could you help?

Here is my code:

Datapre <- readland.tps("pre.tps", specID = c("ID"), negNA = FALSE, warnmsg = TRUE)
Datapost <- readland.tps("post.tps", specID = c("ID"), negNA = FALSE, warnmsg = TRUE)

shape.pre <- gpagen(Datapre)$coords
shape.post <- gpagen(Datapost)$coords

pre.dat <- two.d.array(shape.pre)
post.dat <- two.d.array(shape.post)

add <- read.table("add.txt", header=TRUE, stringsAsFactors=TRUE, sep="\t", na.strings="NA", dec=".", strip.white=TRUE)

dat.full <- geomorph.data.frame(coordspre = pre.dat, coordspost = post.dat, treatment = add$Treatment)
str(dat.full)

List of 3
 $ coordspre : num [1:21, 1:26] 0.408 0.402 0.397 0.407 0.402 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:21] "0 " "1 " "2 " "3 " ...
  .. ..$ : chr [1:26] "1.X" "1.Y" "2.X" "2.Y" ...
 $ coordspost: num [1:21, 1:26] 0.397 0.399 0.404 0.407 0.394 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:21] "0 " "1 " "2 " "3 " ...
  .. ..$ : chr [1:26] "1.X" "1.Y" "2.X" "2.Y" ...
 $ treatment : Factor w/ 2 levels "A","B": 1 1 1 1 1 1 1 1 1 1 ...
 - attr(*, "class")= chr "geomorph.data.frame"

m.1<-procD.lm(dat.full$coordspost~dat.full$coordspre*dat.full$treatment,iter=999)

ERROR: 'names' attribute [3] must be the same length as the vector [1]

m.pgls <- procD.pgls(coordspost ~ coordspre*treatment, data = dat.full, iter = 999)

ERROR: argument "phy" is missing, with no default

m.2<-lm.rrpp(coordspost ~ coordspre*treatment, SS.type = "III", data=dat.full, iter=999)

ERROR: One or more independent variables does not match the number of observations in the data.

The only thing that works is a PLS without treatment, which is why I was looking for a way to incorporate treatment here:

two.b.pls(dat.full$coordspost, dat.full$coordspre, iter = 999, seed = NULL, print.progress = TRUE)

r-PLS: 0.756

Effect Size (Z): 1.3503

P-value: 0.089

Based on 1000 random permutations

Tyler

Bryan H. Juarez

unread,
Aug 4, 2021, 10:27:31 AM8/4/21
to geomorph-...@googlegroups.com
Hi Tyler, 

The errors in geomorph and RRPP are quite helpful and intuitive in my opinion, especially relative to other packages. For example,
"ERROR: 'names' attribute [3] must be the same length as the vector [1]" 
this means that the rows of the data you supplied do NOT all have the same length. If your data do not all have the same length, then the algorithm is unable to know how to match your data to your treatment groups in the way you intend. The solution is to double check the length and names of the data you supply and to make sure they are the same. This may require reorganization of your input data.

The second error you receive from procD.pgls is self explanatory, there was no phy argument provided, and since procD.pgls implemented phylogenetic generalized least squares (pgls), we cannot expect it to run without providing a phylogeny. From the help file (>?procD.pgls), the phy argument is the phylogeny. Do you have a phylogeny? 

PLS works without a treatment because it is an analysis (similar-ish, but separate from pgls) that generally should work when you supply most any pair of matrices. However, partial least squares is simply not the same as phylogenetic or non-phylogenetic generalized least squares regression. Thus, PLS is not a method that receives a formula or third argument (e.g., a treatment variable).

Best, 
Bryan

nas...@gmx.net

unread,
Aug 5, 2021, 1:35:52 AM8/5/21
to geomorph-...@googlegroups.com
Hi Tyler,
 
Why do you perform the Procrustes superimposition for both groups (pre and post treatment) separately? I am not sure if I completely understand your project, but the vignette provided by Mike Collyer is probably helpful:
 
Best,
Nadja
 
 
Gesendet: Mittwoch, 04. August 2021 um 16:26 Uhr
Von: "Bryan H. Juarez" <bryanh...@gmail.com>
An: geomorph-...@googlegroups.com
Betreff: Re: [geomorph-r-package] PLS interactions
Reply all
Reply to author
Forward
0 new messages