Skip to content

scdef.pl.path_embedding

path_embedding(model: scDEF, path_id: Union[int, str] = 'auto', paths_key: str = 'transition_paths', score_key: Optional[str] = None, basis: str = 'umap_multilayer', min_affinity: float = 0.0, affinity_alpha_range: Tuple[float, float] = (0.15, 1.0), cmap: str = 'viridis', point_size: float = 10.0, show_background: bool = True, background_color: str = 'lightgray', background_alpha: float = 0.2, obs_key: Optional[str] = None, obs_order: Optional[Sequence[str]] = None, ncols: int = 3, ax: Optional[Axes] = None, show: bool = True) -> Optional[Figure]

Plot cells on an embedding colored by position along one path.

This visualization uses outputs from scd.tl.score_paths: - adata.obsm[f"{score_key}_positions"] - adata.obsm[f"{score_key}_affinities"].

Color encodes path position (0->1), and point alpha scales with path affinity. If obs_key is provided, draws one facet per category value.

Parameters:

Name Type Description Default
model scDEF

fitted scDEF model scored by scdef.tl.score_paths.

required
path_id Union[int, str]

which path to draw, as an index or a stored path name. "auto" picks the path with the most cells above min_affinity.

'auto'
paths_key str

adata.uns key holding the built paths.

'transition_paths'
score_key Optional[str]

prefix of the obsm matrices written by score_paths. Defaults to paths_key.

None
basis str

adata.obsm embedding to plot on, without the X_ prefix.

'umap_multilayer'
min_affinity float

hide cells whose affinity for the path falls below this, so the plot shows only cells the path actually describes.

0.0
affinity_alpha_range Tuple[float, float]

opacity range mapped from affinity, as (min, max) — the low end keeps weakly-associated cells faintly visible rather than invisible.

(0.15, 1.0)
cmap str

colormap for path position.

'viridis'
point_size float

marker size for the plotted cells.

10.0
show_background bool

draw the cells that are not on the path underneath, for context.

True
background_color str

color of those background cells.

'lightgray'
background_alpha float

opacity of those background cells.

0.2
obs_key Optional[str]

adata.obs column to facet by, one panel per category.

None
obs_order Optional[Sequence[str]]

order of the facets. Defaults to the category order.

None
ncols int

number of facet columns.

3
ax Optional[Axes]

existing axes to draw into. Only valid when not faceting.

None
show bool

call plt.show(). Set False to get the figure back instead.

True

Returns:

Type Description
Optional[Figure]

The figure when show is False, otherwise None.