calculate.ellipse.area - Calculate the size of morphological space occupied by taxa from multivariate morphological data

This wrapper function calculates the amount of morphological space occupied by taxa based on the first two principle components from a principle component analysis

The function code can be downloaded here

library(pracma)
library(car)
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:pracma':
## 
##     logit
## ggbiplot is used for visualizing the data
library(ggbiplot)
## Loading required package: ggplot2
## Loading required package: plyr
## Loading required package: scales
## Loading required package: grid

Load the data, and load the functions

dat <- read.csv("test.data.csv")

head(dat)
##   Subspecies Wing   Tail Tarsus Mid.Toe Culmen.Depth Culmen.Width
## 1 orientalis  190 104.20   17.8    21.8        15.00        26.15
## 2 orientalis  196  98.00   20.0    25.0        18.00        28.50
## 3 orientalis  188 102.30   18.6    21.1        16.10        27.25
## 4 orientalis  175  97.25   17.7    20.3        12.00        23.90
## 5 orientalis  191 105.00   17.6    21.3        15.45        24.20
## 6 orientalis  189  99.00   17.6    20.4        16.40        25.65
##   Culmen.Length
## 1          20.1
## 2          23.9
## 3          22.0
## 4          19.9
## 5          20.5
## 6          19.6
source("calculate.ellipse.area.R")

First we will do a manual analysis for visualization using ggbiplot. This is useful to make sure that the results returned agree visually with the data

# Group information from our data
grp <- dat$Subspecies
pca1 <- prcomp(dat[,-1],scale=TRUE)
g <- ggbiplot(pca1, obs.scale = 1, var.scale = 1, 
              groups = grp, ellipse = TRUE, circle = FALSE)
g <- g + theme(legend.direction = 'horizontal', 
              legend.position = 'top')
g <- g + coord_fixed(ratio = 1.5)
g <- g +geom_point(size=1, aes(colour = grp))
print(g)

Now we can fun the main function to calculate the volume of each ellipse The function takes the following arguments:

* morpho.data: A `data.frame` of the morphological characters for each species
* group.info: A `factor` specifying what group each row in the `data.frame` belongs to
* conf.interval: What confidence interval to calculate the ellipses at
* scale.pca: Logical, should the principal components analysis scale the measurements before calculating the priniple components?
# Group information from our data
grp <- dat$Subspecies

results <- calculate.morpho.poly.area(dat[,-1], group.info=grp, conf.interval=0.9, scale.pca =TRUE)

results
##            PolygonArea NumObservations
## orientalis   20.067622               6
## laetior      14.281997               3
## abundas      22.994750               6
## gigas         7.618484               4
## pacificus     9.381595               4