moscot.problems.generic.GWProblem.prepare

GWProblem.prepare(key, x_attr=None, y_attr=None, policy='sequential', cost='sq_euclidean', cost_kwargs=mappingproxy({}), a=None, b=None, subset=None, reference=None, x_callback=None, y_callback=None, x_callback_kwargs=mappingproxy({}), y_callback_kwargs=mappingproxy({}))[source]

Prepare the individual quadratic subproblems.

See also

  • TODO(michalk8): add an example how to pass x_attr/y_attr.

Parameters:
  • key (str) – Key in obs for the SubsetPolicy.

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

    How to get the data for the source quadratic term:

    • str - a 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.

    • None - 'x_callback' must be passed via kwargs.

    By default, tag = 'point_cloud' is used.

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

    How to get the data for the target quadratic term:

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

    • dict - it should contain 'attr' and 'key', the attribute and the key in AnnData, and optionally 'tag', one of Tag.

    • None - 'y_callback' must be passed via kwargs.

    By default, tag = 'point_cloud' is used.

  • policy (Literal['sequential', 'explicit', 'star']) –

    Rule which defines how to construct the subproblems. Valid options are:

    • 'sequential' - align subsequent categories in obs['{key}'].

    • 'explicit' - explicit sequence of subsets passed via subset = [(b3, b0), ...].

  • 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:

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

  • reference (Any | 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)

  • x_callback_kwargs (Mapping[str, Any])

  • y_callback_kwargs (Mapping[str, Any])

Return type:

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

Returns:

: Returns self and updates the following fields: