cellrank.external.kernels.WOTKernel.plot_random_walks
- WOTKernel.plot_random_walks(n_sims, max_iter=0.25, seed=None, successive_hits=0, start_ixs=None, stop_ixs=None, basis='umap', cmap='gnuplot', linewidth=1.0, linealpha=0.3, ixs_legend_loc=None, n_jobs=None, backend='loky', show_progress_bar=True, figsize=None, dpi=None, save=None, **kwargs)
Plot random walks in an embedding.
This method simulates random walks on the Markov chain defined though the corresponding transition matrix. The method is intended to give qualitative rather than quantitative insights into the transition matrix. Random walks are simulated by iteratively choosing the next cell based on the current cell’s transition probabilities.
- Parameters
n_sims (
int
) – Number of random walks to simulate.max_iter (
Union
[int
,float
]) – Maximum number of steps of a random walk. If afloat
, it can be specified as a fraction of the number of cells.successive_hits (
int
) – Number of successive hits in thestop_ixs
required to stop prematurely.start_ixs (
Union
[Sequence
[str
],Dict
[str
,Union
[str
,Sequence
[str
],Tuple
[float
,float
]]],None
]) –Cells from which to sample the starting points. If None, use all cells. Can be specified as:
dict
- dictionary with 1 key inanndata.AnnData.obs
with values corresponding to either 1 or more clusters (if the column is categorical) or atuple
specifying [min, max] interval from which to select the indices.typing.Sequence
- sequence of cell ids inanndata.AnnData.obs_names
.
For example
{'dpt_pseudotime': [0, 0.1]}
means that starting points for random walks will be sampled uniformly from cells whose pseudotime is in [0, 0.1].stop_ixs (
Union
[Sequence
[str
],Dict
[str
,Union
[str
,Sequence
[str
],Tuple
[float
,float
]]],None
]) –Cells which when hit, the random walk is terminated. If None, terminate after
max_iters
. Can be specified as:dict
- dictionary with 1 key inanndata.AnnData.obs
with values corresponding to either 1 or more clusters (if the column is categorical) or atuple
specifying [min, max] interval from which to select the indices.typing.Sequence
- sequence of cell ids inanndata.AnnData.obs_names
.
For example
{'clusters': ['Alpha', 'Beta']}
andsuccessive_hits = 3
means that the random walk will stop prematurely after cells in the above specified clusters have been visited successively 3 times in a row.basis (
str
) – Basis inanndata.AnnData.obsm
to use as an embedding.cmap (
Union
[str
,LinearSegmentedColormap
]) – Colormap for the random walk lines.linewidth (
float
) – Width of the random walk lines.linealpha (
float
) – Alpha value of the random walk lines.ixs_legend_loc (
Optional
[str
]) – Legend location for the start/top indices.show_progress_bar (
bool
) – Whether to show a progress bar. Disabling it may slightly improve performance.n_jobs (
Optional
[int
]) – Number of parallel jobs. If -1, use all available cores. If None or 1, the execution is sequential.backend (
str
) – Which backend to use for parallelization. Seejoblib.Parallel
for valid options.figsize (
Optional
[Tuple
[float
,float
]]) – Size of the figure.save (
Union
[str
,Path
,None
]) – Filename where to save the plot.kwargs (
Any
) – Keyword arguments forscvelo.pl.scatter()
.
- Return type
- Returns
Nothing, just plots the figure. Optionally saves it based on
save
. For each random walk, the first/last cell is marked by the start/end colors ofcmap
.