update.gpa.pca: Update GPA and PCA

View source: R/update.gpa.pca.R

update.gpa.pcaR Documentation

Update GPA and PCA

Description

Adds new specimens (landmarks) to an existing GPA and PCA.

Usage

update.gpa.pca(
  original_data,
  new_landmarks,
  center.pca = TRUE,
  scale.pca = FALSE,
  ...
)

Arguments

original_data

Either an "array" that is a named set of n landmarks in D dimensions corresponding to the original specimens; or directly a "nosymproc" or "symproc" object output from Morpho::procSym.

new_landmarks

a named set of n landmarks in D dimensions corresponding to the new specimens

center.pca

logical, if original_data is "nosymproc" or "symproc", whether to calculate the centering vector for the pca (default is TRUE).

scale.pca

logical, if original_data is "nosymproc" or "symproc", whether to calculate the centering vector for the pca (default is FALSE).

...

any optional arguments to pass to Morpho::procSym.

Details

This function does the following:

  • 1- Either runs a GPA (using Morpho::ProcSym) and a PCA (using stats::prcomp) if the input is an "array" of landmarks; or extracts the GPA and runs a PCA (using stats::prcomp) if the input is a "nosymproc" or "symproc" object.

  • 2- Aligns the new landmarks onto the original GPA (using Morpho::align2procSym).

  • 3- Projects these superimposed landmarks onto the original PCA (using stats::predict).

  • 4- Merges and output the combined PCA containing the new specimens.

Author(s)

Thomas Guillerme

Examples


## Get some 3D data from Morpho
library(Morpho)
data(boneData)
original_landmarks <- boneLM

## Generate some random 3D data
new_spec <- array(data = c(apply(original_landmarks, c(1,2), mean),
                           apply(original_landmarks, c(1,2), median),
                           unlist(select.procrustes(proc_orig$rotated, selector = min))),
                           dim = c(10, 3, 3))
dimnames(new_spec)[[3]] <- paste0("new_", c("mean", "median", "min"))


## Run the GPA/PCA from the landmarks
update.gpa.pca(original_landmarks, new_spec)

## Run the GPA/PCA from a GPA
proc_orig <- Morpho::procSym(original_landmarks)
update.gpa.pca(proc_orig, new_spec)



TGuillerme/landvR documentation built on July 4, 2025, 10:16 p.m.