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, xy_callback=None, x_callback=None, y_callback=None, xy_callback_kwargs=mappingproxy({}), x_callback_kwargs=mappingproxy({}), y_callback_kwargs=mappingproxy({}), subset=None, marginal_kwargs=mappingproxy({}))[source]

Prepare the alignment problem problem.

See also

Parameters:
  • batch_key (str) – Key in obs where the slices are stored.

  • spatial_key (str) – Key in obsm 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:

    • None - PCA on X is computed.

    • str - key in obsm where the data is stored.

    • dict - it should contain 'attr' and 'key', the attribute and key in AnnData, and optionally 'tag' from the tags.

    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 the reference.

  • reference (Optional[str]) – Spatial reference when policy = 'star'.

  • normalize_spatial (bool) – Whether to normalize the spatial coordinates. If True, the coordinates are normalized by standardizing them.

  • cost (Union[Literal['euclidean', 'sq_euclidean', 'cosine', 'pnorm_p', 'sq_pnorm', 'geodesic'], Mapping[Literal['xy', 'x', 'y'], Literal['euclidean', 'sq_euclidean', 'cosine', 'pnorm_p', 'sq_pnorm', 'geodesic']]]) –

    Cost function to use. Valid options are:

  • cost_kwargs (Union[Mapping[str, Any], Mapping[Literal['x', 'y', 'xy'], Mapping[str, Any]]]) – Keyword arguments for the BaseCost or any backend-specific cost.

  • a (Union[bool, str, None]) –

    Source marginals. Valid options are:

  • b (Union[bool, str, None]) –

    Target marginals. Valid options are:

  • xy_callback (Literal['local-pca'] | ~typing.Callable[[~typing.Literal['xy', 'x', 'y'], ~anndata._core.anndata.AnnData, ~anndata._core.anndata.AnnData | None], ~moscot.utils.tagged_array.TaggedArray | None] | None)

  • x_callback (Literal['local-pca'] | ~typing.Callable[[~typing.Literal['xy', 'x', 'y'], ~anndata._core.anndata.AnnData, ~anndata._core.anndata.AnnData | None], ~moscot.utils.tagged_array.TaggedArray | None] | None)

  • y_callback (Literal['local-pca'] | ~typing.Callable[[~typing.Literal['xy', 'x', 'y'], ~anndata._core.anndata.AnnData, ~anndata._core.anndata.AnnData | None], ~moscot.utils.tagged_array.TaggedArray | None] | None)

  • xy_callback_kwargs (Mapping[str, Any])

  • x_callback_kwargs (Mapping[str, Any])

  • y_callback_kwargs (Mapping[str, Any])

  • subset (Sequence[Tuple[K, K]] | None)

  • marginal_kwargs (Mapping[str, Any])

Return type:

AlignmentProblem[TypeVar(K, bound= Hashable), TypeVar(B, bound= OTProblem)]

Returns:

: Returns self and updates the following fields: