Shrink log2 fold changes
Adds shrunken log2 fold changes (LFC) and SE to a
results table from DESeq
run without LFC shrinkage.
For consistency with results
, the column name lfcSE
is used here although what is returned is a posterior SD.
Three shrinkage estimators for LFC are available via type
(see the vignette for more details on the estimators).
The apeglm publication demonstrates that 'apeglm' and 'ashr' outperform
the original 'normal' shrinkage estimator.
lfcShrink( dds, coef, contrast, res, type = c("apeglm", "ashr", "normal"), lfcThreshold = 0, svalue = FALSE, returnList = FALSE, format = c("DataFrame", "GRanges", "GRangesList"), apeAdapt = TRUE, apeMethod = "nbinomCR", parallel = FALSE, BPPARAM = bpparam(), quiet = FALSE, ... )
dds |
a DESeqDataSet object, after running |
coef |
the name or number of the coefficient (LFC) to shrink,
consult |
contrast |
see argument description in |
res |
a DESeqResults object. Results table produced by the
default pipeline, i.e. |
type |
|
lfcThreshold |
a non-negative value which specifies a log2 fold change
threshold (as in |
svalue |
logical, should p-values and adjusted p-values be replaced
with s-values when using |
returnList |
logical, should |
format |
same as defined in |
apeAdapt |
logical, should |
apeMethod |
what |
parallel |
if FALSE, no parallelization. if TRUE, parallel
execution using |
BPPARAM |
see same argument of |
quiet |
whether to print messages |
... |
arguments passed to |
See vignette for a comparison of shrinkage estimators on an example dataset.
For all shrinkage methods, details on the prior is included in
priorInfo(res)
, including the fitted_g
mixture for ashr.
For type="apeglm":
Specifying apeglm
passes along DESeq2 MLE log2
fold changes and standard errors to the apeglm
function
in the apeglm package, and re-estimates posterior LFCs for
the coefficient specified by coef
.
For type="ashr":
Specifying ashr
passes along DESeq2 MLE log2
fold changes and standard errors to the ash
function
in the ashr package,
with arguments mixcompdist="normal"
and method="shrink"
.
For type="normal":
For design as a formula, shrinkage cannot be applied
to coefficients in a model with interaction terms.
For user-supplied model matrices, shrinkage is only
supported via coef
. coef
will make use
of standard model matrices, while contrast
will make use of expanded model matrices, and for the
latter, a results object should be provided to
res
. With numeric- or list-style contrasts,
it is possible to use lfcShrink
, but likely easier to use
DESeq
with betaPrior=TRUE
followed by results
,
because the numeric or list should reference the coefficients
from the expanded model matrix. These coefficients will be printed
to console if 'contrast' is used.
a DESeqResults object with the log2FoldChange
and lfcSE
columns replaced with shrunken LFC and SE.
For consistency with results
(and similar to the output of bayesglm
)
the column name lfcSE
is used here, although what is returned is a posterior SD.
For normal
and for apeglm
the estimate is the posterior mode,
for ashr
it is the posterior mean.
priorInfo(res)
contains information about the shrinkage procedure,
relevant to the various methods specified by type
.
Publications for the following shrinkage estimators:
type="apeglm"
:
Zhu, A., Ibrahim, J.G., Love, M.I. (2018) Heavy-tailed prior distributions for sequence count data: removing the noise and preserving large differences. Bioinformatics. https://doi.org/10.1093/bioinformatics/bty895
type="ashr"
:
Stephens, M. (2016) False discovery rates: a new deal. Biostatistics, 18:2. https://doi.org/10.1093/biostatistics/kxw041
type="normal"
:
Love, M.I., Huber, W., Anders, S. (2014) Moderated estimation of fold change and dispersion for RNA-seq data with DESeq2. Genome Biology, 15:550. https://doi.org/10.1186/s13059-014-0550-8
Related work, the bayesglm
function in the arm
package:
Gelman, A., Jakulin, A., Pittau, M.G. and Su, Y.-S. (2009). A Weakly Informative Default Prior Distribution For Logistic And Other Regression Models. The Annals of Applied Statistics 2:4. http://www.stat.columbia.edu/~gelman/research/published/ priors11.pdf
set.seed(1) dds <- makeExampleDESeqDataSet(n=500,betaSD=1) dds <- DESeq(dds) res <- results(dds) # these are the coefficients from the model # we can specify them using 'coef' by name or number below resultsNames(dds) res.ape <- lfcShrink(dds=dds, coef=2, type="apeglm") res.ash <- lfcShrink(dds=dds, coef=2, type="ashr") res.norm <- lfcShrink(dds=dds, coef=2, type="normal")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.