Re: [MORPHMET] Re: Conceptual clarification of plotting shape deformation grids in geomorph

2018-11-08 Thread Igor Talijančić


Dear colleagues,

 

thank you so much for your guidelines regarding proper code syntax of the 
shape visualization of trajectory analysis!

 

 

Thank you so much!

 

Sincerely, 

Igor

Dana srijeda, 7. studenoga 2018. u 14:53:47 UTC+1, korisnik Dean Adams 
napisao je:
>
> Igor,
>
>  
>
> The components, $means contain the least squares means from the linear 
> model implemented in trajectory analysis. These can be visualized relative 
> to some reference (e.g., the overall mean shape), using ‘plotRefToTarget’.  
> Note that the $means must first be converted to a 2D array using 
> ‘arrayspecs.’  
>
>  
>
> An example is below (see also relevant help files).
>
>
> Best, 
>
>
> Dean
>
>  
>
> ##
>
> data(plethodon) 
>
> Y.gpa <- gpagen(plethodon$land)   
>
> gdf <- geomorph.data.frame(Y.gpa, species = plethodon$species, site = 
> plethodon$site)
>
> TA <- trajectory.analysis(coords ~ species*site, data=gdf, iter=199)
>
>  
>
> new <- arrayspecs(TA$means,p=12,k=2)
>
> ref <-mshape(Y.gpa$coords)
>
> plotRefToTarget(ref,new[,,1])
>
> ##
>
>  
>
> 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
>
>  
>
> *From:* Igor Talijančić > 
> *Sent:* Monday, November 5, 2018 4:26 AM
> *To:* MORPHMET >
> *Cc:* mlco...@gmail.com 
> *Subject:* [MORPHMET] Re: Conceptual clarification of plotting shape 
> deformation grids in geomorph
>
>  
>
> Hello everyone,
>
> Just a question regarding the plotting of deformation grinds of the 
> trajectory analysis (e.g. pupfish or plethodon data). Can shape.predictor 
> function be used for visualizing TA$pc.means since TA$pc.data corresponds 
> to PC scores obtained for Y.gpa$coords?
>
>  
>
> Thank you for your given time and consideration.
>
>  
>
> Sincerely,
>
> Igor
>
>
> Dana srijeda, 25. srpnja 2018. u 14:42:41 UTC+2, korisnik javiersantos3 
> napisao je:
>
> Hello Carmelo and Mike,
>
>  
>
> Thanks for the quick response! I see things now clearer, especially with 
> the examples you have both provided. Sometimes one gets disoriented in the 
> abstractness of shape space and coding ;-P  Thanks again!
>
>  
>
>  
>
> Best wishes,
>
> Javier
>
>  
>
>  
> --
>
> *From:* Mike Collyer 
> *Sent:* Wednesday, July 25, 2018 2:29:38 PM
> *To:* Javier Santos
> *Cc:* Morphomet Mailing List
> *Subject:* Re: Conceptual clarification of plotting shape deformation 
> grids in geomorph 
>
>  
>
> Javier, 
>
>  
>
> First your plotting question.  The plot.trajectory.analysis function is an 
> S3 generic plot function, which means you can modify the plot as you like. 
>  You do this easiest with the points function.  Here is an example, using 
> the help page example, which hopefully makes sense for you:
>
>  
>
> data(plethodon) 
>
> Y.gpa <- gpagen(plethodon$land)   
>
> gdf <- geomorph.data.frame(Y.gpa, species = plethodon$species, site = 
> plethodon$site)
>
>  
>
> TA <- trajectory.analysis(coords ~ species*site, data=gdf)
>
> summary(TA, angle.type = "deg")
>
> plot(TA)
>
> # Augment plot with the following code
>
> points(TA$pc.data, pch=19, col = "blue”) # turn all points blue
>
> points(TA$pc.data, pch=19, col = TA$groups) # change points to different 
> colors, by group
>
> One can modify plots as desired but you might need to learn how to use 
> graphical parameters in order to do it.  See the help for the function, 
> par, to know how to do that.
>
>  
>
> Second, since PC scores are Procrustes residuals (coordinates) projected 
> onto PC axes, there is a direct correspondence between an observation’s set 
> of coordinates and its PC scores.  If you perform trajectory analysis, the 
> $means object has the coordinates for the means (trajectory points).  You 
> simply have to rearrange the values with arrayspecs to generate deformation 
> grids.  The $pc.data is a matrix of PC scores whose rows correspond to the 
> coordinates in the gpagen object.  For example, TA$pc.data[5,] is a set of 
> PC scores for Y.gpa$coords[,,5].
>
>  
>
> Finally, for your last question, the function shape.predictor does exactly 
> what you seek.  The help page has examples that should help you (on e 
> specifically for allometry).
>
>  
>
> Cheers!
>
> Mike
>
>  
>
> On Jul 25, 2018, at 7:17 AM, Javier San

RE: [MORPHMET] Re: Conceptual clarification of plotting shape deformation grids in geomorph

2018-11-07 Thread Adams, Dean [EEOBS]
Igor,

The components, $means contain the least squares means from the linear model 
implemented in trajectory analysis. These can be visualized relative to some 
reference (e.g., the overall mean shape), using ‘plotRefToTarget’.  Note that 
the $means must first be converted to a 2D array using ‘arrayspecs.’

An example is below (see also relevant help files).

Best,

Dean

##
data(plethodon)
Y.gpa <- gpagen(plethodon$land)
gdf <- geomorph.data.frame(Y.gpa, species = plethodon$species, site = 
plethodon$site)
TA <- trajectory.analysis(coords ~ species*site, data=gdf, iter=199)

new <- arrayspecs(TA$means,p=12,k=2)
ref <-mshape(Y.gpa$coords)
plotRefToTarget(ref,new[,,1])
##

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: Igor Talijančić 
Sent: Monday, November 5, 2018 4:26 AM
To: MORPHMET 
Cc: mlcoll...@gmail.com
Subject: [MORPHMET] Re: Conceptual clarification of plotting shape deformation 
grids in geomorph


Hello everyone,

Just a question regarding the plotting of deformation grinds of the trajectory 
analysis (e.g. pupfish or plethodon data). Can shape.predictor function be used 
for visualizing TA$pc.means since TA$pc.data corresponds to PC scores obtained 
for Y.gpa$coords?



Thank you for your given time and consideration.



Sincerely,

Igor

Dana srijeda, 25. srpnja 2018. u 14:42:41 UTC+2, korisnik javiersantos3 napisao 
je:

Hello Carmelo and Mike,



Thanks for the quick response! I see things now clearer, especially with the 
examples you have both provided. Sometimes one gets disoriented in the 
abstractness of shape space and coding ;-P  Thanks again!





Best wishes,

Javier






From: Mike Collyer >
Sent: Wednesday, July 25, 2018 2:29:38 PM
To: Javier Santos
Cc: Morphomet Mailing List
Subject: Re: Conceptual clarification of plotting shape deformation grids in 
geomorph

Javier,

First your plotting question.  The plot.trajectory.analysis function is an S3 
generic plot function, which means you can modify the plot as you like.  You do 
this easiest with the points function.  Here is an example, using the help page 
example, which hopefully makes sense for you:


data(plethodon)

Y.gpa <- gpagen(plethodon$land)

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



TA <- trajectory.analysis(coords ~ species*site, data=gdf)

summary(TA, angle.type = "deg")

plot(TA)

# Augment plot with the following code

points(TA$pc.data, pch=19, col = "blue”) # turn all points blue

points(TA$pc.data, pch=19, col = TA$groups) # change points to different 
colors, by group
One can modify plots as desired but you might need to learn how to use 
graphical parameters in order to do it.  See the help for the function, par, to 
know how to do that.

Second, since PC scores are Procrustes residuals (coordinates) projected onto 
PC axes, there is a direct correspondence between an observation’s set of 
coordinates and its PC scores.  If you perform trajectory analysis, the $means 
object has the coordinates for the means (trajectory points).  You simply have 
to rearrange the values with arrayspecs to generate deformation grids.  The 
$pc.data is a matrix of PC scores whose rows correspond to the coordinates in 
the gpagen object.  For example, TA$pc.data[5,] is a set of PC scores for 
Y.gpa$coords[,,5].

Finally, for your last question, the function shape.predictor does exactly what 
you seek.  The help page has examples that should help you (on e specifically 
for allometry).

Cheers!
Mike

On Jul 25, 2018, at 7:17 AM, Javier Santos > 
wrote:

Hello Morphometricians,

I was hoping someone could clarify the concept of plotting shape deformation 
grids from the geomorph output. I am confused at the moment because the output 
of most functions (eg. trajectory.analysis()) gives PC values or regression 
scores, while most of the plotting functions I know (eg. plotRefToTarget(), 
plotTangentSpace(), plotAllSpecimens()) require LM coordinates. I am sure that 
the conceptual framework to plot the shape deformation grids corresponding from 
the PC/regression values of the functions' output should not be too 
complicated, but I am currently lost how to do so with the coding and do not 
have a working example.

I will use my current analysis as an example from which to work upon. I have 
ran a trajectory.analysis() on a three species sample:

ontogeny <- trajectory.analysis(M2d ~ 
species*age,f2=NULL,iter=999,seed=NULL,data=gdf)

and plot the results:

x11(); 
plot(ontogeny,group.cols=c("red","blue","green"),pt.scale=1.5,pt.seq.pattern=c("black","gray","white"))

The following code plots the trajectory in the corresponding PC1-PC2