scdef.tl.factor_diagnostics ¶
factor_diagnostics(model: scDEF, recompute: bool = False, batch_key: Optional[str] = None, sensible_top_n_eff_parents_max: float = 1.5, sensible_top_min_best_parent_prob: Optional[float] = None, sensible_top_min_clear_children: int = 2, sensible_top_ignore_root: bool = True, sensible_top_use_filtered: bool = True, confidence_threshold: float = 0.9, tau_quantile: float = 0.99, min_effect: Optional[float] = None, mc_samples: int = 100, random_seed: int = 0, batch_split_min_batch_frac: float = 0.7, gene_scale_reference: Optional[Any] = None) -> None
Compute/store factor diagnostics in model.adata.uns['factor_obs'].
Populates per-factor hierarchy scores plus ARD, BRD, n_cells
(hard argmax posterior z assignments among kept factors — the same rule
as annotate_adata / make_graph(..., assignments=True)), and optional
batch metrics when batch_key is set.
Also runs set_confident_signatures so plotting helpers
(make_graph, pl.factor_diagnostics(color='signature_confidence'),
etc.) can use cached signatures without a separate call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
scDEF
|
scDEF model instance |
required |
recompute
|
bool
|
if True, force recomputation of the cached fixed upper-layer factor subset used for clarity scores, even if the fit revision did not change. |
False
|
batch_key
|
Optional[str]
|
key in |
None
|
sensible_top_n_eff_parents_max
|
float
|
threshold used to classify sensible-top factors on the hierarchy walk. |
1.5
|
sensible_top_min_best_parent_prob
|
Optional[float]
|
optional best-parent probability
threshold used alongside |
None
|
sensible_top_min_clear_children
|
int
|
parent escape-hatch count; a parent is accepted if it owns at least this many clear best-parent children, even when weighted ambiguity is high. |
2
|
sensible_top_ignore_root
|
bool
|
whether to ignore a width-1 final root layer when classifying sensible-top factors. |
True
|
sensible_top_use_filtered
|
bool
|
whether to use |
True
|
confidence_threshold
|
float
|
passed to |
0.9
|
tau_quantile
|
float
|
passed to |
0.99
|
min_effect
|
Optional[float]
|
passed to |
None
|
mc_samples
|
int
|
passed to |
100
|
random_seed
|
int
|
passed to |
0
|
batch_split_min_batch_frac
|
float
|
center of the batch-skew ramp that weights
candidate partners in |
0.7
|
gene_scale_reference
|
Optional[Any]
|
optional gene-side batch diagnostic, off by
default. Pass the REFERENCE fit (the model made with |
None
|