scdef.tl.set_cell_entropies ¶
set_cell_entropies(model: scDEF, layers: Optional[Sequence[Union[int, str]]] = None, key_suffix: str = 'entropy', effective_suffix: str = 'effective_n_factors', normalize: bool = True, eps: float = 1e-12) -> List[str]
Compute per-cell assignment entropy and store one column per layer.
For each selected layer, uses model.adata.obsm[f"X_{layer_name}"] to
build per-cell membership probabilities and computes Shannon entropy.
If normalize=True, entropy is divided by log(n_factors_layer) so
values are approximately in [0, 1] (for layers with >1 factors).
Also stores an effective number of factors per cell, defined as
exp(H) where H is the non-normalized Shannon entropy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
scDEF
|
fitted scDEF model, with |
required |
layers
|
Optional[Sequence[Union[int, str]]]
|
layers to compute entropy for, as indices or names. Defaults to every layer. |
None
|
key_suffix
|
str
|
suffix of the entropy column written to |
'entropy'
|
effective_suffix
|
str
|
suffix of the effective-number-of-factors column, written as
|
'effective_n_factors'
|
normalize
|
bool
|
divide the entropy by |
True
|
eps
|
float
|
floor applied before normalizing and before taking logs, to keep zero memberships from producing infinities. |
1e-12
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of created/updated entropy column names. |