# 10.4: C.4- R and shape

- Page ID
- 3613

Analysis of biological shape is a really useful technique. Inspired with highly influential works of D’Arcy Thompson\(^{[1]}\), it takes into account not the linear measurements but the *whole shape* of the object: contours of teeth, bones, leaves, flower petals, and even 3D objects like skulls or beaks.

Naturally, shape is not exactly measurement data, it should be analyzed with special approaches. There are methods based on the analysis of curves (namely, Fourier coefficients) and methods which use *landmarks* and *thin-plate splines* (TPS). The last method allows to visualize aligned shapes with PCA (in so-called tangent space) and plot transformation grids.

In R, several packages capable to perform this statistical analysis of shape, or *geometric morphometry*. Fourier analysis is possible with momocs, and landmark analysis used below with geomorph package:

Code \(\PageIndex{1}\) (R):

(One additional function was defined to simplify the workflow.)

Data comes out of leaf measures of alder tree. There are two data files: classic morphometric dataset with multiple linear measurements, and geometric morphometric dataset:

Code \(\PageIndex{2}\) (R):

Geometric morphometric data was prepared with separate program, tpsDig\(^{[2]}\). In the field, every leaf was contoured with sharp pencil, and then all images were scanned.

Next, PNG images were supplied to tpsDig and went through landmark mapping\(^{[3]}\). In total, there were 12 landmarks: top, base, and endpoints of the first (lower) five pairs of primary leaf veins (Figure \(\PageIndex{1}\)). Note that in geometric morphometry, preferable number of cases should be > 11 times bigger then number of variables.

Next step is the *Generalized Procrustes Analysis* (GPA). The name refers to bandit from Greek mythology who made his victims fit his bed either by stretching their limbs or cutting them off (Figure \(\PageIndex{2}\)). GPA aligns all images together:

Code \(\PageIndex{3}\) (R):

... and next—principal component analysis on GPA results:

Code \(\PageIndex{4}\) (R):

(**Check** the PCA screeplot yourself.)

Now we can plot the results (Figure \(\PageIndex{3}\)). For example, let us check if leaves from top branches (high P.1 indices) differ in their shape from leaves of lower branches (small P.1 indices):

Code \(\PageIndex{5}\) (R):

Well, the difference, if even exists, is small.

Now plot *consensus shapes* of top and lower leaves. First, we need *mean shapes* for the whole dataset and separately for lower and top branches, and then *links* to connect landmarks:

Code \(\PageIndex{6}\) (R):

Finally, we plot D’Arcy Thompson’s *transformation grids* (Figure C.5.1):

Code \(\PageIndex{7}\) (R):

Small difference is clearly visible and could be the starting point for the further research.

## References

1. Thompson D. W. 1945. On growth and form. Cambridge, New York. 1140 pp.

2. Rohlf F.J. tpsDig. Department of Ecology and Evolution, State University of New York at Stony Brook. Freely available at life.bio.sunysb.edu/morph/

3. Actually, geomorph package is capable to digitize images with digitize2d() function but it works only with JPEG images.