Chapter 7 Differential expression analysis with DESeq2
Here is a quick example of the use of DESeq2 for differential expression analysis.
7.1 Loading data for DESeq2
A DESeqDataSet object is required for all the following steps.
library(DESeq2)
rownames(metadata) <- metadata$SampleID
dds <- DESeqDataSetFromTximport(txi = txi.kallisto,
colData = metadata,
design = ~ treatment)7.2 Filtering out underrepresented transcripts
Transcripts with too few counts are filtered out. The function relevel() is used to set up which group is the control
dds <- dds[rowSums(counts(dds)) >= 10,]
dds$treatment <- relevel(dds$treatment, ref = 'starved')7.3 Running DESEq2
The main pipeline of DESeq2, including their own data normalization step is run using the DESeq() function.
dds <- DESeq(dds)Exporting results
res <- results(dds)
summary(res)##
## out of 32104 with nonzero total read count
## adjusted p-value < 0.1
## LFC > 0 (up) : 472, 1.5%
## LFC < 0 (down) : 585, 1.8%
## outliers [1] : 276, 0.86%
## low counts [2] : 9337, 29%
## (mean count < 6)
## [1] see 'cooksCutoff' argument of ?results
## [2] see 'independentFiltering' argument of ?results
datatable(as.data.frame(res),
caption = 'Differential expression results using DESeq2',
options = list(scrollX = TRUE))## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html