plastro.plasticity.random_walk_plasticity

plastro.plasticity.random_walk_plasticity(full_simulated_ad: AnnData, subset_simulated_ad: AnnData, plastic_cells: Dict[str, List[str]], walk_lengths: Dict[str, int], latent_space_key: str = 'X_dc') AnnData[source]

Simulate random walk plasticity in single cells.

Performs random walks on specified plastic cells to simulate phenotypic transitions. Plastic cells from different leiden clusters perform walks of specified lengths, and their phenotypes are replaced with their walk targets.

Parameters:
  • full_simulated_ad (anndata.AnnData) – Complete simulated dataset used for performing random walks.

  • subset_simulated_ad (anndata.AnnData) – Subset of the dataset containing cells to be analyzed.

  • plastic_cells (Dict[str, List[str]]) – Dictionary mapping leiden cluster identifiers to lists of cell names that will undergo plastic transitions.

  • walk_lengths (Dict[str, int]) – Dictionary mapping leiden cluster identifiers to walk lengths. Must contain entries for all keys in plastic_cells.

  • latent_space_key (str, optional) – Key in the obsm attribute of the AnnData object that contains the latent space representation. Default is ‘X_dc’.

Returns:

Modified dataset with plastic cells replaced by their walk targets. Non-plastic cells remain unchanged.

Return type:

anndata.AnnData

Raises:

AssertionError – If walk_lengths keys don’t match plastic_cells keys.

Examples

>>> plastic_cells = {'0': ['Cell_1', 'Cell_2'], '1': ['Cell_3']}
>>> walk_lengths = {'0': 100, '1': 50}
>>> result = random_walk_plasticity(full_ad, subset_ad, plastic_cells, walk_lengths)

Notes

This function modifies cell phenotypes by replacing plastic cells with cells that represent their final positions after random walks. The walk parameters (p, q) are set within the perform_random_walk function.