scdef.tl.compute_within_group_pairwise_dissimilarity ¶
compute_within_group_pairwise_dissimilarity(model: scDEF, layer: Union[int, str], obs_key: str, metric: Literal['jsd', 'euclidean', 'cosine'] = 'jsd', eps: float = 1e-12) -> DataFrame
Compute within-group pairwise cell dissimilarity for one layer.
Cells are represented by normalized factor memberships from
model.adata.obsm[f"X_{layer_name}"]. Pairwise distances are computed
within each category of obs_key and summarized per group.
Results are cached in model.adata.uns['within_group_pairwise_dissimilarity'].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
scDEF
|
fitted scDEF model, with |
required |
layer
|
Union[int, str]
|
layer whose factor memberships represent each cell, as an index or a
name from |
required |
obs_key
|
str
|
column in |
required |
metric
|
Literal['jsd', 'euclidean', 'cosine']
|
distance between two cells' membership vectors — |
'jsd'
|
eps
|
float
|
floor applied when normalizing memberships, so that a cell with no assigned factor does not divide by zero. |
1e-12
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per group, summarizing the within-group pairwise distances. Groups |
DataFrame
|
with fewer than two cells yield empty distance sets. |