calculate_sample_mahalanobis_distances: 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
)
Value
The samples tibble with a new column `pc_distance` which contains the
Mahalanobis distances of individual samples from the PC elipsoid
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.
Examples
Run this codecalculate_sample_mahalanobis_distances(brauer_2008_tidy)
Run the code above in your browser using DataLab