dynamo.vf.BaseVectorField

class dynamo.vf.BaseVectorField(X=None, V=None, Grid=None, *args, **kwargs)[source]

The BaseVectorField class is a base class for storing and manipulating vector fields. A vector field is a function that associates a vector to each point in a certain space.

The BaseVectorField class has a number of methods that allow you to work with vector fields. The __init__ method initializes the object, taking in a number of optional arguments such as X, V, and Grid, which correspond to the coordinates of the points in the vector field, the vector values at those points, and a grid used for evaluating the vector field, respectively.

The construct_graph method takes in a set of coordinates X and returns a tuple consisting of a matrix of pairwise distances between the points in X and an object for performing nearest neighbor searches. The from_adata method takes in an AnnData object and a basis string, and extracts the coordinates and vector values of the vector field stored in the AnnData object.

The get_X, get_V, and get_data methods return the coordinates, vector values, and both the coordinates and vector values of the vector field, respectively. The find_fixed_points method searches for fixed points of the vector field function, which are points where the velocity of the vector field is zero. The get_fixed_points method returns the fixed points and their types (stable or unstable). The plot method generates a plot of the vector field.

Methods table

assign_fixed_points([domain, cores])

assign each cell to the associated fixed points

construct_graph([X])

find_fixed_points([n_x0, X0, domain, ...])

Search for fixed points of the vector field function.

from_adata(adata[, basis, vf_key])

get_V([idx])

get_X([idx])

get_data()

get_fixed_points(**kwargs)

Get fixed points of the vector field function.

integrate(init_states[, dims, scale, t_end, ...])

Integrate along a path through the vector field field function to predict the state after a certain amount of time t has elapsed.

Methods

BaseVectorField.assign_fixed_points(domain=None, cores=1, **kwargs)[source]

assign each cell to the associated fixed points

Parameters:
  • domain (Optional[ndarray] (default: None)) – Array of shape (n_dim, 2), which stores the domain for each dimension

  • cores (int (default: 1)) – Defaults to 1.

Return type:

Tuple[ndarray, ndarray, ndarray]

Returns:

Tuple of fixed points, type assignments, and assignment IDs

BaseVectorField.construct_graph(X=None, **kwargs)[source]
Return type:

Tuple[ndarray, Union[NNDescent, NearestNeighbors]]

BaseVectorField.find_fixed_points(n_x0=100, X0=None, domain=None, sampling_method='random', **kwargs)[source]

Search for fixed points of the vector field function.

Parameters:
  • n_x0 (int (default: 100)) – Number of sampling points

  • X0 (Optional[ndarray] (default: None)) – An array of shape (n_samples, n_dim)

  • domain (Optional[ndarray] (default: None)) – Domain in which to search for fixed points

  • sampling_method (Literal['random', 'velocity', 'trn', 'kmeans'] (default: 'random')) – Method for sampling initial points. Can be one of random, velocity, trn, or kmeans.

Return type:

None

BaseVectorField.from_adata(adata, basis='', vf_key='VecFld')[source]
BaseVectorField.get_V(idx=None)[source]
Return type:

ndarray

BaseVectorField.get_X(idx=None)[source]
Return type:

ndarray

BaseVectorField.get_data()[source]
Return type:

Tuple[ndarray, ndarray]

BaseVectorField.get_fixed_points(**kwargs)[source]

Get fixed points of the vector field function.

Return type:

Tuple[ndarray, ndarray]

Returns:

Tuple storing the coordinates of the fixed points and the types of the fixed points.

Types of the fixed points: -1 – stable,

0 – saddle, 1 – unstable

BaseVectorField.integrate(init_states, dims=None, scale=1, t_end=None, step_size=None, args=(), integration_direction='forward', interpolation_num=250, average=True, sampling='arc_length', verbose=False, disable=False)[source]

Integrate along a path through the vector field field function to predict the state after a certain amount of time t has elapsed.

Parameters:
  • init_states (ndarray) – Initial state provided to scipy’s ivp_solver with shape (num_cells, num_dim)

  • dims (Union[int, list, ndarray, None] (default: None)) – Dimensions of state to be used

  • scale (default: 1) – Scale the vector field function by this factor. Defaults to 1.

  • t_end (default: None) – Integrates up till when t=t_end, Defaults to None.

  • step_size (default: None) – Defaults to None.

  • args (default: ()) – Additional arguments provided to scipy’s ivp_solver Defaults to ().

  • integration_direction (default: 'forward') – Defaults to “forward”.

  • interpolation_num (default: 250) – Defaults to 250.

  • average (default: True) – Defaults to True.

  • sampling (default: 'arc_length') – Defaults to “arc_length”.

  • verbose (default: False) – Defaults to False.

  • disable (default: False) – Defaults to False.

Return type:

Tuple[ndarray, ndarray]

Returns:

Tuple storing times and predictions