Skip to content

scdef.tl.multilayer_umap

multilayer_umap(model: scDEF, layers: Optional[Sequence[int]] = None, weights: Optional[Sequence[float]] = None, normalize_per_layer: bool = False, use_log: bool = False, metric: str = 'euclidean', key_added: str = 'multilayer', eps: float = 1e-08, neighbors_kwargs: Optional[Dict[str, object]] = None, umap_kwargs: Optional[Dict[str, object]] = None) -> ndarray

Compute a single UMAP from the concatenation of all scDEF layers.

Each cell's representation is the concatenation of its soft factor assignments X_{layer_name} across the selected layers, producing a multi-resolution signature that encodes identity at every level of the hierarchy simultaneously.

This tends to produce a lineage-aware embedding that smooths through differentiation trajectories: terminally differentiated cells form tight clusters by shared fine-layer factor, progenitor cells bridge siblings through their shared parent-layer mass, and stem-like cells with diffuse scores sit in their own regime. Contrast with umap (per-layer), which only captures a single scale.

By default it uses raw per-layer scores as stored in X_{layer}. Set normalize_per_layer=True to convert each layer's row to proportions before optional log/weighting; this makes geometry reflect relative composition at each layer rather than absolute score scale.

Use weights to bias the embedding toward fine or coarse resolution.

Single-factor layers (K_k == 1, typically the root) are skipped automatically — every cell has mass 1 there, so they add no discriminative signal.

Parameters:

Name Type Description Default
model scDEF

fitted scDEF model.

required
layers Optional[Sequence[int]]

layer indices to include. If None, uses all layers with K_k >= 2, in ascending order.

None
weights Optional[Sequence[float]]

optional per-layer multiplicative weights applied to each layer's sub-vector before concatenation. Must have the same length as layers. Larger weight → that layer has more influence on the embedding geometry. Default: uniform.

None
normalize_per_layer bool

if True, row-normalize each selected layer block so rows sum to 1 before optional log and weighting. Useful when you want distances to depend on relative factor composition rather than total per-layer score magnitude.

False
use_log bool

if True, replace each sub-vector by log(X + eps) before applying weights/concatenation. Helpful when fine resolution is dominated by a single factor and small proportions get crushed by Euclidean distance.

False
metric str

distance metric for sc.pp.neighbors.

'euclidean'
key_added str

suffix used to store results. Writes adata.obsm[f"X_{key_added}"] (the concatenated representation) and adata.obsm[f"X_umap_{key_added}"] (the UMAP embedding).

'multilayer'
eps float

floor for log when use_log=True.

1e-08
neighbors_kwargs Optional[Dict[str, object]]

extra kwargs forwarded to sc.pp.neighbors.

None
umap_kwargs Optional[Dict[str, object]]

extra kwargs forwarded to sc.tl.umap.

None

Returns:

Type Description
ndarray

The concatenated representation of shape (n_cells, sum K_k).