| as_ranked | R Documentation |
Extract a per-gene statistic from a DESeq2 analysis as a named
numeric vector sorted in descending order, ready to be passed to
gsea. This uses the full ranked list rather than a
significance cut-off, so no information is discarded by dichotomising
the genes.
as_ranked(x, statistic = c("stat", "log2FoldChange"), ...)
## S3 method for class 'DESeqResults'
as_ranked(x, statistic = c("stat", "log2FoldChange"), ...)
## S3 method for class 'DESeqDataSet'
as_ranked(x, statistic = c("stat", "log2FoldChange"), ...)
x |
a |
statistic |
character, the column to rank by: |
... |
additional arguments; for a |
Non-finite statistics (genes with all-zero counts, genes
flagged by outlier replacement, or failed fits) are dropped with a
message. Duplicated gene identifiers are resolved by keeping the
entry with the largest absolute statistic, with a warning. Note
that lfcShrink() with type = "apeglm" does not return
a stat column; use statistic = "log2FoldChange" for
shrunk results, and keep in mind that shrunk fold changes are
intended for ranking and visualization, not for statistical
testing.
A named numeric vector sorted in descending order, suitable
for the geneList argument of gsea.
library(DESeq2)
dds <- makeExampleDESeqDataSet(n = 500)
## strengthen a subset of genes in condition B (keep the rest near-null
## so the size factors have a stable reference)
isB <- colData(dds)$condition == "B"
ct <- counts(dds)
ct[1:60, isB] <- ct[1:60, isB] * 5 + 500
storage.mode(ct) <- "integer"
counts(dds) <- ct
dds <- DESeq(dds, quiet = TRUE)
ranked <- as_ranked(dds, contrast = c("condition", "B", "A"))
gene_sets <- list(
SET1 = paste0("gene", 1:50),
SET2 = paste0("gene", 201:260)
)
res <- gsea(ranked, gene_sets, nPerm = 1000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.