scdef.tl.get_batch_specific_genes_from_gene_scale ¶
get_batch_specific_genes_from_gene_scale(model: 'scDEF', *, eps: float = 1e-12, log_base: float = 2.0, reference: Literal['mean_other_batches', 'global_mean'] = 'mean_other_batches') -> DataFrame
Per-gene log-ratios of batch-specific gene_scale vs a reference profile.
After fitting (and annotate_adata), scDEF stores inferred positive gene
scaling factors in model.pmeans["gene_scale"] with shape
(n_batches, n_genes) when batch_key was set with at least two batches.
Higher scale for a gene in a batch means the model explains more variance /
signal for that gene in that batch (relative to the Gamma prior mean encoded
in gene_ratio).
For each batch b, this computes::
log_ratio[g, b] = log( scale[b, g] + eps ) - log( ref[g] + eps )
with log at the chosen base (default log2), and ref either the mean
of the other batches at gene g (default) or the global mean across all
batches at g.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
'scDEF'
|
Fitted scDEF model whose |
required |
eps
|
float
|
Small constant for numerical stability. |
1e-12
|
log_base
|
float
|
Logarithm base ( |
2.0
|
reference
|
Literal['mean_other_batches', 'global_mean']
|
|
'mean_other_batches'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame indexed like |
DataFrame
|
label in |
DataFrame
|
dimension). Positive entries indicate relatively higher |
DataFrame
|
that batch vs the chosen reference. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |