# In which direction is the LCF calculated when using the function differential\_expression?

**URL:** <https://discourse.scverse.org/t/in-which-direction-is-the-lcf-calculated-when-using-the-function-differential-expression/3514>\
**Category:** scvi-tools\
**Tags:** diff-exp, scvi\
**Created:** [February 26, 2025, 7:07pm UTC](https://discourse.scverse.org/t/in-which-direction-is-the-lcf-calculated-when-using-the-function-differential-expression/3514 "2025-02-26T19:07:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashenflower](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/ashenflower/32/1467_2.png) [@ashenflower](https://discourse.scverse.org/u/ashenflower)\
**Post date:** [February 26, 2025, 7:07pm UTC](https://discourse.scverse.org/t/in-which-direction-is-the-lcf-calculated-when-using-the-function-differential-expression/3514/1 "2025-02-26T19:07:19Z")

</div>

I am sorry if this sounds like a stupid question, but I looked around and I could not find a proper answer.

Given `idx1, idx2` as parameters to my my `model.differential_expression`, if I find that for a given gene the LFC is positive, does it mean that it is over expressed in `idx1` or `idx2`?

In [this tutorial](https://docs.scvi-tools.org/en/latest/tutorials/notebooks/scrna/scVI_DE_worm.html) it is stated that

> Positive values of the LFC signify that the gene is upregulated in `idx1`.

However, looking in the [documentation](https://docs.scvi-tools.org/en/latest/user_guide/background/differential_expression.html) it is reported that the LFC is equal to `log(B) - log(A)` with `idx1` indicated as A and `idx2`indicated as B. Following, I attach the corresponding pictures for clarity:

 ![Screenshot From 2025-02-26 20-04-23](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/6/6b4869e8a0a714d684910b8ce5bcdc59735f1727.png)  
 ![Screenshot From 2025-02-26 20-04-49](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/3/32c4ac37be24822046fb94e4a6e83564e3d958b8.png)

So, which one is correct? Looking at my data, it seems to that the second option (B over A, i.e. `idx2 / idx1` it’s what is actually happening, buy I am not sure and I could not grasp it from the [code](https://github.com/scverse/scvi-tools/blob/main/src/scvi/model/base/_differential.py).

Thank you in advance for 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:** [March 2, 2025, 2:52pm UTC](https://discourse.scverse.org/t/in-which-direction-is-the-lcf-calculated-when-using-the-function-differential-expression/3514/2 "2025-03-02T14:52:14Z")

</div>

Hey,  
The scvi-tools code base is calculating idx1 over idx2,  
see: model.base.\_differential.py

I agree the doc needs to be other way around.

However LFC is a symmetrical metric, so it doesn’t really matter how you use that as long as you keep it consist. Usually one set the idx1 group as the one represent the phenomena class (like cases, or effect) and the idx2 group represent the controls/no-effect.
