evolocity.tl.random_walk

evolocity.tl.random_walk(data, root_node=0, walk_length=10, n_walks=1, forward_walk=True, path_key='rw_paths', vkey='velocity', groupby=None, groups=None, self_transitions=False, eps=0.001, random_state=0, copy=False, **kwargs)

Runs a random walk on the evolocity graph.

Parameters
data : AnnData

Annotated data matrix.

root_node : int (default: 0)

Index of node at which to start random walk.

walk_length : int (default: 10)

Number of steps in walk.

n_walks : int (default: 1)

Number of walks to take.

forward_walk : bool (default: True)

Whether to go in the same or reverse direction of evolocity.

path_key : str (default: ‘rw_paths’)

Name at which to store the random walks.

vkey : str (default: ‘velocity’)

Name of velocity estimates to be used.

groupby : str, list or np.ndarray (default: None)

Key of observations grouping to consider. Only to be set, if each group is assumed to have a distinct lineage with an independent root and end point.

groups : str, list or np.ndarray (default: None)

Groups selected to find terminal states on. Must be an element of .obs[groupby]. To be specified only for very distinct/disconnected clusters.

self_transitions : bool (default: False)

Allow transitions from one node to itself.

eps : float (default: 1e-3)

Tolerance for eigenvalue selection.

random_state : int or None (default: 0)

Seed used by the random number generator. If None, use the RandomState instance by np.random.

copy : bool (default: False)

Return a copy instead of writing to data.

**kwargs

Passed to evolocity.tl.transition_matrix(), e.g. scale, basis.

Returns

  • Returns or updates data with the attributes

  • rw_paths (.uns) – rows of matrix correspond to random walks, columns correspond to steps