calculate_sample_mahalanobis_distances: Calculate Sample Mahalanobis Distances

calculate_sample_mahalanobis_distancesR Documentation

Calculate Sample Mahalanobis Distances

Description

Determine each samples distance from the center of the data using Mahalanobis distance.

Usage

calculate_sample_mahalanobis_distances(
  tomic,
  value_var = NULL,
  max_pcs = 10,
  scale = FALSE
)

Arguments

tomic

Either a tidy_omic or triple_omic object

value_var

the measurement variable to use for calculating distances

max_pcs

the maximum number of principal components to used for representing the covariance matrix.

scale

if TRUE then the data will be scaled before calculating distances

Details

Since 'romic' is built around using tall data where there are more features than samples calculating Mahalanobis distance off of the covariance matrix is not possible. Instead, we use SVD to create a low-dimensional representation of the covariance matrix and calculate distances from the center of the data in this space. This essentially involves weighting the principal components by their loadings.

Value

The samples tibble with a new column 'pc_distance' which contains the Mahalanobis distances of individual samples from the PC elipsoid

Examples

calculate_sample_mahalanobis_distances(brauer_2008_tidy)

calico/romic documentation built on Sept. 27, 2024, 7:16 p.m.