Thanks a lot, this was very helpful. I'll keep that in mind.
Hello,
I am using edgeR to perform a DE analysis between two groups and I'm trying to understand how the logFC is obtained.
I created a simple GL model without the intercept:
design <- model.matrix(~0+group)
And then performed a glmQLFTest with (1,-1) contrast. Then, I extracted the top genes via topTags, applying a BH correction and sorting by p_value. I selected the first gene to look into the results.
logFC logCPM F PValue
geneX 11.31014 4.756812 1770.353 0
Then I looked at the coefficients for this gene (in the DGELRT object obtained by performing the test)
groupX groupY
-9.774554 -17.614144
If I understand correctly, according to this model the coefficients would be the average, expression values for this gene and for each group. So, I would expect the difference between groupY and groupX to be the fold change (following how I modeled the contrast). But I figured that the reasoning is surely more involved; can someone explain it to me or point to a reliable source? I tried looking into the edgeR documentation but I can't seem to find an answer to this.
1 answer
Results presented by topTags() are on the log2 scale. Coefficients stored internally in the DGELRT object are on the loge scale. If you convert from the loge to log2 then you get the topTags output:
> logeFC <- (-9.774554) - (-17.614144)
> log2FC <- logeFC / log(2)
> log2FC
[1] 11.31014
This is a general rule for edgeR. Internal results are always loge, user-level results are always log2. Results in the table data.frame of the DGELRT object are also on the log2 scale, because they are ready for output by topTags().
Log in to answer this question.