Learn R Programming

MorphoRegions (version 0.1.0)

svdPCO: Calculate PCO (principal co-ordinates analysis) based on SVD

Description

Calculates distance matrix from raw data, then conducts a PCO ordination using a single value decomposition (SVD). This differs from other PCO functions which use stats::cmdscale() and rely on a spectral decomposition.

Usage

svdPCO(x, metric = "gower", scale = TRUE)

Value

A regions_pco object, which contains eigenvectors in the scores component and eigenvalues in the eigen.val component. The original dataset is stored in the data attribute.

Arguments

x

a regions_data object; the output of a call to process_measurements().

metric

string; the distance matrix calculation metric. Allowable options include those support by cluster::daisy(), which are "euclidean", "manhattan", or "gower". Default is "gower". Abbreviations allowed.

scale

logical; whether to scale the variables prior to including them in the PCO estimation. Default is TRUE, which is especially advisable when using the bootstrap to select the number of PCOs to use in downstream analyses. Passed to the stand argument of cluster::daisy(). Ignored if metric = "gower".

See Also

plot.regions_pco() for plotting PCO axes

cluster::daisy(), which is used to compute the distance matrix used in the calculation; stats::cmdscale() for a spectral decomposition-based implementation

Examples

Run this code
data("alligator")

alligator_data <- process_measurements(alligator,
                                       pos = "Vertebra")

# Compute PCOs
alligator_PCO <- svdPCO(alligator_data,
                        metric = "gower")

alligator_PCO

# Plot PCOs against vertebra index
plot(alligator_PCO, pco_y = 1:2)

# Plot PCOs against each other
plot(alligator_PCO, pco_y = 1, pco_x = 2)

Run the code above in your browser using DataLab