I believe something like
res <- results(dds, contrast=c("cond", "A", "B"))`
res.shr <- lfcShrink(dds=dds, res=res, type="normal")
should work, because the res
parameter passed to lfcShrink
already contains the contrast
(or coef
) information. Instead it dies with a (cryptic) error message that coefAlpha
is missing in a call to results
. ?lfcShrink
does not say much on the topic, except that contrast
and coef
are ignored for type="ashr"
when res
is provided (and for ashr
neither contrast
nor coef
are required). There is also the error message one of coef or contrast required if 'res' is missing
, which appears to imply that they are not required when res
is supplied.
The way the contrast/coefficient is encoded in the results object requires a bit of a hack (string parsing) to extract it, but that is used elsewhere in the code (and could be changed in a future version). So I see no reason why contrast
or coef
should be required if res
is given (even for for types other than ashr
), or am I missing something? In fact, if res
is supplied together with a contrast that was not used in the call to results
that generated res
, wouldn't that lead to weird results (that should warrant at least a warning)?
So my suggestion is fix the code such that res
is always sufficient and maybe do sanity checks if contrast
or coef
is supplied as well. Thanks!
I take it back, it was added 2 months ago to the development branch, so it will become release at the end of April.
I think 1.20.1. Good to hear this will be fixed, thanks!