Skip to content

scdef.sscDEF

sscDEF(adata: AnnData, top_key: str, add_root: bool = True, **kwargs: Any)

Bases: scDEF

Supervised scDEF (sscDEF): cell-type labels fix the top hierarchy. Experimental.

Experimental

sscDEF has unit tests covering its construction and layer shapes, but it has not been validated on real data and is not actively developed. Prefer scDEF for unsupervised fits and iscDEF when you have marker gene lists. Expect rough edges, and check any result it produces.

Layer sizes and W priors match scDEF (geometric schedule from n_factors / n_layers, or explicit layer_sizes). By default a width-1 root is appended above the supervised top layer (fitted in a second phase via root_epochs, default 10). Pass add_root=False to use only the supervised layer as the coarsest level.

Top-layer cell-factor usage z is fixed to binary assignments (1 on the annotated population, near-zero elsewhere). During fitting the top z is not sampled from the variational posterior and its parameters are not optimized; all other layers are learned as in scDEF.

Parameters:

Name Type Description Default
adata AnnData

AnnData with counts in adata.X or counts_layer.

required
top_key str

adata.obs column with cell population / cell-type labels.

required
add_root bool

if True (default), append a width-1 root above the supervised top layer.

True
**kwargs Any

forwarded to scDEF; see that page for the shared construction parameters. n_factors, n_layers, layer_sizes and layer_names keep their meaning there, except that n_layers counts layers from L0 through the supervised top and the add_root layer is not counted in it. root_epochs sets the length of the root-only phase.

{}

Methods:

Name Description
fit

Fit sscDEF; the supervised top layer z is held fixed.

fit

fit(root_epochs: int = 0, **kwargs: Any) -> None

Fit sscDEF; the supervised top layer z is held fixed.

When add_root=True, delegates to fit two-phase scheduling (frozen root during the main fit, then root_epochs on the root). Defaults to root_epochs=10 when add_root and root_epochs is 0.