When performing GM analyses with geomorph it is
necessary that all landmark coordinates be aligned via Generalized Procrustes Analysis using the
gpagen function. Of important note, however, is that the
gpagen function does not automatically reflect specimens
that are of a different side than the rest of a bilateral dataset
(i.e. left vs. right).
Avoiding mismatched sides altogether is often not feasible due to the
nature of data collection, however there is a quick way to reflect
off-sided landmarks using the rotate.coords function, which
we will discuss here.
rotate.coords() (Expand for more details)`
This function is meant to be used only for 2D landmark coordinates.
wings <- gpagen(mosquito$wingshape[,,1:5], print.progress = F)
plotAllSpecimens(wings$coords)

wingsflip <- rotate.coords(wings$coords, type = "flipX")
plotAllSpecimens(wingsflip)

In this example, the fourth specimen is flipped along the x-axis opposite to the rest.

To re-align it to the rest of our data, we need to create a vector of binary inputs, the fourth of which is a 1. This specifies that the fourth specimen is the only one to be flipped. Then we run the function as normal:
flip <- c(0,0,0,1,0)
wingsflip <- rotate.coords(wings, type = "flipX", index = flip)
plotAllSpecimens(wingsflip)
