scdef.tl.score_paths ¶
score_paths(model: scDEF, paths_key: str = 'transition_paths', key_added: Optional[str] = None, normalize_per_layer: bool = True, min_affinity: float = 0.0, eps: float = 1e-12) -> None
Score per-cell position and affinity on previously built paths.
Writes
adata.obsm[f"{prefix}_positions"](n_cells, n_paths)adata.obsm[f"{prefix}_affinities"](n_cells, n_paths)- per-path summary table in
adata.uns[paths_key]["path_stats"].
Position is how far along a path a cell sits; affinity is how well the path describes that cell at all. Read them together — a position is only meaningful for a cell whose affinity is high.
Differentiation paths (root to leaf): the position averages the coordinates of all path nodes, weighted by the cell's scores on them, and the affinity is the share of the cell's total score that falls on the path.
Transition paths (a terminal factor, up to a shared ancestor, down to another
terminal factor): the position uses only the path's terminal-layer nodes, the
source at 0 and the target at 1, weighted by the cell's normalised weights on
them, because an ancestor carries weight for every cell under it and would pull
every cell to the middle. The affinity is the cell's normalised weight on the
path's apex (its node in the highest layer), the lineage that connects the two
states, read through the tree: the share of the cell's terminal-layer weight on
the terminal factors whose strongest-parent chain reaches the apex, as
make_graph draws it. It lies in [0, 1] whatever the
length of the path. Cells in other factors below the apex, such as intermediate
states, keep a high affinity and are placed by their remaining weight on the
source and target. A path through a high apex covers much of the data, so the
shortest path between two states is usually the informative one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
scDEF
|
fitted scDEF model. |
required |
paths_key
|
str
|
|
'transition_paths'
|
key_added
|
Optional[str]
|
prefix for the two |
None
|
normalize_per_layer
|
bool
|
scale factor scores within each layer before scoring, so that layers with larger raw scores do not dominate a path's position. |
True
|
min_affinity
|
float
|
floor in |
0.0
|
eps
|
float
|
small constant guarding the normalizations against division by zero. |
1e-12
|