Description Usage Arguments Details Author(s) Examples
View source: R/src_run_apeglm.R
The function is designed to use apeglm for shrinking LFCs while automatically releveling the dds object to make the relevant coef accessable via resultsNames so apeglm can access the MLEs, see details.
1 2 3 4 5 6 7 8 | run_apeglm(
dds,
contrasts,
lfc = 0.5,
svalue = TRUE,
workers = 1,
verbose = TRUE
)
|
dds |
a DESeqDataSet() that contains size factors and dispersion estimates, see examples |
contrasts |
named lists of contrasts in DESeq2 style, see details |
lfc |
lfc threshold to use as Null |
svalue |
logical, whether to return s-values rather than pvalues/padj. Will be TRUE automatically if lfc argument is not zero.
The latter is hardcoded in |
workers |
number of BiocParallel workers |
verbose |
logical, whether to allow status messages |
By design the DESeq2::lfcShrink(type="apeglm")
function uses the coef argument rather than contrasts.
Therefore the resultsNames(dds)
must contain the respective coef so apeglm can access the MLEs of the effect sizes.
This function here will relevel the factor levels of the dds object to make all contrasts accessable via coef.
A more illustrative example is provided in <https://www.biostars.org/p/448959/#484944>.
Say one makes a design as ~condition
with three levels A/B/C then the expected contrasts
argument of this function would be a named list like...
$A_vs_B [1] "condition" "A" "B" $A_vs_C [1] "condition" "A" "C" $B_vs_C [1] "condition" "B" "C"
...which is the DESeq2 style of writing down contrasts. This function will then loop through the contrasts, releveling the factor levels automatically (if necessary) to allow apeglm shrinkage for all comparisons. After a releveling the Wald test must be re-run, but not of the dispersion estimation because the design is the same.
So far this has only been tested for simple designs such as the one above.
Not tested for more complex designs such as interactions etc.
If one uses the lfc
argument to test against a Null other than zero then s-values will always be returned rather than p/padj.
This is hardcoded in DESeq2 and cannot be changed. The vignette of DESeq2 recommends a smaller cutoff for s- rather the padj, e.g. 0.005.
Final output is a named list with one data.frame per contrast storing the DE statistics.
Alexander Toenges
1 2 3 4 5 6 | # some dummy data:
dds <- DESeq2::makeExampleDESeqDataSet()
dds$condition <- factor(unlist(lapply(seq(1,3),function(x) rep(LETTERS[x], 4))))
contrasts <- diffanalyseR::makeAllContrasts(levels(dds$condition), deseq2 = TRUE, name = "condition")
dds <- DESeq2::estimateSizeFactors(dds) %>% DESeq2::estimateDispersions(.)
res <- run_apeglm(dds,contrasts, lfc=.5, cooksCutoff=0)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.