mantispy.metrics.pc_regression

Contents

mantispy.metrics.pc_regression#

mantispy.metrics.pc_regression(adata, key, use_rep='X_pca', n_comps=None)#

Variance-weighted R^2 of the principal components on key.

The value is the share of total variance the covariate explains, so for a batch key lower is better.

Parameters:
  • adata (AnnData) – Object with the embedding to measure in.

  • key (str) – obs column the components are regressed on.

  • use_rep (str (default: 'X_pca')) – obsm key of the embedding.

  • n_comps (int | None (default: None)) – Use only the leading components, or None for every component the embedding holds.

Return type:

DataFrame

Returns:

A one-row tidy frame holding pc_regression.

Raises:

KeyErrorobsm holds nothing under use_rep.