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
324 stars 58 forks source link

what's scale_average_detection and detection_y_c? #216

Open jefferyUstc opened 1 year ago

jefferyUstc commented 1 year ago

Hi, cell2locatiob team,

I noticed that there’s param named scale_average_detection in method RegressionModel.export_posterior()source code. when scale_average_detection=True, this seems to correct the inference signature based on the "expected detection sensitivity" described in the manuscript. However, in the source code export_posterior, there's a detection_y_c for this purpose. Following the official tutorial, in actually, this step does not happen, cause no detection_y_c in self.samples["post_sample_means"].keys().

BTW, how can I get the result of detection_y_c?

vitkl commented 1 year ago

Hi @jefferyUstc

The regression model doesn't have a cell-specific normalisation parameter detection_y_c - only a batch-specific normalisation parameter detection_y_e (called h_e in equation 28 in Supplementary Methods https://static-content.springer.com/esm/art%3A10.1038%2Fs41587-021-01139-4/MediaObjects/41587_2021_1139_MOESM1_ESM.pdf).

All results presented in the paper as well as in the tutorial are not scaling the reference expression signatures by normalisation parameter (average across batches). This scaling is not important because it is just a scalar value which is used to scale all values in the reference expression signature matrix (multiplication by a constant).

What's important is that the reference signatures are estimated while accounting for the technical effects (everything in equation 28). This is done when the model is trained, so the output reference signatures are already corrected.

I will change the default to scale_average_detection=False.