Skip to content

Commit

Permalink
unexpose scale_by_marginals and edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Arina Danilina committed Jan 19, 2024
1 parent e13ef40 commit a775e70
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
17 changes: 5 additions & 12 deletions src/moscot/problems/cross_modality/_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,20 @@ def annotation_mapping( # type: ignore[misc]
forward: bool,
source: str = "src",
target: str = "tgt",
scale_by_marginals: bool = True,
other_adata: Optional[str] = None,
cell_transition_kwargs: Mapping[str, Any] = types.MappingProxyType({}),
) -> pd.DataFrame:
"""Transfer annotations between distributions.
This function transfers annotation labels (e.g. cell types) between groups of cells.
This function transfers annotations (e.g. cell type labels) between distributions of cells.
Parameters
----------
mapping_mode
How to decide which label to transfer. Valid options are:
- ``'max'`` - pick the label of the annotated cell with the highest mapping weight.
- ``'sum'`` - compute :meth:`cell_transition` of annotation labels to target cells and
pick the label with the highest transition weight.
- ``'max'`` - pick the label of the annotated cell with the highest matching probability.
- ``'sum'`` - aggregate the annotated cells by label then
pick the label with the highest total matching probability.
annotation_label
Key in :attr:`~anndata.AnnData.obs` where the annotation is stored.
forward
Expand All @@ -218,10 +216,6 @@ def annotation_mapping( # type: ignore[misc]
Key identifying the source distribution.
target
Key identifying the target distribution.
scale_by_marginals
Whether to scale by the source :term:`marginals`.
other_adata
The second :class:`anndata.AnnData` if present.
cell_transition_kwargs
Keyword arguments for :meth:`cell_transition`, used only if ``mapping_mode = 'sum'``.
Expand All @@ -236,8 +230,7 @@ def annotation_mapping( # type: ignore[misc]
target=target,
key=self.batch_key,
forward=forward,
other_adata=self.adata_tgt if other_adata is None else other_adata,
scale_by_marginals=scale_by_marginals,
other_adata=self.adata_tgt,
cell_transition_kwargs=cell_transition_kwargs,
)

Expand Down
24 changes: 8 additions & 16 deletions src/moscot/problems/space/_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,21 +291,20 @@ def annotation_mapping( # type: ignore[misc]
forward: bool,
source: str = "src",
target: str = "tgt",
scale_by_marginals: bool = True,
cell_transition_kwargs: Mapping[str, Any] = types.MappingProxyType({}),
) -> pd.DataFrame:
"""Transfer annotations between distributions.
This function transfers annotation labels (e.g. cell types) between groups of cells.
This function transfers annotations (e.g. cell type labels) between distributions of cells.
Parameters
----------
mapping_mode
How to decide which label to transfer. Valid options are:
- ``'max'`` - pick the label of the annotated cell with the highest mapping weight.
- ``'sum'`` - compute :meth:`cell_transition` of annotation labels to target cells and
pick the label with the highest transition weight.
- ``'max'`` - pick the label of the annotated cell with the highest matching probability.
- ``'sum'`` - aggregate the annotated cells by label then
pick the label with the highest total matching probability.
annotation_label
Key in :attr:`~anndata.AnnData.obs` where the annotation is stored.
forward
Expand All @@ -314,8 +313,6 @@ def annotation_mapping( # type: ignore[misc]
Key identifying the source distribution.
target
Key identifying the target distribution.
scale_by_marginals
Whether to scale by the source :term:`marginals`.
cell_transition_kwargs
Keyword arguments for :meth:`cell_transition`, used only if ``mapping_mode = 'sum'``.
Expand All @@ -330,7 +327,6 @@ def annotation_mapping( # type: ignore[misc]
target=target,
key=self.batch_key,
forward=forward,
scale_by_marginals=scale_by_marginals,
cell_transition_kwargs=cell_transition_kwargs,
)

Expand Down Expand Up @@ -630,21 +626,20 @@ def annotation_mapping( # type: ignore[misc]
source: K,
target: Union[K, str] = "tgt",
forward: bool = False,
scale_by_marginals: bool = True,
cell_transition_kwargs: Mapping[str, Any] = types.MappingProxyType({}),
) -> pd.DataFrame:
"""Transfer annotations between distributions.
This function transfers annotation labels (e.g. cell types) between groups of cells.
This function transfers annotations (e.g. cell type labels) between distributions of cells.
Parameters
----------
mapping_mode
How to decide which label to transfer. Valid options are:
- ``'max'`` - pick the label of the annotated cell with the highest mapping weight.
- ``'sum'`` - compute :meth:`cell_transition` of annotation labels to target cells and
pick the label with the highest transition weight.
- ``'max'`` - pick the label of the annotated cell with the highest matching probability.
- ``'sum'`` - aggregate the annotated cells by label then
pick the label with the highest total matching probability.
annotation_label
Key in :attr:`~anndata.AnnData.obs` where the annotation is stored.
forward
Expand All @@ -653,8 +648,6 @@ def annotation_mapping( # type: ignore[misc]
Key identifying the source distribution.
target
Key identifying the target distribution.
scale_by_marginals
Whether to scale by the source :term:`marginals`.
cell_transition_kwargs
Keyword arguments for :meth:`cell_transition`, used only if ``mapping_mode = 'sum'``.
Expand All @@ -670,7 +663,6 @@ def annotation_mapping( # type: ignore[misc]
forward=forward,
key=self.batch_key,
other_adata=self.adata_sc,
scale_by_marginals=scale_by_marginals,
cell_transition_kwargs=cell_transition_kwargs,
)

Expand Down
12 changes: 4 additions & 8 deletions src/moscot/problems/time/_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,20 @@ def annotation_mapping(
forward: bool,
source: K,
target: K,
scale_by_marginals: bool = True,
cell_transition_kwargs: Mapping[str, Any] = types.MappingProxyType({}),
) -> pd.DataFrame:
"""Transfer annotations between distributions.
This function transfers annotation labels (e.g. cell types) between groups of cells.
This function transfers annotations (e.g. cell type labels) between distributions of cells.
Parameters
----------
mapping_mode
How to decide which label to transfer. Valid options are:
- ``'max'`` - pick the label of the annotated cell with the highest mapping weight.
- ``'sum'`` - compute :meth:`cell_transition` of annotation labels to target cells and
pick the label with the highest transition weight.
- ``'max'`` - pick the label of the annotated cell with the highest matching probability.
- ``'sum'`` - aggregate the annotated cells by label then
pick the label with the highest total matching probability.
annotation_label
Key in :attr:`~anndata.AnnData.obs` where the annotation is stored.
forward
Expand All @@ -270,8 +269,6 @@ def annotation_mapping(
Key identifying the source distribution.
target
Key identifying the target distribution.
scale_by_marginals
Whether to scale by the source :term:`marginals`.
cell_transition_kwargs
Keyword arguments for :meth:`cell_transition`, used only if ``mapping_mode = 'sum'``.
Expand All @@ -287,7 +284,6 @@ def annotation_mapping(
key=self._temporal_key,
forward=forward,
other_adata=None,
scale_by_marginals=scale_by_marginals,
cell_transition_kwargs=cell_transition_kwargs,
)

Expand Down

0 comments on commit a775e70

Please sign in to comment.