moscot.problems.generic.SinkhornProblem.prepare¶
- SinkhornProblem.prepare(key, joint_attr=None, policy='sequential', cost='sq_euclidean', cost_kwargs=mappingproxy({}), a=None, b=None, xy_callback=None, xy_callback_kwargs=mappingproxy({}), subset=None, reference=None)[source]¶
Prepare the individual linear subproblems.
See also
See Custom cost matrices on how to pass custom cost matrices.
TODO(michalk8): add an example that shows how to pass different costs (with kwargs).
- Parameters:
key (
str
) – Key inobs
for theSubsetPolicy
.joint_attr (
Union
[str
,Mapping
[str
,Any
],None
]) –How to get the data for the linear term:
dict
- it should contain'attr'
and'key'
, the attribute and key inAnnData
, and optionally'tag'
from thetags
.
By default,
tag = 'point_cloud'
is used.policy (
Literal
['sequential'
,'explicit'
,'star'
]) –Rule which defines how to construct the subproblems using
obs['{key}']
. Valid options are:'sequential'
- align subsequent categories.'explicit'
- explicit sequence of subsets passed viasubset = [(b3, b0), ...]
.
cost (
Literal
['euclidean'
,'sq_euclidean'
,'cosine'
,'pnorm_p'
,'sq_pnorm'
,'geodesic'
]) –Cost function to use. Valid options are:
str
- name of the cost function, seeget_available_costs()
.dict
- a dictionary with the following keys and values:'xy'
- cost function for the linear term, same as above.
cost_kwargs (
Union
[Mapping
[str
,Any
],Mapping
[Literal
['x'
,'y'
,'xy'
],Mapping
[str
,Any
]]]) – Keyword arguments for theBaseCost
or any backend-specific cost.Source marginals. Valid options are:
Target marginals. Valid options are:
xy_callback (
Union
[Literal
['local-pca'
],Callable
[[Literal
['xy'
,'x'
,'y'
],AnnData
,Optional
[AnnData
]],Optional
[TaggedArray
]],None
]) – Callback function used to prepare the data in the linear term.xy_callback_kwargs (
Mapping
[str
,Any
]) – Keyword arguments for thexy_callback
.subset (
Optional
[Sequence
[Tuple
[TypeVar
(K
, bound=Hashable
),TypeVar
(K
, bound=Hashable
)]]]) – Subset ofobs['{key}']
for theExplicitPolicy
. Only used whenpolicy = 'explicit'
.reference (
Optional
[Any
]) – Reference for theSubsetPolicy
. Only used whenpolicy = 'star'
.
- Return type:
SinkhornProblem
[TypeVar
(K
, bound=Hashable
),TypeVar
(B
, bound=OTProblem
)]- Returns:
: Returns self and updates the following fields:
problems
- the prepared subproblems.stage
- set to'prepared'
.problem_kind
- set to'linear'
.