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

How can I use cell2location output for downstream analysis in R Studio #369

Open
532at opened this issue Jun 3, 2024 · 2 comments
Open
Labels
question Further information is requested

Comments

@532at
Copy link

532at commented Jun 3, 2024

Please use the template below to post a question to https://discourse.scverse.org/c/ecosytem/cell2location/.

Problem

Hi, since I was working with R Studio before doing cell2location deconvolution, I was wondering if it is possible to do cell2location deconvolution and use its output for further analysis in R Studio. If yes, how to do it?

I was looking for a file I could use after running the tutorial, but I cannot see anything useful for annotating cell type proportions to Visium spots. Specifically, I looked at the three folders: cell_type_fractions_mean; factor_markers and location_factor_mean, but they seem wrong as there are 11 factors and in the tutorial data is much more cell types?

Running the tutorial, I experienced an error (below), could it be a reason behind it? As I don't see any quantile cell abundance files?

TypeError Traceback (most recent call last)
Cell In[30], line 1
----> 1 adata_ref = mod.export_posterior(
2 adata_ref, use_quantiles=True,
3
4 add_to_obsm=["q05","q50", "q95", "q0001"],
5 sample_kwargs={'batch_size': 2500, 'use_gpu': False}
6 )

TypeError: export_posterior() got an unexpected keyword argument 'add_to_obsm'

Best wishes,
Adrian

@532at 532at added the question Further information is requested label Jun 3, 2024
@vitkl
Copy link
Contributor

vitkl commented Jun 5, 2024

The reason behind the error is likely a package version mismatch. I recommend creating a conda environment from scratch.

You can save results from h5ad anndata object and load them into R. Here is the pd.DataFrame you are looking for:

adata_vis.obsm['q05_cell_abundance_w_sf'].to_csv('./q05_cell_abundance_w_sf.csv')

@532at
Copy link
Author

532at commented Jun 5, 2024

Thank you, I will update you when it is done.

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