# Inconsistency of scvi/SOLO in predicting doublets?

**URL:** <https://discourse.scverse.org/t/inconsistency-of-scvi-solo-in-predicting-doublets/3316>\
**Category:** scvi-tools\
**Created:** [November 3, 2024, 12:53pm UTC](https://discourse.scverse.org/t/inconsistency-of-scvi-solo-in-predicting-doublets/3316 "2024-11-03T12:53:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yiwei24](https://avatars.discourse-cdn.com/v4/letter/y/f08c70/32.png) [@yiwei24](https://discourse.scverse.org/u/yiwei24)\
**Post date:** [November 3, 2024, 12:53pm UTC](https://discourse.scverse.org/t/inconsistency-of-scvi-solo-in-predicting-doublets/3316/1 "2024-11-03T12:53:43Z")

</div>

I’m using colab to run my analysis, and since the session is restarted every time you logged out, or terminated due to long pause, i have come to realization on how the inconsistency of the doublets prediction is affecting my analysis.

This is most evidenced when I perform clustering, each restart generated different UMAP profile.

Should i implement random seed ??  
Or is this normal??? (im newbie in this field)

I would highly appreciate any advice I could get in this forum.

---

<div class="post-metadata">

**Author:** ![ori-kron-wis](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/ori-kron-wis/32/1099_2.png) [@ori-kron-wis](https://discourse.scverse.org/u/ori-kron-wis)\
**Post date:** [November 3, 2024, 1:12pm UTC](https://discourse.scverse.org/t/inconsistency-of-scvi-solo-in-predicting-doublets/3316/2 "2024-11-03T13:12:48Z")

</div>

You should run with scvi.settings.seed = 0 at the beginning (see any of our tutorials), but its not enough.

You will only get the exact same UMAPs when comparing 2 runs done after restarting their sessions (under interactive session).  
In other words, you might get different UMAPs even if you are running the exact same code but under the same session and even after setting that seed.

Only setting seed + restarting session each time will guarantee reproducible results (of course given you are running with the same logic)

---

<div class="post-metadata">

**Author:** ![yiwei24](https://avatars.discourse-cdn.com/v4/letter/y/f08c70/32.png) [@yiwei24](https://discourse.scverse.org/u/yiwei24)\
**Post date:** [November 3, 2024, 1:32pm UTC](https://discourse.scverse.org/t/inconsistency-of-scvi-solo-in-predicting-doublets/3316/3 "2024-11-03T13:32:42Z")

</div>

Does this mean i must return the session to a clean slate every time i run scvi??

Would running multiple samples in the same session affect the consistency??

---

<div class="post-metadata">

**Author:** ![ori-kron-wis](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/ori-kron-wis/32/1099_2.png) [@ori-kron-wis](https://discourse.scverse.org/u/ori-kron-wis)\
**Post date:** [November 3, 2024, 1:39pm UTC](https://discourse.scverse.org/t/inconsistency-of-scvi-solo-in-predicting-doublets/3316/4 "2024-11-03T13:39:26Z")

</div>

when you need to **exactly** reproduce your UMAPs and results, yes. And this general rule of thumb is true to any statistical code, not just SCVI.

if not, you should still get similar results, just a bit different due to the random nature in the process.

I didn’t see exactly what you did, but having multiple samples should not the reason.

---

<div class="post-metadata">

**Author:** ![yiwei24](https://avatars.discourse-cdn.com/v4/letter/y/f08c70/32.png) [@yiwei24](https://discourse.scverse.org/u/yiwei24)\
**Post date:** [November 3, 2024, 1:59pm UTC](https://discourse.scverse.org/t/inconsistency-of-scvi-solo-in-predicting-doublets/3316/5 "2024-11-03T13:59:17Z")

</div>

Thank you for your thorough explanation.

---

<div class="post-metadata">

**Author:** ![cane11](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cane11/32/241_2.png) [@cane11](https://discourse.scverse.org/u/cane11)\
**Post date:** [November 7, 2024, 5:02am UTC](https://discourse.scverse.org/t/inconsistency-of-scvi-solo-in-predicting-doublets/3316/6 "2024-11-07T05:02:49Z")

</div>

It’s unfortunately slightly worse on Colab. There is no guarantee that you get exactly the same plots in Colab. Some additional variation is due to the used GPU (CUDA on two different devices is not deterministic) and Colab sometimes switches the GPU or updates their cuDNN library. I don’t find differences in downstream analysis of results but sometimes in number of Leiden clusters etc. [Reproducibility — PyTorch 2.5 documentation](https://pytorch.org/docs/stable/notes/randomness.html) gives a short overview.
