Issues with the procD.lm in the new geomorph version

587 views
Skip to first unread message

Nadja Pollath

unread,
May 17, 2018, 8:01:55 AM5/17/18
to geomorph R package

Dear all,

a colleague of mine wants to do GMM. She started with exploring measurement error. Her data are quite simple at the moment containing 5 specimens with 10 LMs. Her script looks like this:

Test<-readland.tps(file.choose(),specID="imageID",readcurves=FALSE)

rep = as.factor(c(rep(1,3),rep(2,3),rep(3,3),rep(4,3),rep(5,3)))
pos = as.factor(paste("D",1:15,sep=""))

Test.list<-list(Test,rep,pos)
names(Test.list) = c("land", "rep","pos")

Test.gpa <-gpagen(Test.list$land)
shape=Test.gpa$coords

My.df<- geomorph.data.frame(shape,rep,pos)

ANOVA1 <- procD.lm(shape ~ rep/pos, iter=999, data=My.df)
ANOVA2 <- procD.lm(shape ~ rep, iter=999, data=My.df)

This worked perfectly well with her data on my computer. I still have an old version of R (version 3.3.3) and geomorph (3.0.3) on my computer [it's quite cumbersome to get a new version of R installed because the responsible person is in only once a week]. My colleague has now tried to run the exact same script on her computer with the newest versions of R and geomorph. She get's the following error meassage:

ANOVA1<- procD.lm(shape ~ rep/pos, iter=999, data=My.df)
Error in procD.fit(f1, data = data, keep.order = ko, pca = FALSE, ...) :
  Your formula appears to have data embedded within objects
(a '$' is part of the formula).  It is not possible to reconcile
the location of the data from the object that contains it with this
function.  Either use a geomorph data frame or liberate the data from
the object and try again.

We checked the geomorph dataframe My.df which does not contain any $ but is a list with three elements.

I am completely at a loss.

Thanks for your help!

Nadja

Mike Collyer

unread,
May 17, 2018, 9:06:23 AM5/17/18
to geomorph R package
Nadja,

First, this is a poor error statement that we introduced to try to help users understand why an error might have occurred rather receives R’s indecipherable error statement.  However, it seems to get trigger for errors for which we did not intend it.  We need to update that, but for now, read it is simple as “something went wrong”

Second, thank you for providing the detail of your analysis!  It helps to see where the error might have occured.

The problem appears that the objects in your geomorph data frame do not have names.  Try this and see if it works

 My.df <- geomorph.data.frame(shape = shape, rep.pos = rep,pos)

If you do not give them names, they are nameless at positions [[1]] and [[2]] in the list.  The function is searching for names found in the formula and cannot match them.  (This is what the error is detecting and often that is caused by subsetting a list in the formula name.)  

This might seem like an unneeded redundancy but from the R perspective, variables, factors, matrices, and other data frames can be added to data.frames, so it is essential to name components.  Note that with geomoprh.data.frame, we have some exceptions, like with gpagen objects.  The function will separate the components and add them separately.  You could do this

My.df <- geomorph.data.frame(Test.gpa, rep.pos = rep,pos)

and the objects in the data frame will be $coords, $Csize, and $rep.pos

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/97e7b5d2-d07a-42b0-b0e1-df7bac0aef25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nadja Pollath

unread,
May 17, 2018, 1:01:06 PM5/17/18
to geomorph R package
Mike,
now it worked also for my colleague. Many thanks!

Just out of curiosity: Why did her original script work with my old geomorph version but not with the new version?

And if you ask me, this geomorph error message makes much more sense to me than the usual R error statements even if I could not figure out what was wrong. But I at least had an idea where to look.

Thanks again for your quick answer - much appreciated,

Nadja (also in Hui's name)

Mike Collyer

unread,
May 17, 2018, 1:31:45 PM5/17/18
to geomorph-...@googlegroups.com
Nadja,

It could be one or a combination of changes made in our updates or R updates.  I don’t recall an explicit major change to geomorph data frames but it is possible an update somewhere else created an issue here, which we also neither tried to anticipate nor override. Geomorph data frames are R lists and the way you had it set up essentially asks R to try to give objects in the list a name or give up if it is unattainable. The solution I gave you is unambiguous because you define the names. 

Also, as a possibility, a change in the way our functions search the list to find data might have assumed that the list had names. I know that our old coding did not always do a good job to match names. Updated code has become more efficient. It might be that your example just happened to work better with our old code that had more bugs.

These are speculative ideas. Invariably, with program coding, fixing one issue introduces another elsewhere.  I’m surprised your example worked with our old version. I would not have expected that. We probably just got lucky because we assumed the data frame would have named objects.

Cheers!
Mike


Sent from my iPhone
--
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.

Alyson Brokaw

unread,
Jun 21, 2018, 5:26:20 PM6/21/18
to geomorph R package
Hello, 

Just jumping in, as I recently started using geomorph and have been having a similar issue, only while trying to run a MANOVA with procD.pgls. I tried the fix you mentioned to Nadia, but that didn't work in my case (possible I translated the fix incorrectly). 

Here's my original code:

data.cc <- sub_logdata[,c("INW", "ONW", "NL", "NW", "CL", "CW", "INW_Ratio", "NareWidth","Diet", "Avg_Mass", "For_Hab", "For_Mode", "Migr", "Echo_Mode", "FA")]
data.cc <- data.cc[complete.cases(data.cc),]
nose_shape2 <- data.cc[,1:8]
ecovars <- data.cc[,9:15]
df <- geomorph.data.frame(nose_shape2, ecovars, bat_tree)
#Run PGLS 
procD.pgls(nose_shape2 ~ evovars, data=df, print.progress=F) #this is where I get the error

I was using a tutorial and trying to translate it into my own data, so it is possible I've just missed a step or done an extra step? Trying to run a model with several morphological variables (nose_shape2) against a bunch of ecological variables (diet, habitat etc). 

Thanks for your help!

-Alyson



On Thursday, May 17, 2018 at 12:31:45 PM UTC-5, Michael Collyer wrote:
Nadja,

It could be one or a combination of changes made in our updates or R updates.  I don’t recall an explicit major change to geomorph data frames but it is possible an update somewhere else created an issue here, which we also neither tried to anticipate nor override. Geomorph data frames are R lists and the way you had it set up essentially asks R to try to give objects in the list a name or give up if it is unattainable. The solution I gave you is unambiguous because you define the names. 

Also, as a possibility, a change in the way our functions search the list to find data might have assumed that the list had names. I know that our old coding did not always do a good job to match names. Updated code has become more efficient. It might be that your example just happened to work better with our old code that had more bugs.

These are speculative ideas. Invariably, with program coding, fixing one issue introduces another elsewhere.  I’m surprised your example worked with our old version. I would not have expected that. We probably just got lucky because we assumed the data frame would have named objects.

Cheers!
Mike


Sent from my iPhone

On May 17, 2018, at 1:01 PM, Nadja Pollath <nas...@gmx.net> wrote:

Mike,
now it worked also for my colleague. Many thanks!

Just out of curiosity: Why did her original script work with my old geomorph version but not with the new version?

And if you ask me, this geomorph error message makes much more sense to me than the usual R error statements even if I could not figure out what was wrong. But I at least had an idea where to look.

Thanks again for your quick answer - much appreciated,

Nadja (also in Hui's name)

--
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-package+unsub...@googlegroups.com.

Adams, Dean [EEOBS]

unread,
Jun 22, 2018, 10:32:33 AM6/22/18
to geomorph-...@googlegroups.com

Alyson,

 

A few things to think about. First, be certain that the rownames for all components in the dataframe correspond with those of the phylogeny. Also, you did not specify the phylogeny in your procD.pgls, so that is an issue.

 

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/

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 post to this group, send email to geomorph-...@googlegroups.com.
Visit this group at https://groups.google.com/group/geomorph-r-package.

Alyson Brokaw

unread,
Jun 25, 2018, 12:58:03 PM6/25/18
to geomorph R package
Thanks for the suggestions. 
Looking at the dataframe, it looks like the problem is probably that the rownames might not match my phylogeny. For my previous analyses/manipulations, I had renamed the rows of the data (nose_shape2) to match the names in the phylogeny, but that doesn't seem to transfer in the geomorph dataframe. 

Is there a way to change the row names in the geomorph data frame, or do I need to change the tip labels in my phylogeny? I get an error when I try to use the same commands for changing row names in a normal data set. 

Thank you!

-Alyson

To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@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-package+unsub...@googlegroups.com.
To post to this group, send email to geomorph...@googlegroups.com.

Adams, Dean [EEOBS]

unread,
Jun 25, 2018, 2:55:46 PM6/25/18
to geomorph-...@googlegroups.com

Changing the row names of the components first and then putting them in a geomorph data frame should work.

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.

--

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.

Reply all
Reply to author
Forward
0 new messages