moscot.problems.space.AlignmentProblem.prepare#
- AlignmentProblem.prepare(batch_key, spatial_key='spatial', joint_attr=None, policy='sequential', reference=None, normalize_spatial=True, cost='sq_euclidean', cost_kwargs=mappingproxy({}), a=None, b=None, **kwargs)[source]#
Prepare the alignment problem problem.
See also
See Alignment of spatial transcriptomics data on how to prepare and solve the
AlignmentProblem
.
- Parameters:
spatial_key (
str
) – Key inobsm
where the spatial coordinates are stored.joint_attr (
Union
[str
,Mapping
[str
,Any
],None
]) –How to get the data for the linear term in the fused case:
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'
,'star'
]) –Rule which defines how to construct the subproblems using
obs['{batch_key}']
. Valid options are:'sequential'
- align subsequent slices.'star'
- align all slices to thereference
.
reference (
Optional
[str
]) – Spatial reference whenpolicy = 'star'
.normalize_spatial (
bool
) – Whether to normalize the spatial coordinates. If True, the coordinates are normalized by standardizing them. If False, no normalization is performed.cost (
Union
[Literal
['euclidean'
,'sq_euclidean'
,'cosine'
,'pnorm_p'
,'sq_pnorm'
,'elastic_l1'
,'elastic_l2'
,'elastic_stvs'
,'elastic_sqk_overlap'
],Mapping
[Literal
['xy'
,'x'
,'y'
],Literal
['euclidean'
,'sq_euclidean'
,'cosine'
,'pnorm_p'
,'sq_pnorm'
,'elastic_l1'
,'elastic_l2'
,'elastic_stvs'
,'elastic_sqk_overlap'
]]]) –Cost function to use. Valid options are:
str
- name of the cost function for all terms, seeget_available_costs()
.dict
- a dictionary with the following keys and values:'xy'
- cost function for the linear term.'x'
- cost function for the source quadratic term.'y'
- cost function for the target quadratic term.
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:
kwargs (
Any
) – Keyword arguments forprepare()
. Only used if policy=”star”, it’s the value for reference stored inanndata.AnnData.obs
["batch_key"]
.
- Return type:
AlignmentProblem
[TypeVar
(K
, bound=Hashable
),TypeVar
(B
, bound=OTProblem
)]- Returns:
: Returns self and updates the following fields:
problems
- the prepared subproblems.spatial_key
- key inobsm
where the spatial coordinates are stored.stage
- set to'prepared'
.problem_kind
- set to'quadratic'
.