# NOT RUN {
data(plethspecies)
Y.gpa <- gpagen(plethspecies$land) #GPA-alignment
### PCA
pleth.raw <- gm.prcomp(Y.gpa$coords)
summary(pleth.raw)
### PCA with phylogeny (result is same as above, but with additional components)
pleth.phylo <- gm.prcomp(Y.gpa$coords, phy = plethspecies$phy)
summary(pleth.phylo)
#### Plotting
plot(pleth.raw)
gps <- as.factor(c(rep("gp1", 5), rep("gp2", 4))) # Two random groups
par(mar=c(2, 2, 2, 2))
plot(pleth.raw, pch=22, cex = 1.5, bg = gps) # Modify options as desired
# Add things as desired using standard R plotting
text(par()$usr[1], 0.1*par()$usr[3], labels = "PC1 - 45.64%", pos = 4, font = 2)
text(0, 0.95*par()$usr[4], labels = "PC2 - 18.80%", pos = 4, font = 2)
legend("topleft", pch=22, pt.bg = unique(gps), legend = levels(gps))
### Phylomorphospace plot
plot(pleth.phylo, pch=21, bg=1:nrow(pleth.phylo$x), phylo = TRUE,
phylo.par = list(edge.color="grey", node.cex=0)); title(main="phylomorphospace")
text(pleth.phylo$x, labels = labels(pleth.phylo$x)[[1]],
pos = 2, font = 4)
text(pleth.phylo$anc.x, labels = 1:nrow(pleth.phylo$anc.x),
adj = c(-0.1, -0.1), font = 2)
### Visualize shape variation using picknplot.shape Because picknplot requires
### user decisions, the following example
### is not run (but can be with removal of #).
### For detailed options, see the picknplot help file
# picknplot.shape(plot(pleth.phylo))
# }
Run the code above in your browser using DataLab