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
See Cell transitions on how to compute and plot the cell transitions.
- Parameters:
source (
TypeVar
(K
, bound=Hashable
)) – Key identifying the source distribution.target (
Optional
[TypeVar
(K
, bound=Hashable
)]) – Key identifying the target distribution. IfNone
, use the reference.source_groups (
Union
[str
,Mapping
[str
,Sequence
[Any
]],None
]) –Source groups used for aggregation. Valid options are:
target_groups (
Union
[str
,Mapping
[str
,Sequence
[Any
]],None
]) –Target groups used for aggregation. Valid options are:
aggregation_mode (
Literal
['annotation'
,'cell'
]) –How to aggregate the cell-level transport maps. Valid options are:
'annotation'
- group the transitions by thesource_groups
and thetarget_groups
.'cell'
- TODO.
forward (
bool
) – IfTrue
, compute the transitions from thesource_groups
to thetarget_groups
.batch_size (
Optional
[int
]) – Number of rows/columns of the cost matrix to materialize duringpush()
orpull()
. Larger value will require more memory.normalize (
bool
) – IfTrue
, normalize the transition matrix. Ifforward = True
, the transition matrix will be row-stochastic, otherwise column-stochastic.key_added (
Optional
[str
]) – Key inuns
where to save the result.self (CrossModalityTranslationMixinProtocol[K, B])
- Return type:
- Returns:
: Depending on the
key_added
:None
- returns the transition matrix.str
- returns nothing and saves the transition matrix touns['moscot_results']['cell_transition']['{key_added}']