Skip to content

scdef.tl.get_confident_signatures

get_confident_signatures(model: scDEF, layer_idx: int = 0, confidence_threshold: float = 0.9, tau_quantile: float = 0.99, min_effect: Optional[float] = None, max_genes: Optional[int] = None, mc_samples: int = 100, random_seed: int = 0, return_confidences: bool = False) -> Union[Dict[str, List[str]], Tuple[Dict[str, List[str]], Dict[str, ndarray]]]

Get confidence-based signatures per factor using posterior mean/variance.

For each factor independently, this computes a per-factor threshold tau = quantile(E[W_k,:], tau_quantile) and keeps genes that satisfy P(W_k,g > tau) >= confidence_threshold under a normal approximation using the posterior mean and variance of W.

For layer_idx > 0, confidences are estimated with Monte Carlo sampling from the variational posterior via model.get_signature_sample.

Parameters:

Name Type Description Default
model scDEF

scDEF model instance

required
layer_idx int

layer index to use

0
confidence_threshold float

minimum posterior confidence to keep a gene

0.9
tau_quantile float

quantile of factor mean loadings used as threshold tau

0.99
min_effect Optional[float]

optional minimum posterior mean loading E[W_k,g]

None
max_genes Optional[int]

optional maximum number of genes to keep per factor

None
mc_samples int

number of Monte Carlo samples used for layer_idx > 0 confidence estimation

100
random_seed int

random seed for Monte Carlo sampling in upper layers

0
return_confidences bool

whether to also return per-gene confidence arrays

False

Genes are ranked by a combined DE-style score that uses both confidence and posterior mean loading: score = E[W_k,g] * -log10(1 - confidence_k,g).

Returns:

Type Description
Union[Dict[str, List[str]], Tuple[Dict[str, List[str]], Dict[str, ndarray]]]

Dictionary mapping factor names to confident gene lists. If

Union[Dict[str, List[str]], Tuple[Dict[str, List[str]], Dict[str, ndarray]]]

return_confidences is True, also returns a dictionary mapping

Union[Dict[str, List[str]], Tuple[Dict[str, List[str]], Dict[str, ndarray]]]

factor names to confidence arrays aligned with each gene list.