BayraktarLab / cell2location

Comprehensive mapping of tissue cell architecture via integrated single cell and spatial transcriptomics (cell2location model)
https://cell2location.readthedocs.io/en/latest/
Apache License 2.0
320 stars 58 forks source link

getting access to q05_nUMI_factors #112

Closed Nasrine26 closed 2 years ago

Nasrine26 commented 2 years ago

Hi,

I really like your tool! I'm following your Mapping human lymph node cell types to 10X Visium tutorial and wanted to know how I could access q05_nUMI_factors (estimated mRNA abundance from each cell type)? When I look at my visium data, it only has

obsm: 'MT', 'means_cell_abundance_w_sf', 'q05_cell_abundance_w_sf', 'q95_cell_abundance_w_sf', 'spatial', 'stds_cell_abundance_w_sf'

Does q05_nUMI_factors correspond to this: adata_vis.uns['mod']['post_sample_q05']['u_sf_mRNA_factors'] ?

Thank you for your help!

The reason I'm asking this is that I'm trying to cluster based on the cell type abundance estimated with your tool. I was wondering which is better for clustering q05_nUMI_factors or q05_cell_abundance_w_sf?

vitkl commented 2 years ago

Hi @Nasrine26

Thanks for using cell2location! Yes, the tutorial exports only the most used variables to adata.obsm, estimates of all other variables are stored in adata_vis.uns['mod'] (as you pointed out).

You can add u_sf_mRNA_factors to obsm using:

adata.obsm["q05_mRNA_abundance_u_sf"] = mod.sample2df_obs(
                mod.samples,
                site_name="u_sf_mRNA_factors",
                summary_name='q05',
                name_prefix="mRNA_abundance",
)

q05_nUMI_factors name was used in the previous version (pymc3).

mRNA abundance is scaled by the total RNA content of every cell type, computed using the reference cell-type signatures provided to the model scaled by the difference between technologies (e.g. neurons expressing 5k UMI vs astrocytes 2k UMI, scaled by m_g). So these numbers are very similar to cell abundance. Looking at mRNA abundance can be useful for QC purposes: seeing that a given cell type contributes at most 20 mRNA indicates that it is unlikely to be present in the tissue (whereas cell abundance can be larger).