almaan / stereoscope

Spatial mapping of cell types by integration of transcriptomics data
MIT License
87 stars 26 forks source link

counts of gene g at spot s from cell c? #26

Open gorkemkose opened 3 years ago

gorkemkose commented 3 years ago

Hi!

Thank you for developing such a nice tool!

I guess the fit_sc_data function returns the parameters that are obtained from SC data's negative binomial distribution. Is this the same thing as r_zg, rate parameter for cell type z and gene g introduced in the paper? Since the method computes counts of gene g at spot s using x_sgc, is there a way we obtain the values of x_sgc, counts of gene g at spot s from cell c as a matrix as well?

Thanks for your time, Görkem

almaan commented 3 years ago

Hello @gorkemkose, I'm glad that you found stereoscope useful!

You are correct in your assumption that the R.*tsv files contain the rates corresponding to the r_zg parameter in the paper. Currently, there is no way to obtain the counts that originates from a specific cell type for a given spot in the stereoscope implementation.

However, there might be a solution, what you could do is to compute the expected value for the spots (see: https://en.wikipedia.org/wiki/Negative_binomial_distribution), which would figure as an estimate of the actual x_sgc value. In order to do this, you would need the unadjusted proportions; i.e., the values that are normalized in fit.py (lin 227), code : W = W / W.sum(axis = 1).reshape(-1,1). Now, I still want to raise a cautionary word, that this is not something I've tested and thoroughly validated, but theoretically it should give you the information you are looking for.

My suggestion would be for you to either : (1) fork stereoscope and add a step where the unadjusted proportions are saved, or (2) if you are very keen on getting these values, I could - when time permits - create a branch for you where said information is saved in addition to the true proportions.

Hope this answered your questions, and lmk how you plan to proceed with this!

Best /A

gorkemkose commented 3 years ago

Hello again!

Sorry for the late reply, I've drowned in the finals and had a short break for the research! This seems exciting, let me try to add the step you have mentioned first. If I can't, will definitely contact you so that maybe you could add this feature when the time permits!

Thanks for the support! Görkem