How does limma calculate the log2fc?
2
1
Entering edit mode
mcfarn1 ▴ 10
@mcfarn1-20854
Last seen 5.6 years ago

Hello,

I used limma to conduct a differential analysis. Everything worked fine but I can't seem to find something that explains what is going on behind the scenes. How does limma calculate the logFC? I have three replicates in my data and I applied limma (contrast) to the full dataset as well as per replicate. For the most part I get the same logFC but some of them are different. Can someone explain how limma calculates the logFC? Is there a formula I can refer to?

Thanks in advance!

Limma Differential Expression Time-course Analysis • 4.7k views
ADD COMMENT
2
Entering edit mode
@james-w-macdonald-5106
Last seen 1 hour ago
United States

The formula is the mean of one group minus the mean of the other. As an example

> set.seed(0xabeef)
> dat <- matrix(rnorm(600), 100)
> design <- model.matrix(~gl(2,3))
> topTable(eBayes(lmFit(dat, design)), sort.by = "none")
Removing intercept from test coefficients
        logFC     AveExpr          t      P.Value  adj.P.Val           B
1  -0.4491747  0.17399287 -0.5429128 0.5874922134 0.89526118 -6.04808633
2   0.3470947 -0.01715336  0.4195298 0.6750542325 0.92838912 -6.10501274
3   0.6185414  0.05340375  0.7476245 0.4551259542 0.87194966 -5.92143882
4  -0.1563895  0.32075711 -0.1890264 0.8501680185 0.93595218 -6.17225795
5   1.8959091 -0.65304549  2.2915656 0.0224496919 0.56124230 -3.67201123
6  -2.9805834  0.18930152 -3.6026002 0.0003547357 0.03547357  0.03240607
7  -1.1050169  0.11255957 -1.3356225 0.1824321732 0.86602296 -5.33421999
8  -0.2232205 -0.24504755 -0.2698043 0.7874499872 0.93595218 -6.15449037
9  -0.2715671  0.26674769 -0.3282403 0.7429017243 0.92838912 -6.13773717
10  0.2775211  0.64482350  0.3354369 0.7374713950 0.92838912 -6.13544753

> head(rowMeans(dat[,4:6]) - rowMeans(dat[,1:3]),10)
 [1] -0.4491747  0.3470947  0.6185414 -0.1563895  1.8959091 -2.9805834
 [7] -1.1050169 -0.2232205 -0.2715671  0.2775211

ADD COMMENT
0
Entering edit mode

Thank you. Okay, so I calculated the means and found the difference between the two conditions but there are not the same. The difference is slight but I was just wondering if you knew what causes that.

ADD REPLY
1
Entering edit mode
@gordon-smyth
Last seen 4 hours ago
WEHI, Melbourne, Australia

limma computes logFC by fitting a linear model to the log-expression values. Even the title of the package tells you that!

The linear model computation takes into account precision weights, inter-gene correlation, missing values and multiple model terms. Except in simple cases (the example that James gives is one), the result is not equivalent to a simple formula that you can repeat in Excel.

ADD COMMENT

Login before adding your answer.

Traffic: 994 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6