Question: How does limma calculate the log2fc?
0
3 months ago by
mcfarn10
mcfarn10 wrote:

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?

modified 3 months ago by Gordon Smyth38k • written 3 months ago by mcfarn10
Answer: How does limma calculate the log2fc?
2
3 months ago by
United States
James W. MacDonald50k wrote:

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

[1] -0.4491747  0.3470947  0.6185414 -0.1563895  1.8959091 -2.9805834
[7] -1.1050169 -0.2232205 -0.2715671  0.2775211



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.

Answer: How does limma calculate the log2fc?
1
3 months ago by
Gordon Smyth38k
Walter and Eliza Hall Institute of Medical Research, Melbourne, Australia
Gordon Smyth38k wrote:

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.