mantispy.pl.batch_variance#

mantispy.pl.batch_variance(adata, keys, use_rep='X_pca', n_comps=None, ax=None)[source]#

R^2 of each principal component on each covariate.

A covariate with high R^2 in the leading components accounts for much of the embedding’s structure.

Parameters:
adata AnnData

Object with the embedding to measure in.

keys Sequence[str]

obs columns to score, one line each.

use_rep str (default: 'X_pca')

obsm key of the embedding.

n_comps int | None (default: None)

Draw only the leading components, or None for every component the embedding holds.

ax Axes | None (default: None)

Axes to draw on, or None for a new figure.

Return type:

Axes | None

Returns:

The axes when the caller passed ax, else None because the plot then owns the figure it created. When returned they hold one line per entry of keys and the y axis fixed to [0, 1].

Raises:

KeyError – obsm holds nothing under use_rep, or obs has no column for one of keys.