dynamo.pd.least_action

dynamo.pd.least_action(adata, init_cells, target_cells, init_states=None, target_states=None, paired=True, min_lap_t=False, elbow_method='hessian', num_t=20, basis='pca', vf_key='VecFld', vecfld=None, adj_key='pearson_transition_matrix', n_points=25, init_paths=None, D=10, PCs=None, expr_func=<ufunc 'expm1'>, add_key=None, **kwargs)[source]

Calculate the optimal paths between any two cell states.

Parameters:
  • adata (AnnData) – Anndata object that has vector field function computed.

  • init_cells (Union[str, list]) – Cell name or indices of the initial cell states, that will be used to find the initial cell state when optimizing for the least action paths. If the names in init_cells not found in the adata.obs_name, it will be treated as cell indices and must be integers.

  • target_cells (Union[str, list]) – Cell name or indices of the terminal cell states , that will be used to find the target cell state when optimizing for the least action paths. If the names in init_cells not found in the adata.obs_name, it will be treated as cell indices and must be integers.

  • init_states (Optional[ndarray]) – Initial cell states for least action path calculation.

  • target_states (Optional[ndarray]) – Target cell states for least action path calculation.

  • paired (bool) – Whether the initial states and target states will be treated as pairs; if not, all combination of intial and target states will be used to find the least action paths between. When paired is used, the long list is trimmed to the same length of the shorter one.

  • basis (str) – The embedding data to use for predicting the least action path. If basis is pca, the identified least action paths will be projected back to high dimensional space.

  • vf_key (str) – A key to the vector field functions in adata.uns.

  • vecfld (Optional[Callable]) – A function of vector field.

  • adj_key (str) – The key to the adjacency matrix in adata.obsp

  • n_points (int) – Number of way points on the least action paths.

  • init_paths (Union[None, ndarray, list]) – Initial paths that will be used for optimization.

  • D (int) – The diffusion constant. In theory, the diffusion matrix needs to be a function of cell states but we use a constant for the purpose of simplicity.

  • PCs (Optional[str]) – The key to the PCs loading matrix in adata.uns.

  • expr_func (callable) – The function that is applied before performing PCA analysis.

  • add_key (Optional[str]) – The key name that will be used to store the calculated least action path information.

  • kwargs – Additional argument passed to least_action_path function.

Return type:

Union[LeastActionPath, List[LeastActionPath]]

Returns:

A trajectory class containing the least action paths information. Meanwhile, the anndata object with be updated with newly calculated least action paths information.