evolocity.tl.velocity_graph

evolocity.tl.velocity_graph(adata, model_name='esm1b', mkey='model', score='lm', seqs=None, vkey='velocity', n_recurse_neighbors=0, random_neighbors_at_max=None, mode_neighbors='distances', include_set=None, copy=False, verbose=True)

Computes velocity scores at each edge in the graph.

At each edge connecting two sequences \((x^{(a)}, x^{(b)})\), computes a score

\[v_{ab} = \frac{1}{|\mathcal{M}|} \sum_{i \in \mathcal{M}} \left[ \log p\left( x_i^{(b)} | x^{(a)} \right) - \log p\left( x_i^{(a)} | x^{(b)} \right) \right]\]

where \(\mathcal{M} = \left\{ i : x_i^{(a)} \neq x_i^{(b)} \right\}\) is the set of positions at which the amino acid residues disagree.

Parameters
adata : Anndata

Annoated data matrix.

model_name : str (default: ‘esm1b’)

Language model used to compute likelihoods.

mkey : str (default: ‘model’)

Name at which language model is stored.

score : str (default: ‘lm’)

Type of velocity score.

seqs : list (default: ‘None’)

List of sequences; defaults to those in adata.obs[‘seq’].

vkey : str (default: ‘velocity’)

Name of velocity estimates to be used.

n_recurse_neighbors : int (default: 0)

Number of recursions for neighbors search.

random_neighbors_at_max : int or None (default: None)

If number of iterative neighbors for an individual node is higher than this threshold, a random selection of such are chosen as reference neighbors.

mode_neighbors : str (default: ‘distances’)

Determines the type of KNN graph used. Options are ‘distances’ or ‘connectivities’. The latter yields a symmetric graph.

include_set : set (default: None)

Set of characters to explicitly include.

verbose : bool (default: True)

Print logging output.

copy : bool (default: False)

Return a copy instead of writing to adata.

Returns

  • Returns or updates adata with the attributes

  • model (.uns) – language model

  • velocity_graph (.uns) – sparse matrix with transition probabilities