WOTKernel.compute_transition_matrix(cost_matrices=None, lambda1=1, lambda2=50, epsilon=0.05, growth_iters=1, solver='duality_gap', growth_rate_key=None, use_highly_variable=True, last_time_point=LastTimePoint.UNIFORM, threshold='auto', conn_kwargs=mappingproxy({}), **kwargs)[source]

Compute transition matrix using Waddington OT [Schiebinger et al., 2019].

Computes transport maps linking together pairs of time points for time-series single cell data using unbalanced optimal transport, taking into account cell birth and death rates. From the sequence of transition maps linking pairs of sequential time points, we construct one large transition matrix which contains the normalized transport maps as blocks on the 1st upper diagonal.

  • cost_matrices (Union[str, Mapping[Tuple[float, float], ndarray], None]) – Cost matrices for each consecutive pair of time points. If a str, it specifies a key in anndata.AnnData.layers or anndata.AnnData.obsm. containing cell features that are used to compute cost matrices. If None, use WOT’s default, i.e. compute distances in PCA space derived from anndata.AnnData.X for each time point pair separately.

  • lambda1 (float) – Regularization parameter for the marginal constraint on \(p\), the transport map row sums. Smaller value is useful when precise information about the growth rate is not present.

  • lambda2 (float) – Regularization parameter for the marginal constraint on \(q\), the transport map column sums.

  • epsilon (float) – Entropy regularization parameter. Larger value gives more entropic descendant distributions.

  • growth_iters (int) – Number of iterations for growth rate estimates. If growth rates are not known, consider using more iterations.

  • solver (Literal[‘fixed_iters’, ‘duality_gap’]) – Which solver to use.

  • growth_rate_key (Optional[str]) – Key in anndata.AnnData.obs where initial cell growth rates are stored. See compute_initial_growth_rates() on how to estimate them.

  • use_highly_variable (Union[str, bool, None]) – Key in anndata.AnnData.var where highly variable genes are stored. If True, use ‘highly_variable’. If None, use all genes.

  • last_time_point (Literal[‘uniform’, ‘diagonal’, ‘connectivities’]) –

    How to define transitions within the last time point. Valid options are:

    • ’uniform’ - row-normalized matrix of 1s for transitions within the last time point.

    • ’diagonal’ - diagonal matrix with 1s on the diagonal.

    • ’connectivities’ - use transitions from cellrank.tl.kernels.ConnectivityKernel derived from the last time point subset of adata.

  • threshold (Union[float, Literal[‘auto’], None]) –

    How to remove small non-zero values from the transition matrix. Valid options are:

    • ’auto’ - find the maximum threshold value which will not remove every non-zero value from any row.

    • float - value in [0, 100] corresponding to a percentage of non-zeros to remove. Rows where all values are removed will have uniform distribution.

    • None - do not threshold.

  • conn_kwargs (Mapping[str, Any]) – Keyword arguments for scanpy.pp.neighbors(), when using last_time_point = 'connectivities'. Can contain ‘density_normalize’ for cellrank.tl.kernels.ConnectivityKernel.compute_transition_matrix().

  • kwargs (Any) – Additional keyword arguments for optimal transport configuration.

Return type



cellrank.external.kernels.WOTKernel Makes transition_matrix, transport_maps and growth_rates available. Also modifies anndata.AnnData.obs with the following key:

  • ’estimated_growth_rates’ - the estimated final growth rates.


For more information about WOT, see the official tutorial.