Thank you that worked, mostly.
I had an error thrown, and went down another biostars answer to make it work. DESeq2 compare all levels
The crux is that you have to modify the reference level of your design so the comparison of interest becomes available via resultsNames.
Here is an example:
library(DESeq2)
/ Example data with three levels: dds <- makeExampleDESeqDataSet() dds$condition <- factor(unlist(lapply(seq(1,3),function(x)
rep(LETTERS[x], 4))))
/ standard workflow dds <- estimateSizeFactors(dds) dds <- estimateDispersions(dds) dds <- nbinomWaldTest(dds) resultsNames(dds)
1 "Intercept" "condition_B_vs_A" "condition_C_vs_A"
As you see you have B_vs_A and C_vs_A for which the MLEs that apeglm needs are available. In case you want to shrink the B_vs_C comparison you would need to relevel the condition. You either have to make B or C the reference. Lets take C.
relevel(dds$condition, ref = "C")
dds$condition 1 A A A A B B B B C C C C Levels: C A B
The design is the same (~condition), only the reference level changed, and since it is the same so we do not need to rerun the dispersion estimation but only the Wald test to get new MLE coefficients for the comparison of interest.
dds <- nbinomWaldTest(dds) resultsNames(dds) 1 "Intercept"
"condition_A_vs_C" "condition_B_vs_C"B_vs_C is now present so we can proceed.
lfcShrink(dds = dds, coef = 3, type = "apeglm")
It is on you to decide whether you want to do that or simply use ashr. Based on the apeglm paper ashr seems to perform decently as well. Don't use type="normal" though, the paper clearly states that it underperforms on comparison to the other two.