mantispy.metrics.lisi

Contents

mantispy.metrics.lisi#

mantispy.metrics.lisi(adata, key, use_rep='X_pca', perplexity=30, kind='auto')#

Median LISI over rows [Korsunsky et al., 2019].

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

  • key (str) – obs column whose labels the neighborhoods are scored over.

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

  • perplexity (float (default: 30)) – Perplexity the kernel width is calibrated to. Each neighborhood holds 3 * perplexity rows, so an object with no more rows than that cannot support it and the value is NaN.

  • kind (str (default: 'auto')) – "batch" names the result ilisi (higher is better mixed) and "label" names it clisi (lower means the biological groups stay separated). "auto" guesses from the column name: a key containing batch, plate, source, week or run is a batch and anything else a label, so "Metadata_Site" counts as a label. Pass kind explicitly when one table holds both, or the two rows get the same metric name.

Return type:

DataFrame

Returns:

A one-row tidy frame holding ilisi or clisi, whose value is NaN when the object holds too few rows for perplexity, which is what a 48-well plate or a consensus object with one row per perturbation does.

Raises:
  • KeyErrorobsm holds nothing under use_rep.

  • ValueErrorkind is not one of the three accepted values.

  • ValueErrorobs[key] has missing values.