moscot.problems.cross_modality.TranslationProblem.cell_transition

TranslationProblem.cell_transition(source, target=None, source_groups=None, target_groups=None, aggregation_mode='annotation', forward=False, batch_size=None, normalize=True, key_added='cell_transition')

Aggregate the transport matrix.

This function computes a transition matrix with entries corresponding to categories, e.g., cell types.

See also

Parameters:
  • source (TypeVar(K, bound= Hashable)) – Key identifying the source distribution.

  • target (Optional[TypeVar(K, bound= Hashable)]) – Key identifying the target distribution. If None, use the reference.

  • source_groups (Union[str, Mapping[str, Sequence[Any]], None]) –

    Source groups used for aggregation. Valid options are:

    • str - key in obs where categorical data is stored.

    • dict - a dictionary with one key corresponding to a categorical column in obs and values to a subset of categories.

  • target_groups (Union[str, Mapping[str, Sequence[Any]], None]) –

    Target groups used for aggregation. Valid options are:

    • str - key in obs where categorical data is stored.

    • dict - a dictionary with one key corresponding to a categorical column in obs and values to a subset of categories.

  • aggregation_mode (Literal['annotation', 'cell']) –

    How to aggregate the cell-level transport maps. Valid options are:

    • 'annotation' - group the transitions by the source_groups and the target_groups.

    • 'cell' - TODO.

  • forward (bool) – If True, compute the transitions from the source_groups to the target_groups.

  • batch_size (Optional[int]) – Number of rows/columns of the cost matrix to materialize during push() or pull(). Larger value will require more memory.

  • normalize (bool) – If True, normalize the transition matrix. If forward = True, the transition matrix will be row-stochastic, otherwise column-stochastic.

  • key_added (Optional[str]) – Key in uns where to save the result.

  • self (CrossModalityTranslationMixinProtocol[K, B])

Return type:

DataFrame

Returns:

: Depending on the key_added: