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

celltype argument expected to have the same name in cell_transition #743

Closed
giovp opened this issue Sep 5, 2024 · 2 comments · Fixed by #751
Closed

celltype argument expected to have the same name in cell_transition #743

giovp opened this issue Sep 5, 2024 · 2 comments · Fixed by #751
Assignees

Comments

@giovp
Copy link
Member

giovp commented Sep 5, 2024

originally reported by @soerenab ,

The code below throws an error. Basically, it should be possible to have 2 clusters have different names, and still compute the cell_transition output.

adata = mt.datasets.bone_marrow(rna=True)
adata.obs["time"] = 1
adata2 = adata.copy()
adata2.obs["time"] = 2
adata = ad.concat([adata, adata2])
adata.obs["time"] = pd.Categorical(adata.obs["time"])
adata.obs["cluster"] = pd.Categorical(np.random.choice(["a", "b"], size=len(adata)))
adata.obs["cluste2"] = pd.Categorical(np.random.choice(["a", "b"], size=len(adata)))
tp = TemporalProblem(adata).prepare(time_key="time").solve()
tp.cell_transition(1, 2, "cluster", "cluster2", forward=False)

this is different but related to #742

@MUCDK
Copy link
Collaborator

MUCDK commented Sep 24, 2024

adata_sc = ...
adata_sp = ...

adata_sc.obs["test_col_1"] = pd.Categorical(np.random.choice(["a", "b"], size=len(adata_sc)))
adata_sp.obs["test_col_2"] = pd.Categorical(np.random.choice(["a", "b"], size=len(adata_sp)))

mp = MappingProblem(adata_sc, adata_sp)
mp = mp.prepare(...).solve(...)

mp.cell_transition("src", "tgt", "test_col_1", "test_col_2")

@selmanozleyen selmanozleyen self-assigned this Sep 24, 2024
@selmanozleyen
Copy link
Collaborator

selmanozleyen commented Sep 29, 2024

hi @giovp , @MUCDK

I was able to run the codes with some minor adjustments. For example in @giovp 's case there was a typo and this runs:

import moscot as mt
import anndata as ad
import pandas as pd
from moscot.problems.time import TemporalProblem


adata = mt.datasets.bone_marrow(rna=True)
adata.obs["time"] = 1
adata2 = adata.copy()
adata2.obs["time"] = 2
adata = ad.concat([adata, adata2])
adata.obs["time"] = pd.Categorical(adata.obs["time"])
adata.obs["cluster"] = pd.Categorical(np.random.choice(["a", "b"], size=len(adata)))
adata.obs["cluster2"] = pd.Categorical(np.random.choice(["a", "b"], size=len(adata))) # FIXED THE TYPO HERE
tp = TemporalProblem(adata).prepare(time_key="time").solve()
tp.cell_transition(1, 2, "cluster", "cluster2", forward=False)

in @MUCDK 's case the source and target was mixed so this works:

import pandas as pd
adata_sc.obs["test_col_1"] = pd.Categorical(np.random.choice(["a", "b"], size=len(adata_sc)))
adata_sp.obs["test_col_2"] = pd.Categorical(np.random.choice(["a", "b"], size=len(adata_sp)))

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


mp.cell_transition("src", "tgt", "test_col_2", "test_col_1") # here since test_col_1 was expected to be in src ie spatial data there was an error but this code now runs

Update: Sorry last code block indeed fails I fixed my error in this PR: #751

@selmanozleyen selmanozleyen linked a pull request Oct 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants