

using the geomorph package in R
We will use 2D coordinate data of salamander head shape stored in the plethspecies variable
note that the landmark data is in a \(p\ (landmarks) \times k \ (dimensionality) \times n\ (individuals)\) array
library(geomorph) data(plethspecies) plethspecies$land[,,1]
## [,1] [,2] ## [1,] 0.21709112 -0.000276374 ## [2,] 0.25926598 -0.052804288 ## [3,] -0.01647032 -0.016116581 ## [4,] -0.25610814 -0.122293605 ## [5,] -0.27985971 -0.091408103 ## [6,] -0.31518457 -0.062484078 ## [7,] -0.31617380 0.011871093 ## [8,] -0.18628522 0.091895157 ## [9,] 0.03922964 0.119902699 ## [10,] 0.23104389 0.103313314 ## [11,] 0.62345113 0.018400765
Notice that our plethspecies has more than landmarks, it also has a phylogenetic tree
We will explore these more next week, but just take brief look
plot(plethspecies$phy)
GPA_pleth <- gpagen(plethspecies$land)
GPA_pleth
## ## Call: ## gpagen(A = plethspecies$land) ## ## ## ## Generalized Procrustes Analysis ## with Partial Procrustes Superimposition ## ## 11 fixed landmarks ## 0 semilandmarks (sliders) ## 2-dimensional landmarks ## 2 GPA iterations to converge ## ## ## Consensus (mean) Configuration ## ## X Y ## 1 0.21321198 -0.02105584 ## 2 0.24769363 -0.08046387 ## 3 -0.02712554 -0.01550055 ## 4 -0.26228896 -0.09485409 ## 5 -0.29017433 -0.06350496 ## 6 -0.31712433 -0.03118322 ## 7 -0.31143955 0.04394055 ## 8 -0.17573253 0.10754464 ## 9 0.05243877 0.11186878 ## 10 0.24134839 0.07648746 ## 11 0.62919248 -0.03327890
PCA <- gm.prcomp(GPA_pleth$coords) summary(PCA)
## ## Ordination type: Principal Component Analysis ## Centering by OLS mean ## Orthogonal projection of OLS residuals ## Number of observations: 9 ## Number of vectors 8 ## ## Importance of Components: ## Comp1 Comp2 Comp3 Comp4 ## Eigenvalues 0.0002720474 0.0001120524 0.0001084758 0.0000568924 ## Proportion of Variance 0.4564029477 0.1879858086 0.1819855633 0.0954461044 ## Cumulative Proportion 0.4564029477 0.6443887563 0.8263743196 0.9218204240 ## Comp5 Comp6 Comp7 Comp8 ## Eigenvalues 0.0000264508 1.260516e-05 5.959622e-06 1.584785e-06 ## Proportion of Variance 0.0443754550 2.114717e-02 9.998220e-03 2.658730e-03 ## Cumulative Proportion 0.9661958790 9.873431e-01 9.973413e-01 1.000000e+00
plot(PCA)
PCA_phylo <- gm.prcomp(GPA_pleth$coords, phy = plethspecies$phy) plot(PCA_phylo, phylo = TRUE)
Check out the picknplot.shape() for help visualizing the grids
you can do TONS of analyses using the functions in the geomorph package
Questions?