mantispy.metrics.evaluate_correction

mantispy.metrics.evaluate_correction#

mantispy.metrics.evaluate_correction(adata, *, reps=('X_pca',), label_key='Metadata_Perturbation', batch_key='Metadata_Batch', map_key=None, perplexity=30)#

Run every metric for every representation and stack the results.

Every argument after adata is keyword-only, so a later metric parameter can be added without changing what an existing argument means.

Parameters:
  • adata (AnnData) – Object holding the representations in obsm.

  • reps (Sequence[str] (default: ('X_pca',))) – Representations to compare, e.g. ("X_pca", "X_pca_harmony").

  • label_key (str (default: 'Metadata_Perturbation')) – obs column with the biological grouping.

  • batch_key (str (default: 'Metadata_Batch')) – obs column with the nuisance grouping.

  • map_key (str | None (default: None)) – Name of a table written by map(), to add its mean mAP as one more row. That table is read rather than recomputed, so the row appears once, under the representation that run scored, and not once per entry of reps.

  • perplexity (float (default: 30)) – Perplexity for both lisi() rows. The default needs more than 90 rows, and on a smaller object those two rows are NaN unless a smaller value is passed.

Return type:

DataFrame

Returns:

A tidy frame with metric, representation, key, value and better, the last saying which direction is an improvement for that metric. A metric that is undefined for this object, such as a LISI whose perplexity the row count cannot support or a silhouette over one row per label, is NaN in that frame rather than an error, so one undefined metric still leaves the others readable.

Raises:
  • KeyErrorobsm holds nothing under one of reps.

  • KeyErrormap_key names no table, or nothing recorded the representation behind it.