dynamo.vf.jacobian(adata, regulators=None, effectors=None, cell_idx=None, sampling=None, sample_ncells=1000, basis='pca', Qkey='PCs', vector_field_class=None, method='analytical', store_in_adata=True, **kwargs)[source]

Calculate Jacobian for each cell with the reconstructed vector field.

If the vector field was reconstructed from the reduced PCA space, the Jacobian matrix will then be inverse transformed back to high dimension. Note that this should also be possible for reduced UMAP space and will be supported shortly. Note that we compute the Jacobian for the RKHS kernel vector field analytically, which is much more computationally efficient than the numerical method.

  • adata (AnnData) – AnnData object that contains the reconstructed vector field in .uns.

  • regulators (list) – The list of genes that will be used as regulators when calculating the cell-wise Jacobian matrix. The Jacobian is the matrix consisting of partial derivatives of the vector field wrt gene expressions. It can be used to evaluate the change in velocities of effectors (see below) as the expressions of regulators increase. The regulators are the denominators of the partial derivatives.

  • effectors (list or None (default: None)) – The list of genes that will be used as effectors when calculating the cell-wise Jacobian matrix. The effectors are the numerators of the partial derivatives.

  • cell_idx (list or None (default: None)) – A list of cell index (or boolean flags) for which the jacobian is calculated. If None, all or a subset of sampled cells are used.

  • sampling ({None, 'random', 'velocity', 'trn'}, (default: None)) – See specific information on these methods in .tl.sample. If None, all cells are used.

  • sample_ncells (int (default: 1000)) – The number of cells to be sampled. If sampling is None, this parameter is ignored.

  • basis (str (default: 'pca')) – The embedding data in which the vector field was reconstructed. If None, use the vector field function that was reconstructed directly from the original unreduced gene expression space.

  • Qkey (str (default: 'PCs')) – The key of the PCA loading matrix in .uns.

  • vector_field_class (vectorfield) – If not None, the jacobian will be computed using this class instead of the vector field stored in adata.

  • method (str (default: 'analytical')) – The method that will be used for calculating Jacobian, either ‘analytical’ or ‘numerical’. ‘analytical’ method uses the analytical expressions for calculating Jacobian while ‘numerical’ method uses numdifftools, a numerical differentiation tool, for computing Jacobian. ‘analytical’ method is much more efficient.

  • cores (int (default: 1)) – Number of cores to calculate Jacobian. If cores is set to be > 1, multiprocessing will be used to parallel the Jacobian calculation.

  • kwargs – Any additional keys that will be passed to elementwise_jacobian_transformation function.


adata – AnnData object that is updated with the ‘jacobian’ key in the .uns. This is a 3-dimensional tensor with dimensions n_effectors x n_regulators x n_obs.

Return type