Skip to contents

Runs PCA on the feature and sample spaces of a MultiAssayExperiment object, identifying outliers based on Mahalanobis distance.

Usage

run_pca(
  expomicset,
  log_trans_exp = FALSE,
  log_trans_omics = TRUE,
  action = "add"
)

Arguments

expomicset

A MultiAssayExperiment object containing omics and exposure data.

log_trans_exp

A boolean value specifying whether to log2 transform the exposure data

log_trans_omics

a boolean value specifying whether to log2 transform the omics data

action

A character string specifying whether to store ("add") or return ("get") the results. Default is "add".

Value

A MultiAssayExperiment object with PCA results added to metadata (if action = "add") or a list with:

pca_df

A tibble of the transformed input data.

pca_feature

A prcomp object containing PCA results for features.

pca_sample

A prcomp object containing PCA results for samples.

outliers

A character vector of detected sample outliers.

Details

This function:

  • Identifies common samples across all assays and exposure data.

  • Performs PCA on features (transformed and standardized).

  • Performs PCA on samples and computes Mahalanobis distance to detect outliers.

  • Output Handling:

    • "add": Stores results in metadata(expomicset)$pca and updates colData with PCs.

    • "get": Returns a list containing the PCA results.

Examples

if (FALSE) { # \dontrun{
expom <- run_pca(expomicset = expom, action = "add")
pca_results <- run_pca(expomicset = expom, action = "get")
} # }