# Problems with Bayes factors and LFC changes using model.differential\_expression()

**URL:** <https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604>\
**Category:** scvi-tools\
**Tags:** diff-exp\
**Created:** [April 12, 2025, 9:30pm UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604 "2025-04-12T21:30:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![joseph-siefert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/joseph-siefert/32/789_2.png) [@joseph-siefert](https://discourse.scverse.org/u/joseph-siefert)\
**Post date:** [April 12, 2025, 9:30pm UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604/1 "2025-04-12T21:30:57Z")

</div>

Has something changed for the differential expression in the most recent version of scvi-tools? Previously, plots of bayes\_factor vs. lfc\_median were very similar to plots of prob\_de vs. lfc\_median. prob\_de plots still look ok, but bayes\_factor plots look like this:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/0/0df9747f33e5b09b40a19fe80e47f2c9168ef632.jpeg)

Additionally, comparing lfc changes to ground truth simulated data gives wildly inaccurate results. Pseudobulk differential expression on the same dataset gives a perfect correlation (pearson=1.0)

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/1/1a9b38a439ef0bd46ca59a270ab9c61035b12797.png)

---

<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:** [April 14, 2025, 5:04am UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604/2 "2025-04-14T05:04:14Z")

</div>

Does the second plot look better in the old scVI-tools version? See other post about changes.  
Could you try with a manual very small pseudocounts like 1e-10?  
The Bayes factor plot likely looks find for a two-way comparison (change or not change vs the new three way comparison up/unchanged/down). There might be something wrong in computation there.

---

<div class="post-metadata">

**Author:** ![joseph-siefert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/joseph-siefert/32/789_2.png) [@joseph-siefert](https://discourse.scverse.org/u/joseph-siefert)\
**Post date:** [April 14, 2025, 2:01pm UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604/3 "2025-04-14T14:01:37Z")

</div>

Changing pseudo counts gives the same results. Changing test\_mode=‘two’ does reproduce the bayes factor plots as before, but the lfc estimates are still off. I applied the LFC changes to only genes expressed in \>10% of cells and this increased the correlation to ~0.75, but I am still getting better LFC estimates with pseudobulk. I don’t have the plot on the bottom from a previous version (it was years ago I first tested this), but the results were certainly more accurate. I’ll keep an eye on the other post for the kwargs to reproduce previous versions

---

<div class="post-metadata">

**Author:** ![joseph-siefert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/joseph-siefert/32/789_2.png) [@joseph-siefert](https://discourse.scverse.org/u/joseph-siefert)\
**Post date:** [April 26, 2025, 4:33pm UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604/4 "2025-04-26T16:33:55Z")

</div>

I found the issue, it has to do with total counts per celltype. If there are not at least 10 counts for a gene in a given cell type then the lfc estimates are off:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/e/ee8e97c988807b657434db8d4355ce8fd046ee4c.jpeg)

---

<div class="post-metadata">

**Author:** ![joseph-siefert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/joseph-siefert/32/789_2.png) [@joseph-siefert](https://discourse.scverse.org/u/joseph-siefert)\
**Post date:** [April 29, 2025, 5:33pm UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604/5 "2025-04-29T17:33:47Z")

</div>

I forgot to mention that is on the log1p scale, so the model seems to require a fairly high number of counts per cell type for accurate LFC estimates. There also seem to be a high number of false positive detected as well. Pseudobulk does not suffer from either of these issues. Any suggestions or solutions from the developers here?

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/6/64cc474f408bc0742a8fd1046fcc147800b53f8e.png)

---

<div class="post-metadata">

**Author:** ![joseph-siefert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/joseph-siefert/32/789_2.png) [@joseph-siefert](https://discourse.scverse.org/u/joseph-siefert)\
**Post date:** [April 30, 2025, 5:10am UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604/6 "2025-04-30T05:10:51Z")

</div>

Regarding the false positives, it seems to be that genes altered in one cell type are showing up as differentially expressed in other cell types they are not altered in. This appears to be due to the normalization. Here are 3 example false positive genes, the top are library size normalized and log1p transformed and the bottom are normalized values extracted from the scVI model. The raw counts and all associated metadata are identical between batches for these genes in this cell type. These genes are altered in other cell types, and that appears to affect the normalization in this cell type. I have many examples of this.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/e/e367263579fe7b5727817481be94547b1b028ad8.jpeg)

---

<div class="post-metadata">

**Author:** ![joseph-siefert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/joseph-siefert/32/789_2.png) [@joseph-siefert](https://discourse.scverse.org/u/joseph-siefert)\
**Post date:** [May 28, 2025, 5:36pm UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604/7 "2025-05-28T17:36:12Z")

</div>

One month later and still no response or solution from the developers. 750/783 false positive genes have LFC changes in another cell type, but not the cell type they are being identified as differentially expressed in. This is clearly due to the normalization as I showed in the previous post. The normalization procedure appears to be borrowing information from other cell types, leading to skewed normalization and incorrect differential expression in cell types for which there are no changes. Can the developers please address this issue?

---

<div class="post-metadata">

**Author:** ![sulfur](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@sulfur](https://discourse.scverse.org/u/sulfur)\
**Post date:** [June 27, 2025, 6:34am UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604/8 "2025-06-27T06:34:26Z")

</div>

Relatively new user here, but thankful for these detailed and readily applicable toolkits and workflows!

Similar to Joseph’s original post, I have been noticing a lot of negative bayes\_factor values in recent results from my group when previous iterations only had almost exclusively positive bayes\_factor results. We believe that what we are seeing are the log of the Bayes factor. The is\_de\_fdr\_0.05 are showing as True for the results with highly negative bayes\_factor values.

 ![Untitled-1 copy](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/f/f36130e69eb999e53883686be7f1a0fb758372eb.jpeg)

From the extended table above, which only includes is\_de\_fdr\_0.5 True genes (corresponding to the labeled green dots in the volcano plot), proba\_de does seem to be much greater than proba\_not\_de.

With potential recent updates to the DE test, is it possible that something has changed with respect to the bayes\_factor column and interpretation? Would appreciate any help!

---

<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:** [July 9, 2025, 12:36pm UTC](https://discourse.scverse.org/t/problems-with-bayes-factors-and-lfc-changes-using-model-differential-expression/3604/9 "2025-07-09T12:36:31Z")

</div>

Thank you for raising this and sorry for late response.  
bayes\_factor should be positive for expressed genes, but can get negative for highly underexpressed (with pseudocounts\>0).  
We are checking what is wrong with current default settings of the DE.

For the meanwhile, I can suggest running the DE function with mode=“vanilla” and pseudocounts=0?  
Other option is to run with mode=“change” (default now) and force pseudocounts=0 and test\_mode = “two”
