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

mod.samples & plot_genes_per_cell_type #143

Closed
MertDemirdizen opened this issue Apr 12, 2022 · 8 comments
Closed

mod.samples & plot_genes_per_cell_type #143

MertDemirdizen opened this issue Apr 12, 2022 · 8 comments
Labels
question Further information is requested

Comments

@MertDemirdizen
Copy link

MertDemirdizen commented Apr 12, 2022

Hi again,

I used your tutorial as a template for my data and until the advanced use section, I got no error. Until here, I got perfect results.

For expected_dict = mod.module.model.compute_expected_per_cell_type(
mod.samples["post_sample_q05"], mod.adata
)
I am getting the error of 'Cell2location' object has no attribute 'samples'

For the

plot_genes_per_cell_type, I referred to the issue #121, copied and pasted the function, and I am getting the following error:

KeyError: 'Smooth_muscle_cells'

I was suspected whether dashes/underscores makes a difference in python, and I changed the names of clusters as above. Before that run, I was getting same error with another cluster name.

I was wondering what could be the reason for them. I would appreciate some help. Thank you very much in advance.

@MertDemirdizen MertDemirdizen added the question Further information is requested label Apr 12, 2022
@vitkl
Copy link
Contributor

vitkl commented Apr 13, 2022

Hi @MertDemirdizen

with the latest version (updated yesterday), the correct use is:

expected_dict = mod.module.model.compute_expected_per_cell_type(
mod.samples["post_sample_q05"], mod.adata_manager
)

the error of 'Cell2location' object has no attribute 'samples'

This error suggests that mod.samples dictionary was not created. Have you done the posterior export step?

Are you using a loaded model? If yes you need to add the mod.samples dictionary to the model as:

mod.samples = adata.uns['mod']

@MertDemirdizen
Copy link
Author

Thank you for your answer, but when I tried to install the newest version when I try to install cell2location in a fresh environment:
pip install git+https://github.com/BayraktarLab/cell2location.git#egg=cell2location[tutorials]
Cannot install cell2location and scvi-tools because these package versions have conflicting dependencies.
Also, even if I solve the JAX problem with your answer as in the issue #142, I am getting another problem:
scvi.data does not have setup_anndata attribute error in the part of scvi.data.setup_anndata section.

@MertDemirdizen
Copy link
Author

I am not sure but I think the problem was the scvi version with setup_anndata:
So, I changed to:
RegressionModel.setup_anndata.
It worked. For the second use of the function in the workflow,
I changed to
cell2location.models.Cell2location.setup_anndata(adata=adata_vis, batch_key="sample")
It did not give an error, but I got radically different results for my data.
Is it a problem with my data or do I have a wrong implementation of the function?

@vitkl
Copy link
Contributor

vitkl commented Apr 23, 2022

Hi @MertDemirdizen

Try recreating the environment now - looks like JAX issue was fixed by their developers.

@vitkl
Copy link
Contributor

vitkl commented Apr 23, 2022

cell2location.models.Cell2location.setup_anndata(adata=adata_vis, batch_key="sample") should give the same result as previously because it doesn't do anything else than the old scvi.data.setup_anndata. What do you mean by "radically different results"?

@MertDemirdizen
Copy link
Author

What do you mean by "radically different results"?

I am using a scRNA-seq file converted from Seurat object with sceasy. I have double-checked that the anndata contains raw counts. However, when I trained my data, in the inf_aver variable, the estimated expression seems weird. I have some marker genes that are specific to the cluster, but in the data, there are some clusters that do not show significant expression before training but are high in inf_aver.
If the function did not change anything, I will try to figure out where the problem occurs. Thank you very much!

@MertDemirdizen
Copy link
Author

Try recreating the environment now - looks like JAX issue was fixed by their developers.

Yes, it seems solved. Thanks.

@MertDemirdizen
Copy link
Author

What do you mean by "radically different results"?

I realized that it is completely my mistake. Thank you for your help. Everything works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants