Open daler opened 4 years ago
Alternative shrinkage methods, apeglm
and ashr
:
The options for type are:
- apeglm is the adaptive t prior shrinkage estimator from the apeglm package (Zhu, Ibrahim, and Love 2018). As of version 1.28.0, it is the default estimator.
- ashr is the adaptive shrinkage estimator from the ashr package (Stephens 2016). Here DESeq2 uses the ashr option to fit a mixture of Normal distributions to form the prior, with method="shrinkage".
- normal is the the original DESeq2 shrinkage estimator, an adaptive Normal distribution as prior.
apeglm
:normal
is that we cannot use the convenient contrast
parameter in our lfcShrink
call. So, estimating different comparisons and fold-changes will need some refactoring.
dds$condition
can be releveleddesign(dds)
can be replaced with a new designnbinomWaldTest
step needs to be run again (not the full DESeq()
call)NOTE: Most of the following is based on DESeq2 docs linked above.
A
(reference), B
, C
, the resultsNames(dds)
would be: intercept
, groupB
and groupC
groupB
is the contrast: B vs A
groupC
is the contrast: C vs A
B vs C
, we need to jump through a couple of hoops:
dds$group <- relevel(dds$group, 'B')
dds <- nbinomWaldTest(dds)
resultsNames(dds)
will be: intercept
, groupA
and groupC
. So, we can now get the contrast B vs C
with
resBvsC <- lfcShrink(dds, coef='groupC', type='apeglm')
1
,2
,3
A
,B
~ grp + cnd + grp:cnd
Here the third term grp:cnd
is the interaction term. There are three condition effects:
and consequently, three interaction contrasts: 2 vs 1
, 3 vs 1
and 3 vs 2
.
The normal model matrix will have resultsNames(dds)
:
## [1] grp2 grp3 cndB grp2:cndB grp3:cndB
grp2:cndB
== 2 vs 1
grp3:cndB
== 3 vs 1
3 vs 2
, we need to relevel the factor grp
dds$grp <- relevel(dds$grp, '2')
nbinomWaldTest
step, resultsNames(dds)
will include the following:
## [1] grp1 grp3 cndB grp1:cndB grp3:cndB
grp3:cndB
== 3 vs 2
According to the extended shrinkage estimator section in the DESeq2 vignette, apeglm has better performance especially with lower-count genes where the default "normal" mode shrinks to aggressively.
However, as they describe there, this prevents us from using the
contrast=c('factorame', 'treat', 'control')
syntax for generating results. It's still possible to generate results, it just takes some rearrangement of the model to get it to work.