dynamo.vf.SvcVectorField

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

Initialize the VectorField class.

Parameters:
  • X (Optional[ndarray]) – (dimension: n_obs x n_features), Original data.

  • V (Optional[ndarray]) – (dimension: n_obs x n_features), Velocities of cells in the same order and dimension of X.

  • Grid (Optional[ndarray]) – The function that returns diffusion matrix which can be dependent on the variables (for example, genes)

  • normalize (Optional[str]) – Logic flag to determine whether to normalize the data to have zero means and unit covariance. This is often required for raw dataset (for example, raw UMI counts and RNA velocity values in high dimension). But it is normally not required for low dimensional embeddings by PCA or other non-linear dimension reduction methods.

  • Mint (default: None) The number of basis functions to approximate the vector field. By default it is calculated as min(len(X), int(1500 * np.log(len(X)) / (np.log(len(X)) + np.log(100)))). So that any datasets with less than about 900 data points (cells) will use full data for vector field reconstruction while any dataset larger than that will at most use 1500 data points.

  • afloat (default 5) Parameter of the model of outliers. We assume the outliers obey uniform distribution, and the volume of outlier’s variation space is a.

  • betafloat (default: None) Parameter of Gaussian Kernel, k(x, y) = exp(-beta*||x-y||^2). If None, a rule-of-thumb bandwidth will be computed automatically.

  • ecrfloat (default: 1e-5) The minimum limitation of energy change rate in the iteration process.

  • gammafloat (default: 0.9) Percentage of inliers in the samples. This is an inital value for EM iteration, and it is not important. Default value is 0.9.

  • lambdafloat (default: 3) Represents the trade-off between the goodness of data fit and regularization.

  • minPfloat (default: 1e-5) The posterior probability Matrix P may be singular for matrix inversion. We set the minimum value of P as minP.

  • MaxIterint (default: 500) Maximum iteration times.

  • thetafloat (default 0.75) Define how could be an inlier. If the posterior probability of a sample is an inlier is larger than theta, then it is regarded as an inlier.

  • div_cur_free_kernelsbool (default: False) A logic flag to determine whether the divergence-free or curl-free kernels will be used for learning the vector field.

  • sigmaint Bandwidth parameter.

  • etaint Combination coefficient for the divergence-free or the curl-free kernels.

  • seed – int or 1-d array_like, optional (default: 0) Seed for RandomState. Must be convertible to 32 bit unsigned integers. Used in sampling control points. Default is to be 0 for ensure consistency between different runs.

__init__(X=None, V=None, Grid=None, normalize=None, *args, **kwargs)[source]

Initialize the VectorField class.

Parameters:
  • X (Optional[ndarray]) – (dimension: n_obs x n_features), Original data.

  • V (Optional[ndarray]) – (dimension: n_obs x n_features), Velocities of cells in the same order and dimension of X.

  • Grid (Optional[ndarray]) – The function that returns diffusion matrix which can be dependent on the variables (for example, genes)

  • normalize (Optional[str]) – Logic flag to determine whether to normalize the data to have zero means and unit covariance. This is often required for raw dataset (for example, raw UMI counts and RNA velocity values in high dimension). But it is normally not required for low dimensional embeddings by PCA or other non-linear dimension reduction methods.

  • Mint (default: None) The number of basis functions to approximate the vector field. By default it is calculated as min(len(X), int(1500 * np.log(len(X)) / (np.log(len(X)) + np.log(100)))). So that any datasets with less than about 900 data points (cells) will use full data for vector field reconstruction while any dataset larger than that will at most use 1500 data points.

  • afloat (default 5) Parameter of the model of outliers. We assume the outliers obey uniform distribution, and the volume of outlier’s variation space is a.

  • betafloat (default: None) Parameter of Gaussian Kernel, k(x, y) = exp(-beta*||x-y||^2). If None, a rule-of-thumb bandwidth will be computed automatically.

  • ecrfloat (default: 1e-5) The minimum limitation of energy change rate in the iteration process.

  • gammafloat (default: 0.9) Percentage of inliers in the samples. This is an inital value for EM iteration, and it is not important. Default value is 0.9.

  • lambdafloat (default: 3) Represents the trade-off between the goodness of data fit and regularization.

  • minPfloat (default: 1e-5) The posterior probability Matrix P may be singular for matrix inversion. We set the minimum value of P as minP.

  • MaxIterint (default: 500) Maximum iteration times.

  • thetafloat (default 0.75) Define how could be an inlier. If the posterior probability of a sample is an inlier is larger than theta, then it is regarded as an inlier.

  • div_cur_free_kernelsbool (default: False) A logic flag to determine whether the divergence-free or curl-free kernels will be used for learning the vector field.

  • sigmaint Bandwidth parameter.

  • etaint Combination coefficient for the divergence-free or the curl-free kernels.

  • seed – int or 1-d array_like, optional (default: 0) Seed for RandomState. Must be convertible to 32 bit unsigned integers. Used in sampling control points. Default is to be 0 for ensure consistency between different runs.

Methods

__init__([X, V, Grid, normalize])

Initialize the VectorField class.

assign_fixed_points([domain, cores])

assign each cell to the associated fixed points

compute_acceleration([X, method])

Calculate acceleration for many samples via

compute_curl([X, method, dim1, dim2, dim3])

Curl computation for many samples for 2/3 D systems.

compute_curvature([X, method, formula])

Calculate curvature for many samples via :rtype: ndarray

compute_divergence([X, method])

Takes the trace of the jacobian matrix to calculate the divergence.

compute_sensitivity([X, method])

Calculate sensitivity for many samples via :rtype: ndarray

compute_torsion([X, method])

Calculate torsion for many samples via :rtype: ndarray

construct_graph([X])

rtype:

Tuple[ndarray, Union[NNDescent, NearestNeighbors]]

evaluate(CorrectIndex, VFCIndex, siz)

Evaluate the precision, recall, corrRate of the sparseVFC algorithm.

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

Search for fixed points of the vector field function.

from_adata(adata[, basis, vf_key])

get_Hessian([method])

Get the Hessian of the vector field function.

get_Jacobian([method, input_vector_convention])

Get the Jacobian of the vector field function.

get_Laplacian([method])

Get the Laplacian of the vector field.

get_V([idx])

rtype:

ndarray

get_X([idx])

rtype:

ndarray

get_data()

rtype:

Tuple[ndarray, ndarray]

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.

plot_energy([figsize, fig])

train(**kwargs)

Learn an function of vector field from sparse single cell samples in the entire space robustly.