# Differential gene expression using DESeq2

Differential gene expression using DESeq2

In [20]:
​x
 
library("DESeq2")
library(scales)
options(repr.plot.width=4, repr.plot.height=3)
In [21]:
 
matrixFile = path.expand("~/data/work/RNAseq/all_CVSQ.gene.counts.tsv")
In [22]:
 
countData <- as.matrix(read.csv(matrixFile, sep="\t", row.names="Geneid"))
head(countData)
Control1.bamControl2.bamQuiescence.bamQuiescence2.bam
MIR1302-11 0 0 0 0
FAM138A 0 0 0 0
OR4F5 0 0 0 0
RP11-34P13.7 2 8 12 7
RP11-34P13.8 0 0 0 0
AL627309.173 97 13592
In [25]:
 
colnames(countData) <- c("Control1", "Control2", "Quiescence1", "Quiescence2")
head(countData)
Control1Control2Quiescence1Quiescence2
MIR1302-11 0 0 0 0
FAM138A 0 0 0 0
OR4F5 0 0 0 0
RP11-34P13.7 2 8 12 7
RP11-34P13.8 0 0 0 0
AL627309.173 97 13592
In [26]:
 
condition <- factor(c("Control", "Control", "Quiescence", "Quiescence"))
print(condition)
[1] Control    Control    Quiescence Quiescence
Levels: Control Quiescence
In [27]:
 
colData <- data.frame(sampleName = colnames(countData),
                      condition = condition)
colData
sampleNamecondition
Control1 Control
Control2 Control
Quiescence1Quiescence
Quiescence2Quiescence
In [28]:
 
dds <- DESeqDataSetFromMatrix(countData = countData,
                              colData = colData,
                              design = ~ condition)
colnames(dds) <- colnames(countData)
In [29]:
 
dds
class: DESeqDataSet 
dim: 41863 4 
exptData(0):
assays(1): counts
rownames(41863): MIR1302-11 FAM138A ... AC007965.1 RNU6-1314P
rowRanges metadata column names(0):
colnames(4): Control1 Control2 Quiescence1 Quiescence2
colData names(2): sampleName condition
In [30]:
 
dds$condition
  1. Control
  2. Control
  3. Quiescence
  4. Quiescence
In [31]:
 
dds <- DESeq(dds)
estimating size factors
estimating dispersions
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates
fitting model and testing
In [66]:
 
options(repr.plot.width=6, repr.plot.height=4)
barplot(sizeFactors(dds))
In [67]:
 
options(repr.plot.width=6, repr.plot.height=4)
barplot(colSums(countData))
In [55]:
 
options(repr.plot.width=6, repr.plot.height=6)
plot(data.frame(log10(counts(dds))), cex=0.1, col=alpha("black", 0.4))
 
Scatterplots indicate that replicates are more similar than samples between the two different conditions. The following function log transforms the data and normalizes for library size, effectively reducing variation among the low-expressing genes.

Scatterplots indicate that replicates are more similar than samples between the two different conditions. The following function log transforms the data and normalizes for library size, effectively reducing variation among the low-expressing genes.

In [35]:
 
rld <- rlogTransformation(dds, blind=TRUE)
In [56]:
 
options(repr.plot.width=6, repr.plot.height=6)
plot(data.frame(assay(rld)), cex=0.1, col=alpha("black", 0.4))
 
A principle component analysis (PCA)-plot provides another way to look at inter -and between-sample variation. Again, a greater variance is observed between the two different conditions than between replicates.

A principle component analysis (PCA)-plot provides another way to look at inter -and between-sample variation. Again, a greater variance is observed between the two different conditions than between replicates.

In [37]:
 
plotPCA(rld, intgroup=c("condition"))
 
In an MA-plot, differentialy expressed genes are highlighted in red.

In an MA-plot, differentialy expressed genes are highlighted in red.

In [43]:
 
options(repr.plot.width=5, repr.plot.height=4)
plotMA(dds,ylim=c(-4.5,4.5))
In [39]:
 
res <- results(dds)
res <- res[order(res$padj),]
head(res)
log2 fold change (MAP): condition Quiescence vs Control 
Wald test p-value: condition Quiescence vs Control 
DataFrame with 6 rows and 6 columns
         baseMean log2FoldChange     lfcSE      stat       pvalue         padj
        <numeric>      <numeric> <numeric> <numeric>    <numeric>    <numeric>
HMGCS1  5472.8973       3.516664 0.1870320  18.80247 7.207993e-79 9.750973e-75
SCD    60431.0065       3.345131 0.1991905  16.79363 2.717160e-63 1.837887e-59
TM7SF2   692.4239       3.908236 0.2426317  16.10769 2.252741e-58 1.015836e-54
MSMO1   3791.3652       3.141667 0.2010986  15.62252 5.114639e-55 1.729771e-51
HMGCR   7330.7780       2.786559 0.1826802  15.25375 1.554379e-52 3.603673e-49
INSIG1  3986.5615       3.410375 0.2236028  15.25193 1.598317e-52 3.603673e-49
 
Using a cut-off of log2 fold change > 1 and an adjusted P-value ≤ 0.05, 511 genes were found to be upregulated genes, while 240 genes were found to be downregulated upon serum depletion.

Using a cut-off of log2 fold change > 1 and an adjusted P-value ≤ 0.05, 511 genes were found to be upregulated genes, while 240 genes were found to be downregulated upon serum depletion.

In [77]:
 
res.sign <- res[(!is.na(res$padj)) & (res$padj < 0.05),]
dim(res.sign)
  1. 2132
  2. 6
In [76]:
 
res.sign <- res[(!is.na(res$padj)) & (res$padj < 0.05) & (res$log2FoldChange > 1),]
dim(res.sign)
  1. 511
  2. 6
In [79]:
 
res.sign <- res[(!is.na(res$padj)) & (res$padj < 0.05) & (res$log2FoldChange < -1),]
dim(res.sign)
  1. 240
  2. 6
In [41]:
 
write.table(res, "deseq.results.tsv", sep="\t", col.names=NA, quote=FALSE)
In [82]:
 
options(repr.plot.width=6)
barplot(assay(rld)["SREBF2",])
In [90]:
 
options(repr.plot.width=6)
barplot(assay(rld)["E2F1",])
In [ ]:
 
​