Skip to content

scdef.pl.within_group_pairwise_dissimilarity

within_group_pairwise_dissimilarity(model: scDEF, layer: Union[int, str], obs_key: str, metric: Literal['jsd', 'euclidean', 'cosine'] = 'jsd', kind: Literal['box', 'violin'] = 'box', showfliers: bool = False, figsize: Tuple[float, float] = (8, 4), show: bool = True) -> Optional[Figure]

Plot within-group pairwise dissimilarity distributions.

Uses cached results from model.adata.uns['within_group_pairwise_dissimilarity'] when available, otherwise computes them with scdef.tl.compute_within_group_pairwise_dissimilarity.

A group whose cells sit far apart in factor space is heterogeneous at that resolution, which is a reason to look for structure inside it at a finer layer.

Parameters:

Name Type Description Default
model scDEF

fitted scDEF model.

required
layer Union[int, str]

layer whose factor memberships represent each cell, as an index or a name from model.layer_names.

required
obs_key str

adata.obs column defining the groups.

required
metric Literal['jsd', 'euclidean', 'cosine']

distance between two cells' membership vectors — "jsd" (Jensen-Shannon, the default), "euclidean", or "cosine".

'jsd'
kind Literal['box', 'violin']

draw each group's distribution as a box or a violin.

'box'
showfliers bool

draw outlier points beyond the whiskers. Only affects "box".

False
figsize Tuple[float, float]

figure size in inches.

(8, 4)
show bool

call plt.show(). Set False to get the figure back instead.

True

Returns:

Type Description
Optional[Figure]

The figure when show is False, otherwise None.