Importing superimposed data in geomorph

567 views
Skip to first unread message

Milena Stefanovic

unread,
Oct 19, 2016, 4:18:10 AM10/19/16
to geomorph R package
Hello everyone,

Is it possible to import superimposed .tps or .nts data in geomorph and perform analysis?

Thanks,
Milena

Milena Stefanovic

unread,
Oct 19, 2016, 4:29:44 AM10/19/16
to geomorph R package
I digitized and superimposed my data in tpsDig and tpsRelw and imported .tps aligned data in R.
My data set with 2 factors (Population and Sex) and Tree nested in those factors are called "withfactors".

How to perform Procrustes ANOVA on my dataset?

My code so far is:

library(geomorph)
mydata <- readland.tps("Aligned specimens.tps", specID = "ID")
dim(mydata)

# Converting 3D array in 2D matrix (n x [p x k])
a <- two.d.array(mydata)
a

# Making classifier table with factors
classifier <- read.csv("Classifier.csv", header=T, row.names=1)
dim(classifier)
dim(mydata)
dim(a)

#Making dataset with factor variables Population and Sex
withfactors <- cbind(a, classifier)

#MANOVA
y <- # ???
procD.lm(y ~ withfactors$Population * withfactors$Sex)

Adams, Dean [EEOBS]

unread,
Oct 19, 2016, 9:17:22 AM10/19/16
to Milena Stefanovic, geomorph R package

Milena,

 

The functions readland.tps and readland.nts may be used to import shape data if they are in the appropriate file formats.


Dean

 

Dr. Dean C. Adams

Professor

Department of Ecology, Evolution, and Organismal Biology

       Department of Statistics

Iowa State University

www.public.iastate.edu/~dcadams/

phone: 515-294-3834

--
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/12c0608c-2977-4ae4-b78a-5139b1735484%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adams, Dean [EEOBS]

unread,
Oct 19, 2016, 12:18:00 PM10/19/16
to Milena Stefanovic, geomorph R package

Milena,

 

The script you sent is overly complicated for what you wish to do. It looks a bit like one is trying to force a MorphoJ structure on your data. That is not necessary.  The basic steps are these:

 

1: read in your data, both the landmarks and the other variables.  In your case, you have read in the shape data  ‘mydata’. This is a 3D array of whatever was in your TPS file. Then you have a second object ‘classifier’ that contains your additional variables: population and sex.

 

2: do GPA if you have not already (use gpagen in geomorph).  It seems you have done this outside of geomorph. Be aware that some other software uses full Procrustes rather than the more appropriate partial Procrustes. So you may wish to bring the original landmark dataset into geomorph. This will also allow you to obtain centroid size for other analyses, as Csize is obtained from gpagen.

 

3: do Procrustes anova. For your example, you do this last step as:

 

myresults<-procD.lm(mydata~classifier$Population*classifier$Sex) 

summary(myresults)

 

Here, you have done a factorial model with interaction. The output is found myresults.

 

The help file for procD.lm has additional comments, hints, and examples.


Best,

 

Dean

 

Dr. Dean C. Adams

Professor

Department of Ecology, Evolution, and Organismal Biology

       Department of Statistics

Iowa State University

www.public.iastate.edu/~dcadams/

phone: 515-294-3834

 

From: geomorph-...@googlegroups.com [mailto:geomorph-...@googlegroups.com] On Behalf Of Milena Stefanovic


Sent: Wednesday, October 19, 2016 3:30 AM
To: geomorph R package <geomorph-...@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.

Milena Stefanovic

unread,
Oct 21, 2016, 6:40:00 AM10/21/16
to geomorph R package

Dr. Adams,

 

Thank you very much  for your help.

 

I have done superimposition in tpsRelw, but to be honest I am not sure if that was full or partial Procrustes. In help menu of the programme it is not specified , only reference to: Rohlf and Slice, 1990 (Extensions of the Procrustes method for the optimal superimposition  of landmarks. Systematic Zool., 39:40-59).

I also did superimposition in geomorph, as you seggested:


Taxus_all <- readland.tps("Output file_Taxus baccata_digitized.tps", specID = "ID", readcurves=TRUE)

dim(Taxus_all)

Y.gpa2 <- gpagen(Taxus_all, curves = define.sliders(Taxus_all[,,1], 26), ProcD = FALSE)


and PCA:


plotTangentSpace(Y.gpa2$coords)


First two principal components explain 86.05% of shape variation and it seems that there are some groupings of data, but deformation grids seems little bit strange to me. What could be the cause of that (PCA plot is attached)?

 

Best regards,

Milena


среда, 19. октобар 2016. 10.18.10 UTC+2, Milena Stefanovic је написао/ла:
Rplot_PCA.pdf
Message has been deleted

Milena Stefanovic

unread,
Oct 21, 2016, 10:22:45 AM10/21/16
to geomorph R package
Rplot_PCA_Population.pdf

Mike Collyer

unread,
Oct 21, 2016, 10:30:29 AM10/21/16
to Milena Stefanovic, geomorph R package
Milena,

Without the benefit of knowing your landmark configurations and choice of sliders, just a guess, an outcome like this suggests that you have two different landmark configurations in play.  Notice there is no shape near the origin, suggesting something like the mean shape does not exist.  Notice that the deformation grids twist a lot, suggesting landmarks switch places in some cases.  I would verify that the digitizing was done in the exact same order in all cases, as a first step.

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.

For more options, visit https://groups.google.com/d/optout.
<Rplot_PCA.pdf>

Adams, Dean [EEOBS]

unread,
Oct 21, 2016, 10:58:46 AM10/21/16
to Mike Collyer, Milena Stefanovic, geomorph R package


Dean

 

Dr. Dean C. Adams

Professor

Department of Ecology, Evolution, and Organismal Biology

       Department of Statistics

Iowa State University

www.public.iastate.edu/~dcadams/

phone: 515-294-3834

 

Milena Stefanovic

unread,
Oct 21, 2016, 11:29:34 AM10/21/16
to geomorph R package, milen...@gmail.com
Thank you, Mike.

You are right, there is no mean shape (Rplot_after superimposition). Although, I got mean shape when I performed superimposition on the same dataset in tpsRelw (All population_consensus). 

Configurations are the same, but black samples are smaller than green and red. Is it possible that this differentiation is caused by size? 

Best regards,
Milena
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-package+unsub...@googlegroups.com.
Rplot_after superimposition.pdf
All populations_consensus.jpg

Mike Collyer

unread,
Oct 21, 2016, 11:42:41 AM10/21/16
to Milena Stefanovic, geomorph R package
Milena, 

I don’t think you understood what I meant.  tpsRelw might give you a deformation grid for the mean, but that does not mean you have a real specimen that is similar to this grid.  We have the same ability in geomorph with shape.predictor.  One can predict any shape in the shape space, even if there is no real specimen at a location.

The problem is that you have a chasm of no real shapes around the origin.  This is unnatural.  Unless you are comparing e.g., mammal and reptile bones or some other really divergent groups, this should not happen.  Sometimes one will find a pattern like yours, where only one or two specimens are divergent.  This usually indicates a couple of mis-digitized specimens.  For example, maybe landmarks 4 and 5 were switched around.

In your case I suspect you maybe had two different people digitizing and they digitized landmarks in a different order.  There is no other way to get such divergent groups and such mangled deformation grids, unless one has a data set including hugely divergent organisms, morphologically.  If your data includes both whales and bats, then maybe this kind of pattern is legitimate.

I hope that makes sense.

Mike


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.

For more options, visit https://groups.google.com/d/optout.
<Rplot_after superimposition.pdf><All populations_consensus.jpg>

Adams, Dean [EEOBS]

unread,
Oct 21, 2016, 11:46:37 AM10/21/16
to Mike Collyer, Milena Stefanovic, geomorph R package

 

Dean

 

Dr. Dean C. Adams

Professor

Department of Ecology, Evolution, and Organismal Biology

       Department of Statistics

Iowa State University

www.public.iastate.edu/~dcadams/

phone: 515-294-3834

 

From: geomorph-...@googlegroups.com [mailto:geomorph-...@googlegroups.com] On Behalf Of Mike Collyer
Sent: Friday, October 21, 2016 10:43 AM
To: Milena Stefanovic <milen...@gmail.com>
Cc: geomorph R package <geomorph-...@googlegroups.com>
Subject: Re: [geomorph-r-package] Importing superimposed data in geomorph

 

Milena, 

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/b780e3b1-3145-4c86-931e-8718ac35aca5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Rplot_PCA.pdf>

 

--
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/5295089a-5a5c-4a15-a500-948fb27ef306%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Rplot_after superimposition.pdf><All populations_consensus.jpg>

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

Milena Stefanovic

unread,
Oct 21, 2016, 1:25:25 PM10/21/16
to geomorph R package

What you said: "The only way to obtain such a pattern is if landmarks above and below the midline are labeled as the same in some specimens relative to others", it might cause these "wales" and "bats" in my data. I should do digitization again more cautiously.

Best regards,
MIlena  


Adams, Dean [EEOBS]

unread,
Oct 21, 2016, 2:40:44 PM10/21/16
to Milena Stefanovic, geomorph R package


Dean

 

Dr. Dean C. Adams

Professor

Department of Ecology, Evolution, and Organismal Biology

       Department of Statistics

Iowa State University

www.public.iastate.edu/~dcadams/

phone: 515-294-3834

 

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

Message has been deleted

Milena Stefanovic

unread,
Oct 24, 2016, 7:46:58 AM10/24/16
to geomorph R package

I have managed to find error in my data. One of the curves on one specimen had one point more compering to other specimen. When I deleted it, I got much better looking estimated mean (Rplot_after superimposition_2) and PCA plot (Rplot_PCA_Population_2).
However, there is no grouping in my data.

Anyway, I really like geomorph and I will continue to learn it. 

Best,
Milena
Rplot_after superimposition_2.pdf
Rplot_PCA_Population_2.pdf

Mike Collyer

unread,
Oct 24, 2016, 7:54:26 AM10/24/16
to Milena Stefanovic, geomorph R package
Milena,

This looks more appropriate.  Were most of these landmarks treated as sliding semilandmarks?  If so, did you use bending energy?  (I.e., did you say ProcD=FALSE as an argument in gpagen?)

You might have group differences after accounting for shape allometry, if there is meaningful allometric variation.  The help file and examples for procD.allometry might provide some insight about what to do next.

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

For more options, visit https://groups.google.com/d/optout.
<Rplot_after superimposition_2.pdf><Rplot_PCA_Population_2.pdf>

Milena Stefanovic

unread,
Oct 24, 2016, 10:57:23 AM10/24/16
to geomorph R package, milen...@gmail.com
Yes, there are 26 semilandmarks and 3 landmarks. And yes, I used bending energy method (because I read that is the most common). 

I also performed MANOVA, and there are significant differences between groups: 

gdf <- geomorph.data.frame(Shape = Y.gpa2$coords, Population = classifier$Population, Sex = classifier$Sex)
myresults <- procD.lm(Shape ~ Population * Sex, data = gdf)
summary(myresults)

Call:
procD.lm(f1 = Shape ~ Population * Sex, data = gdf) 

Type I (Sequential) Sums of Squares and Cross-products
Randomized Residual Permutation Procedure Used
1000 Permutations

                Df      SS       MS      Rsq       F       Z Pr(>F)   
Population       2 0.18979 0.094896 0.061597 15.6230 11.2422  0.001 **
Sex              1 0.03967 0.039675 0.012876  6.5317  4.5596  0.003 **
Population:Sex   2 0.03334 0.016669 0.010820  2.7443  2.3732  0.020 * 
Residuals      464 2.81841 0.006074                                   
Total          469 3.08121                                            
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

But PCA plot looks really "messy" and I am thinking about how to calculate mean shape for each tree (10 measurements for each tree) and represent 47 elements on PCA plot instead of 470. Is there a way to combine function mshape with classifier$Tree to represent only mean shape for every tree on PCA plot? 

Thank you for suggestion for allometric variation. 

Milena

Adams, Dean [EEOBS]

unread,
Oct 24, 2016, 3:49:31 PM10/24/16
to Milena Stefanovic, geomorph R package

Milena,

There are at least two ways to do this. First, you could do this by putting mshape into one of the apply functions.

 

Or perhaps a bit more straightforward, use advanced.procD.lm.  This may be used for pairwise comparisons, but as part of the output generates a matrix of means for the groups. These could then be re-arranged into a 3D array for use in plotTangentSpace.  A modified example from the help file is below.


Best,


Dean

 

###

data(plethodon)

Y.gpa<-gpagen(plethodon$land)    #GPA-alignment

gdf <- geomorph.data.frame(Y.gpa, species = plethodon$species, site = plethodon$site)

 

myresults<-advanced.procD.lm(coords ~ site*species, ~ site + species, groups = ~site*species,

                             iter=499, data = gdf)

 

means<-arrayspecs(myresults$LS.means,p=12,k=2)

plotTangentSpace(means)

 

 

Dr. Dean C. Adams

Professor

Department of Ecology, Evolution, and Organismal Biology

       Department of Statistics

Iowa State University

www.public.iastate.edu/~dcadams/

phone: 515-294-3834

 

From: geomorph-...@googlegroups.com [mailto:geomorph-...@googlegroups.com] On Behalf Of Milena Stefanovic


Sent: Monday, October 24, 2016 9:57 AM
To: geomorph R package <geomorph-...@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