if (FALSE) {
data(plethodon)
Y.gpa <- gpagen(plethodon$land, print.progress = FALSE) #GPA-alignment
gdf <- geomorph.data.frame(Y.gpa, species = plethodon$species,
site = plethodon$site)
# Morphological disparity for entire data set
morphol.disparity(coords ~ 1, groups = NULL, data = gdf,
print.progress = FALSE)
# Morphological disparity for entire data set, accounting for allometry
morphol.disparity(coords ~ Csize, groups= NULL, data = gdf,
print.progress = FALSE)
# Morphological disparity without covariates, using overall mean
morphol.disparity(coords ~ 1, groups= ~ species * site, data = gdf,
print.progress = FALSE)
# Morphological partial disparities for overal mean
morphol.disparity(coords ~ 1, groups= ~ species * site, partial = TRUE,
data = gdf, print.progress = FALSE)
# Morphological disparity without covariates, using group means
morphol.disparity(coords ~ species * site, groups= ~species * site,
data = gdf, print.progress = FALSE)
# Morphological disparity of different groups than those
# described by the linear model
morphol.disparity(coords ~ Csize + species * site, groups= ~ species,
data = gdf, print.progress = FALSE)
# Extracting components
MD <- morphol.disparity(coords ~ Csize + species * site, groups= ~ species,
data = gdf, print.progress = FALSE)
MD$Procrustes.var # just the Procrustes variances
### Morphol.disparity can be used with previously-defined
### procD.lm or lm.rrpp class objects
data(plethspecies)
Y.gpa <- gpagen(plethspecies$land) #GPA-alignment
gp.end <- factor(c(0,0,1,0,0,1,1,0,0)) #endangered species vs. rest
names(gp.end) <- plethspecies$phy$tip
gdf <- geomorph.data.frame(Y.gpa, phy = plethspecies$phy,
gp.end = gp.end)
pleth.ols <- procD.lm(coords ~ Csize + gp.end,
data = gdf) # ordinary least squares
pleth.pgls <- procD.pgls(coords ~ Csize + gp.end, phy = phy,
data = gdf) # phylogenetic generalized least squares
summary(pleth.ols)
summary(pleth.pgls)
morphol.disparity(f1 = pleth.ols, groups = ~ gp.end, data = gdf,
print.progress = FALSE)
morphol.disparity(f1 = pleth.pgls, groups = ~ gp.end,
transform = FALSE, data = gdf,
print.progress = FALSE) # disparity in tangent space
morphol.disparity(f1 = pleth.pgls, groups = ~ gp.end,
transform = TRUE, data = gdf,
print.progress = FALSE) # disparity in transformed space
# Three plots that correspond to the three tests
PCA <- gm.prcomp(Y.gpa$coords, phy = plethspecies$phy)
pPCA <- gm.prcomp(Y.gpa$coords, phy = plethspecies$phy,
GLS = TRUE, transform = FALSE)
tpPCA <- gm.prcomp(Y.gpa$coords, phy = plethspecies$phy,
GLS = TRUE, transform = TRUE)
par(mfrow = c(1,3))
# Phylomorphospace
PC.plot <- plot(PCA, pch = 19, phylo = TRUE, main = "PCA-OLS")
shapeHulls(PC.plot, groups = gp.end)
# Phylo-PCA
pPC.plot <- plot(pPCA, pch = 19, phylo = TRUE, main = "pPCA - GLS, not transformed")
shapeHulls(pPC.plot, groups = gp.end)
# Transformed phylo-PCA
tpPC.plot <- plot(tpPCA, pch = 19, phylo = TRUE, main = "tpPCA - GLS, transformed")
shapeHulls(tpPC.plot, groups = gp.end)
par(mfrow = c(1,1))
### Variance using RRPP (not necessarily the same as disparity)
PW <- pairwise(pleth.ols, groups = gp.end)
summary(PW, test.type = 'var')
PW2 <- pairwise(pleth.pgls, groups = gp.end)
summary(PW2, test.type = 'var')
}
Run the code above in your browser using DataLab