pc_meta_correlations() computes associations between PCA axes and metadata columns. Numeric metadata are tested by correlation, while categorical metadata are tested by ANOVA and reported with eta-squared effect sizes.

pc_meta_correlations(
  object,
  metadata = NULL,
  reduction = "pca",
  meta.cols = NULL,
  method = c("pearson", "spearman"),
  mode = c("lm", "correlation"),
  adjust = c("BH", "bonferroni", "none"),
  min.cells = 10,
  verbose = TRUE
)

Arguments

object

A Seurat object, a numeric PCA matrix, or a data frame containing principal component embeddings.

metadata

A data frame of metadata variables. If object is a Seurat object, this defaults to the object's metadata. Otherwise this argument is required.

reduction

Name of the PCA reduction to use when object is a Seurat object. Default: "pca".

meta.cols

Character or integer vector of metadata columns to analyse. Default: all columns.

method

Correlation method for numeric metadata or ranking method for linear-model mode: "pearson" or "spearman".

mode

Analysis mode: "lm" for linear regression or "correlation" for simple correlation/ANOVA.

adjust

p-value adjustment method passed to p.adjust(). Default: "BH".

min.cells

Minimum non-missing values required for a metadata column. Default: 10.

verbose

If TRUE, print progress messages.

Value

A data frame with one row per metadata variable and PC axis pair. Columns include metadata, pc, type, statistic, p.value, adj.p.value, effect_size, and direction.