Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect arguments passed to annotation_mapping #742

Closed
giovp opened this issue Sep 5, 2024 · 1 comment
Closed

incorrect arguments passed to annotation_mapping #742

giovp opened this issue Sep 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@giovp
Copy link
Member

giovp commented Sep 5, 2024

This happens when the method annotation_mapping is used in the MappingProblem,

Here, the adata_sp has a batch value, and the annotation_mapping should be done for each batch separately. Howevr, this call would fail

mp.annotation_mapping(
    mapping_mode="max",
    source=0,
    target="ref",
    annotation_label="celltype",
    forward=False,
)

and it can be fixed with

mp.adata_sc.obs["<batch_key>"] = 10

that is, passing a dummy batch key to the single cell data.

To reproduce

Details
import anndata as ad
import moscot as mt
import pandas as pd
from moscot import datasets
from moscot.problems.space import MappingProblem

adata_sc = mt.datasets.drosophila(spatial=False)
adata_sp = datasets.drosophila(spatial=True)
adata_sc, adata_sp

adata_sp.obs["fov"] = 0
adata_sp2 = adata_sp.copy()
adata_sp2.obs["fov"] = 1
adata_sp = ad.concat([adata_sp, adata_sp2])
adata_sc.obs["celltype"] = "annotation"
adata_sc.obs["celltype"] = pd.Categorical(adata_sc.obs["celltype"])
adata_sp

import pandas as pd

adata_sp.obs["fov"] = pd.Categorical(adata_sp.obs["fov"])

mp = MappingProblem(adata_sc=adata_sc, adata_sp=adata_sp)
mp = mp.prepare(
    sc_attr={"attr": "obsm", "key": "X_pca"}, xy_callback="local-pca", batch_key="fov"
)

mp = mp.solve()

mp

mp.adata_sc.obs["fov"] = 10

# mp.adata_sc

mp.annotation_mapping(
    mapping_mode="max",
    source=0,
    target="ref",
    annotation_label="celltype",
    forward=False,
)
@MUCDK
Copy link
Collaborator

MUCDK commented Oct 10, 2024

resolved by #751

@MUCDK MUCDK closed this as completed Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants