Calculation of logFC in edgeR
1
0
Entering edit mode
H • 0
@H-24669
Last seen 3 months ago

I am so new in using R and edgeR. I calculated the logFC in edgeR using the following code:

targets <- read.delim("cell_line_M.txt", stringsAsFactors = FALSE)

colnames(d) <- c("MG1","MG2", "MN1","MN2")
d <- estimateCommonDisp(d, verbose=TRUE)
d <- estimateTagwiseDisp(d, trend="none")

et <- exactTest(d,pair=c("MN","MG"))
print(et)


this is what I obtained :

          logFC   logCPM       PValue
A1CF  0.20103589 4.718215 0.8603790511


my problem is how the logFC is calculated. the main file is

gene   MG1  MG2  MN1 MN2
A1CF    8   7    7   4


I expect that the logFc should be calculated from the strategy suggested in here like:

FC=sqrt(87)/ sqrt(74) --> logFC=log2(FC) = 0.49

but edgeR suggest logFC=0.2

Can anyone guide me if in a wrong way I am or i missed anythong?

edgeR logfc • 232 views
0
Entering edit mode

Linking to duplicate post: Calculation of logCPM in edgeR

2
Entering edit mode
Yunshun Chen ▴ 750
@yunshun-chen-5451
Last seen 1 day ago
Australia

The logFCs are calculated in a much more sophisticated way. It requires fitting a NB generalized linear model and then estimating the coefficients. You can't simply use the raw counts for computing logFCs without taking into account other factors such as the library sizes, the dispersion estimates, etc.

0
Entering edit mode

Yunshun Chen Thank you very much. Is there a link or pdf file containing how logFC is calculated?

0
Entering edit mode

I don't recall there is a link to it. However, all the source code of edgeR is publicly available. If you want to know exactly how the logFC is calculated, I guess the best way would be to dig into the code.