Title: | Evolutionary Morphometric Simulation |
---|---|
Description: | Evolutionary process simulation using geometric morphometric data. Manipulation of landmark data files (TPS), shape plotting and distances plotting functions. |
Authors: | Juan Manuel Cabrera, Federico Giri |
Maintainer: | Juan Manuel Cabrera <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.9 |
Built: | 2025-03-06 04:49:12 UTC |
Source: | https://github.com/cran/Evomorph |
Aegla uruguayana consensus shape coordinates.
data("aegla_consensus")
data("aegla_consensus")
Diawol, V. P., Giri, F., & Collins, P. A. (2015). Shape and size variations of Aegla uruguayana (Anomura-Aeglidae) under laboratory conditions. A geometric morphometric approach to the growth. Iheringia Série Zoologia, 105(1), 76-83.
Geometric morphometric data of Aegla uruguayana cephalothorax (21 landmarks).
data("aegla_landmarks")
data("aegla_landmarks")
Diawol, V. P., Giri, F., & Collins, P. A. (2015). Shape and size variations of Aegla uruguayana (Anomura-Aeglidae) under laboratory conditions. A geometric morphometric approach to the growth. Iheringia Série Zoologia, 105(1), 76-83.
DistancesPlot
creates a distances plot using ggplot2 (Wickman 2009).
DistancesPlot(dist)
DistancesPlot(dist)
dist |
Distances matrix |
Use ggplot2
to create a plot where each point represent distance between a particular shape and a reference shape.
Return an ggplot2 object
Juan Manuel Cabrera
H. Wickham. ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York, 2009.
data("simulated_shape_distances") #Plot distances between a set of simulated shapes a reference. DistancesPlot(simulated_shape_distances)
data("simulated_shape_distances") #Plot distances between a set of simulated shapes a reference. DistancesPlot(simulated_shape_distances)
Calculates Procrustes residuals of landmark configurations
GpaResiduals(lands,gpa_coords)
GpaResiduals(lands,gpa_coords)
lands |
Landmark configuration |
gpa_coords |
GPA coordinates matrix |
Partial least squares analysis is a common tool to examine complex patterns of covariations between multiple sets of variables (Rohlf and Corti 2000; Bookstein et al. 2003). When one set of these variables consists of shape coordinates it is called singular warps analysis. Singular warp analysis is based on a singular decomposition of the cross-covariance matrix of two sets of variables measured from the same sample objects. Bookstein et al. (2013) gave this equation (1):
\sum = \left ( 1/N \right )X^{t}Y\
Where N is the sample size and X and Y are matrices for two sets of variables with N rows, corresponding to the same sample specimens, and columns according to the number of variables of each set. If each variable in both matrices is first mean-centered (by variable), then Equation (1) yields the cross-covariance matrix between variables in X and those in Y.
Most of the landmark-based morphometric studies use aligned shape coordinates (GPA) as variable for analyzing complex patterns of covariations between sets of landmarks coordinates data. However, whereas GPA mean-centers all specimen configurations – it superimposes the centroids of each specimen - GPA does not mean center each coordinate within the specimens, and therefore does not in itself provide suitable variables for use in Equation (1).
To avoid this problem GpaResiduals
mean center the aligned coordinates to get Procrustes residuals which are more appropriate for calculating covariance (McNulty 2009).
If generalized procrustes coordinates are not provided, the function will calculate them using geomorph package (Adams & Otárola Castillo 2013)
It returns a list containing:
consens |
Consensus shape |
cvectorized |
Consensus shape (1 dim vector) |
resid |
GPA residuals matrix |
Cabrera Juan Manuel
Adams, D. C., & Otárola-Castillo, E. (2013). geomorph: an R package for the collection and analysis of geometric morphometric shape data. Methods in Ecology and Evolution, 4(4), 393-399.
Bookstein, F. L., Gunz, P., Mitterœcker, P., Prossinger, H., Schæfer, K., & Seidler, H. (2003). Cranial integration in Homo: singular warps analysis of the midsagittal plane in ontogeny and evolution. Journal of Human Evolution, 44(2), 167-187.
McNulty, K. P. (2009). Computing singular warps from Procrustes aligned coordinates. Journal of human evolution, 57(2), 191-194.
Rohlf, F. J., & Corti, M. (2000). Use of two-block partial least-squares to study covariation in shape. Systematic Biology, 49(4), 740-753.
data("aegla_landmarks") result<-GpaResiduals(lands = aegla_landmarks) #GPA consensus (matrix) result$consens #GPA consensus (vector) result$cvectorized #GPA residual matrix result$resid
data("aegla_landmarks") result<-GpaResiduals(lands = aegla_landmarks) #GPA consensus (matrix) result$consens #GPA consensus (vector) result$cvectorized #GPA residual matrix result$resid
Plot the differences between a set of morphometric shapes and a reference
PlotVariations(shapes, reference, path, save = F, w = 6, h = 6, d = 100, c_ref = "red", c_target = "black", s_ref = 3, s_target = 2)
PlotVariations(shapes, reference, path, save = F, w = 6, h = 6, d = 100, c_ref = "red", c_target = "black", s_ref = 3, s_target = 2)
shapes |
Landmark data of shapes (list of matrices) |
reference |
Landmark data of reference shape (matrix type) |
path |
Path where results will be saved (Default: working directory) |
c_ref |
Color of the points representing the reference shape (Default |
c_target |
Color of the points representing the target shape (Default |
s_ref |
Size of the points representing the reference shape (Default |
s_target |
Size of the points representing the target shape (Default |
save |
A logical value. If TRUE, the function will save the plot as jpeg images in the indicated in |
This parameters are used to modify stored graph (save = TRUE
):
w |
Units of width of the graph in inches (Default |
h |
Units of height of the graph in inches(Default |
d |
Number of dpi (resolution) of the graph. (Default |
The function uses package ggplot2 (Wickman 2009) to create multiple plots representing the variations between a list of target shapes and a reference (consensus shape or another specimen data). If save=TRUE
it creates a folder (named day_hh_mm) and stores the plots as images (.jpeg) at the provided path (if not provided it will store them in the working directory).
There are several parameters for modify the graph for a suitable representation. This function could be used for example to analyze morphological variations of species over generations.
Cabrera Juan Manuel
H. Wickham. ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York, 2009.
data("aegla_consensus") data("simulated_shapes") #Sample one individual from simulated_shapes dataset simu<-simulated_shapes[100] #Create a shape variation graphic graph<-PlotVariations(simu,aegla_consensus) #Red dots represent the landmark coordinates of the reference shape and black # dots represent the target shape. The length of the segments represent # distances between pairs of homologous landmarks graph[[1]]
data("aegla_consensus") data("simulated_shapes") #Sample one individual from simulated_shapes dataset simu<-simulated_shapes[100] #Create a shape variation graphic graph<-PlotVariations(simu,aegla_consensus) #Red dots represent the landmark coordinates of the reference shape and black # dots represent the target shape. The length of the segments represent # distances between pairs of homologous landmarks graph[[1]]
Read landmark coordinates and scales from a TPS file
ReadLandmarkData(datafile, m_byscale = T)
ReadLandmarkData(datafile, m_byscale = T)
datafile |
TPS file containing two dimensional landmark data |
m_byscale |
Logical value (Default m_byscale=TRUE). If TRUE, landmark coordinates are multiply by scale |
The function returns landmark coordinates (array and data.frame format) and the scale of each specimen. If m_byscale
= T the coordinates are multiple by the corresponding scale.
ReadLandmarkData
only works with TPS files that has only landmark coordinates (presence of CURVES and OUTLINES may cause malfunction).
It returns a 3 element list:
df |
Landmark coordinates as a data.frame. Sp factor correspond to species number. |
array |
Landmark coordinates as a three dimensional array. |
scale |
Vector of scales value for each specimen. |
Cabrera Juan Manuel
Use the Procrustes method to calculate distances between a set of shapes and a reference.
ShapeDist(shapes, reference)
ShapeDist(shapes, reference)
shapes |
Landmark data of shapes (list of matrices) |
reference |
Lanmark data of reference shape (matrix type) |
Procrustes distance provides a measure of coincidence of two point sets xi and yi, i=1..N. For this purpose the variance of point deviations is calculated at the optimal superposition of the sets. It allows to characterize the shape proximity of a given simplex to shape of a reference one.
A matrix containing procrustes distance between shapes. Procrustes distance is the square root of the sum of squared differences in the posititions of the landmarks in two shapes (Dryden and Mardia 1998). This can be used to describe the difference between many landmark configurations (Rohlf and Slive 1990).
Cabrera Juan Manuel
Dryden, I. L., & Mardia, K. V. (1998). Statistical shape analysis (Vol. 4). Chichester: Wiley.
Rohlf, F. J., & Slice, D. (1990). Extensions of the Procrustes method for the optimal superimposition of landmarks. Systematic Biology, 39(1), 40-59.
data("aegla_landmarks") data("aegla_consensus") #Calculate distances between set of shapes and a reference ShapeDist(shapes = aegla_landmarks, reference = aegla_consensus)
data("aegla_landmarks") data("aegla_consensus") #Calculate distances between set of shapes and a reference ShapeDist(shapes = aegla_landmarks, reference = aegla_consensus)
SimEvo
performs a simulation of shape variation using a modification of Lande's evolutionary model Polly 2004
SimEvo(vari, consensusvec, resids, ngen, fsamp)
SimEvo(vari, consensusvec, resids, ngen, fsamp)
vari |
Variation coefficient |
consensusvec |
Consensus shape (vectorized form) |
resids |
GPA residuals matrix |
ngen |
Number of generations of simulations (Default: 1000000 steps). |
fsamp |
Frequency of samples (Default: 1000000 steps). |
Lande's evolutionary model defines mean morphological variation over generations as:
where is the additive genetic covariance matrix, and
are selection coefficients applied to the morphological structure.
Polly 2004 proposes a modification of this equation in order to use it with morphological data instead of genetic data:
where is the phenotypic covariance matrix, and
is an heritability matrix (See Polly 2004 for more information).
resids
will be used as the phenotypic covariance matrix, and vari
will be used to simulate term. After
ngen
simulations steps the new shape will be
reconstructed from the starting shape consensusvec
.
The number of plots representing the new shapes can be modify using fsamp
.
It returns a list of ngen/fsamp shapes (landmarks coordinates)
Cabrera Juan Manuel
Polly, P. D. (2004). On the simulation of the evolution of morphological shape: multivariate shape under selection and drift. Palaeontologia Electronica, 7(2), 1-28.
data("aegla_landmarks") #Use GpaResiduals function to obtain GPA residual matrix and consensus # coordinates from landmark configuration a_data=GpaResiduals(aegla_landmarks) #Simulate morphological evolution with a variation rate "vari" # trough "ngen" generations and retrieve the last generation shape coordinates simshape = SimEvo(vari = 2, consensusvec = a_data$cvectorized, resids = a_data$resid, ngen = 10000, fsamp = 10000) #Plot consensus shape and the simulated shape par(mfrow=c(1, 2)) plot(a_data$consens,type = "p",main = "Reference", xlab = "", ylab = "") plot(simshape[[1]],type = "p",col = "red",main = "Target", xlab = "", ylab = "") #Or you can use PlotVariations to see the difference more clearly PlotVariations(simshape,a_data$consens)
data("aegla_landmarks") #Use GpaResiduals function to obtain GPA residual matrix and consensus # coordinates from landmark configuration a_data=GpaResiduals(aegla_landmarks) #Simulate morphological evolution with a variation rate "vari" # trough "ngen" generations and retrieve the last generation shape coordinates simshape = SimEvo(vari = 2, consensusvec = a_data$cvectorized, resids = a_data$resid, ngen = 10000, fsamp = 10000) #Plot consensus shape and the simulated shape par(mfrow=c(1, 2)) plot(a_data$consens,type = "p",main = "Reference", xlab = "", ylab = "") plot(simshape[[1]],type = "p",col = "red",main = "Target", xlab = "", ylab = "") #Or you can use PlotVariations to see the difference more clearly PlotVariations(simshape,a_data$consens)
Procrustes distance between a set of simulated shapes and their ancestry over generations.
data("simulated_shape_distances")
data("simulated_shape_distances")
Simulated landmark data using evomorph SimEvo
function on Aegla uruguayana data.
data("simulated_shapes")
data("simulated_shapes")
Diawol, V. P., Giri, F., & Collins, P. A. (2015). Shape and size variations of Aegla uruguayana (Anomura-Aeglidae) under laboratory conditions. A geometric morphometric approach to the growth. Iheringia Série Zoologia, 105(1), 76-83.