cellrank.external.kernels.WOTKernel.compute_transition_matrix
- 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.
- Parameters
cost_matrices (
Union
[str
,Mapping
[Tuple
[float
,float
],ndarray
],None
]) – Cost matrices for each consecutive pair of time points. If astr
, it specifies a key inanndata.AnnData.layers
oranndata.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 fromanndata.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 inanndata.AnnData.obs
where initial cell growth rates are stored. Seecompute_initial_growth_rates()
on how to estimate them.use_highly_variable (
Union
[str
,bool
,None
]) – Key inanndata.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 ofadata
.
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 forscanpy.pp.neighbors()
, when usinglast_time_point = 'connectivities'
. Can contain ‘density_normalize’ forcellrank.tl.kernels.ConnectivityKernel.compute_transition_matrix()
.kwargs (
Any
) – Additional keyword arguments for optimal transport configuration.
- Return type
- Returns
cellrank.external.kernels.WOTKernel
Makestransition_matrix
,transport_maps
andgrowth_rates
available. Also modifiesanndata.AnnData.obs
with the following key:’estimated_growth_rates’ - the estimated final growth rates.
Notes
For more information about WOT, see the official tutorial.