This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to convert log2FC (Fold Change) obtained by differential expression analysis by DESeq2 to FC

Hi everyone,

I made a differential expression analysis of microRNAs with DESeq2. I got the logFC values that are log2(FC). How do I convert the values (positive and negative) to normal fold changes?

use 2^log2(FC)???

Thanks

deseq2 log2fc differential expression

1 answer

Function I use, where base = 2

  def logratio2foldchange (logratio, base) :

    retval = base^(logratio)
    if retval < 1 :
        return -1/retval
    else :
        return  retval

Yes, was just generating an answer myself. That function should work for Python.

Here is another way in R Programming Language, and some proof:

log2fcs <- c(2, -2, 4, -4)
ifelse(log2fcs > 0, 2 ^ log2fcs, -1 / (2 ^ log2fcs))
[1]   4  -4  16 -16

If you want to ignore negative values in the linear fold change altogether, and are happy with fractions, then use:

ifelse(log2fcs > 0, 2 ^ log2fcs, 1 / (2 ^ abs(log2fcs)))
[1]  4.0000  0.2500 16.0000  0.0625

log2(0.0625)
[1] -4

log2(0.25)
[1] -2

Hi ZheFrench,

Is there a reference I can get for this or is that a nonsensical question?

This is just a 100% mathematical proof. You don't need a reference.

Log in to answer this question.