Open AlbertPlaPlanas opened 11 months ago
setting the scvi global seed after importing cell2location seems to address the issue
import cell2location
import scvi
scvi.settings.seed = 2023
When cell2location package was released scvi-tools package used to set seed by default, however, this changed recently. It is expected to observe slightly different results under different seed conditions, including confusion between cell populations with insufficient detail in their gene expression signatures to resolve their spatial location. You can set the seed as a warning suggested to get improved numerical reproducibility. Complete numerical reproducibility is not expected because Stochastic Variational Inference is an inference method that includes random sampling in each training step.
I will add a note about this to the notebook.
First of all, thanks and congratulations on this great piece of software.
I have noticed that when reproducing some cell2location past analysis in my pipeline I obtain slighlty different results in the cell proportions (which may lead to different downstream analysis results). To determine if the issue was on my end or if it was coming from the original cell2location package I have run the demo notebook ( https://github.com/BayraktarLab/cell2location/blob/master/docs/notebooks/cell2location_tutorial.ipynb ) 2 times using a clean kernel and I have obtained slightly different cell proportions:
Proportions of execution 1:
Proportiosn of execution2:
Minimal code sample (that we can run without your data, using public data)
The only changes I made to the tutorial notebook (to speed up execution) have been:
mod.train(max_epochs=10, use_gpu=True)
Sample of code to show the output
Hypothesis
When executing the sample code I get the following warning in cell 12:
It seems like scvi seed is not initailized in Cell2Location. Could this be the cause of this behaviour?