dynamo.vf.SvcVectorField¶
Methods table¶
|
assign each cell to the associated fixed points |
|
Calculate acceleration for many samples via |
|
Curl computation for many samples for 2/3 D systems. |
|
Calculate curvature for many samples via :rtype: |
|
Takes the trace of the jacobian matrix to calculate the divergence. |
|
Calculate sensitivity for many samples via :rtype: |
|
Calculate torsion for many samples via :rtype: |
|
|
|
Evaluate the precision, recall, corrRate of the sparseVFC algorithm. |
|
Search for fixed points of the vector field function. |
|
|
|
Get the Hessian of the vector field function. |
|
Get the Jacobian of the vector field function. |
|
Get the Laplacian of the vector field. |
|
|
|
|
|
|
|
Get fixed points of the vector field function. |
|
Integrate along a path through the vector field field function to predict the state after a certain amount of time t has elapsed. |
|
|
|
Learn an function of vector field from sparse single cell samples in the entire space robustly. |
Methods¶
- SvcVectorField.assign_fixed_points(domain=None, cores=1, **kwargs)[source]¶
assign each cell to the associated fixed points
- SvcVectorField.compute_acceleration(X=None, method='analytical', **kwargs)[source]¶
Calculate acceleration for many samples via
\[\]a = || J cdot v ||.
- Parameters:
- Return type:
- Returns:
np.ndarray storing the vector norm of acceleration (across all genes) for each cell
- SvcVectorField.compute_curl(X=None, method='analytical', dim1=0, dim2=1, dim3=2, **kwargs)[source]¶
Curl computation for many samples for 2/3 D systems.
- Parameters:
X (
Optional[ndarray] (default:None)) – Current state. Defaults to None, initialized from self.datamethod (
str(default:'analytical')) – Method for calculating the Jacobian, one of numerical, analytical, paralleldim1 (
int(default:0)) – index of first dimensiondim2 (
int(default:1)) – index of second dimensiondim3 (
int(default:2)) – index of third dimension
- Return type:
- Returns:
np.ndarray storing curl
- SvcVectorField.compute_curvature(X=None, method='analytical', formula=2, **kwargs)[source]¶
Calculate curvature for many samples via :rtype:
ndarrayFormula 1: .. math:: kappa =
rac{||mathbf{v} imes mathbf{a}||}{||mathbf{V}||^3}
Formula 2: .. math:: kappa =
rac{||mathbf{Jv} (mathbf{v} cdot mathbf{v}) - ||mathbf{v} (mathbf{v} cdot mathbf{Jv})}{||mathbf{V}||^4}
- Args:
X: Current state. Defaults to None, initialized from self.data method: Method for calculating the Jacobian, one of numerical, analytical, parallel formula: Choose between formulas 1 and 2 to compute the curvature. Defaults to 2.
- Returns:
np.ndarray storing the vector norm of curvature (across all genes) for each cell
- SvcVectorField.compute_divergence(X=None, method='analytical', **kwargs)[source]¶
Takes the trace of the jacobian matrix to calculate the divergence.
- SvcVectorField.compute_sensitivity(X=None, method='analytical', **kwargs)[source]¶
Calculate sensitivity for many samples via :rtype:
ndarray\[\]S = (I - J)^{-1} D(
rac{1}{{I-J}^{-1}})
- Args:
X: Current state. Defaults to None, initialized from self.data method: Method for calculating the Jacobian, one of numerical, analytical, parallel Defaults to “analytical”.
- Returns:
np.ndarray storing sensitivity matrix
- SvcVectorField.compute_torsion(X=None, method='analytical', **kwargs)[source]¶
Calculate torsion for many samples via :rtype:
ndarray\[au =\]rac{(mathbf{v} imes mathbf{a}) cdot (mathbf{J} cdot mathbf{a})}{||mathbf{V} imes mathbf{a}||^2}
- Args:
X: Current state. Defaults to None, initialized from self.data method: Method for calculating the Jacobian, one of numerical, analytical, parallel
- Returns:
np.ndarray storing torsion for each sample
- SvcVectorField.construct_graph(X=None, **kwargs)[source]¶
- Return type:
Tuple[ndarray,Union[NNDescent,NearestNeighbors]]
- SvcVectorField.evaluate(CorrectIndex, VFCIndex, siz)[source]¶
Evaluate the precision, recall, corrRate of the sparseVFC algorithm.
- Parameters:
- Return type:
- Returns:
A tuple of precision, recall, corrRate, where Precision, recall, corrRate are Precision and recall of VFC, percentage of initial correct matches, respectively.
See also::
sparseVFC().
- SvcVectorField.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 pointsX0 (
Optional[ndarray] (default:None)) – An array of shape (n_samples, n_dim)domain (
Optional[ndarray] (default:None)) – Domain in which to search for fixed pointssampling_method (
Literal['random','velocity','trn','kmeans'] (default:'random')) – Method for sampling initial points. Can be one of random, velocity, trn, or kmeans.
- Return type:
- SvcVectorField.get_Hessian(method='analytical', **kwargs)[source]¶
Get the Hessian of the vector field function. If method is ‘analytical’: The analytical Hessian will be returned and it always take row vectors as input no matter what input_vector_convention is.
- Return type:
No matter the method and input vector convention, the returned Hessian is of the following format:
df^2/dx_1^2 df_1^2/(dx_1 dx_2) df_1^2/(dx_1 dx_3) … df^2/(dx_2 dx_1) df^2/dx_2^2 df^2/(dx_2 dx_3) … df^2/(dx_3 dx_1) df^2/(dx_3 dx_2) df^2/dx_3^2 … … … … …
- SvcVectorField.get_Jacobian(method='analytical', input_vector_convention='row', **kwargs)[source]¶
Get the Jacobian of the vector field function. If method is ‘analytical’: The analytical Jacobian will be returned and it always take row vectors as input no matter what input_vector_convention is.
If method is ‘numerical’: If the input_vector_convention is ‘row’, it means that fjac takes row vectors as input, otherwise the input should be an array of column vectors. Note that the returned Jacobian would behave exactly the same if the input is an 1d array.
The column vector convention is slightly faster than the row vector convention. So the matrix of row vector convention is converted into column vector convention under the hood.
- Return type:
No matter the method and input vector convention, the returned Jacobian is of the following format:
df_1/dx_1 df_1/dx_2 df_1/dx_3 … df_2/dx_1 df_2/dx_2 df_2/dx_3 … df_3/dx_1 df_3/dx_2 df_3/dx_3 … … … … …
- SvcVectorField.get_Laplacian(method='analytical', **kwargs)[source]¶
Get the Laplacian of the vector field. Laplacian is defined as the sum of the diagonal of the Hessian matrix. Because Hessian is originally defined for scalar function and here we extend it to vector functions. We will calculate the summation of the diagonal of each output (target) dimension.
A Laplacian filter is an edge detector used to compute the second derivatives of an image, measuring the rate at which the first derivatives change (so it is the derivative of the Jacobian). This determines if a change in adjacent pixel values is from an edge or continuous progression.
- Return type:
- SvcVectorField.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 usedscale (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:
- Returns:
Tuple storing times and predictions
- SvcVectorField.train(**kwargs)[source]¶
Learn an function of vector field from sparse single cell samples in the entire space robustly. Reference: Regularized vector field learning with sparse approximation for mismatch removal, Ma, Jiayi, etc. al, Pattern Recognition
- Parameters:
normalize – 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.
- Return type:
VecFldDict- Returns:
A dictionary which contains X, Y, beta, V, C, P, VFCIndex. Where V = f(X), P is the posterior probability and VFCIndex is the indexes of inliers which found by VFC.