dir="../../"sampleData=paste0(dir,"clinical.txt")sampleData=fread(sampleData)rownames(sampleData) =sampleData$ENA_RUNsampleData$individual=as.factor(sampleData$individual)sampleData$paris_classification=as.factor(sampleData$paris_classification)# Use relevel() to set adjacent normal samples as referencesampleData$paris_classification=relevel(sampleData$paris_classification,ref="normal")files=list.files(paste0(dir,"rsem_star"),"*soforms.results$",full.names=T)
Import RSEM result file and keep the 5th column containing the expected_count values. Build a countData data.frame to store counts
Build a DESeqDataSet from countData with DESeqDataSetFromMatrix, providing also the sample information and a design formula
* Import input data (tximport)
Alternatively, tximport can be used to import expected_count from RSEM, as follows
Differential expression analysis
Run DESeq2 analysis using DESeq, which performs (1) estimation of size factors, (2) estimation of dispersion, then (3) Negative Binomial GLM fitting and Wald statistics. The results tables (log2 fold changes and p-values) can be generated using the results function
We set the adjusted p-value cutoff (FDR) to be 0.05, hence we change the default significance cutoff used for optimizing the independent filtering alpha from 0.1 to 0.05
At a FDR of 0.05, we have 2945 genes up-regulated and 2871 genes down-regulated in 0-IIa pre-lesion versus Normal
The results res object contains the follow columns
Read about authors' note on p-values and adjusted p-values set to NA here
Exploring results
MA-plot
We use MA-plot to show the log2 fold changes attributable to a given variable (i.e. pre-lesion) over the mean of normalized counts for all the samples. Points will be colored red if the adjusted p value is less than 0.05. Points which fall out of the window are plotted as open triangles pointing either up or down
MA-plot
Principal component plot of the samples
First, we perform count data transformation with regularized logarithm rlog or variance stabilizing transformations vst. You can read here about which transformation to choose
Perform sample PCA for transformed data using plotPCA, then plot with ggplot
PCA (rlog)
PCA (vst)
Volcano plots
We use EnhancedVolcano to generate volcano plot to visualise the results of differential expression analyses
Volcano plot
Exporting results
We construct a normData data.frame to store per-group normalised mean and normalised counts of all samples, and a deData data.frame to store the DESeq results. We merge both data.frame with a annoData data.frame that contain per-transcript annotation derived from GENCODE GTF file before exporting the results in tabular format
res <- results(dds, name = "paris_classification_0.IIa_vs_normal", alpha = 0.05)
> summary(res)
out of 159634 with nonzero total read count
adjusted p-value < 0.05
LFC > 0 (up) : 4210, 2.6%
LFC < 0 (down) : 3136, 2%
outliers [1] : 0, 0%
low counts [2] : 87733, 55%
(mean count < 3)
[1] see 'cooksCutoff' argument of ?results
[2] see 'independentFiltering' argument of ?results
> mcols(res)$description
[1] "mean of normalized counts for all samples"
[2] "log2 fold change (MLE): paris classification 0.IIa vs normal"
[3] "standard error: paris classification 0.IIa vs normal"
[4] "Wald statistic: paris classification 0.IIa vs normal"
[5] "Wald test p-value: paris classification 0.IIa vs normal"
[6] "BH adjusted p-values"
> head(res)
log2 fold change (MLE): paris classification 0.IIa vs normal
Wald test p-value: paris classification 0.IIa vs normal
DataFrame with 6 rows and 6 columns
baseMean log2FoldChange lfcSE stat pvalue padj
<numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
ENST00000373020.9 1187.48517486989 -0.63220378627308 0.194294561388125 -3.25384190764961 0.00113855622353168 0.0158582088422363
ENST00000494424.1 0 NA NA NA NA NA
ENST00000496771.5 10.8614532030735 0.332252420760318 0.385893227572389 0.860995728923465 0.389240395417396 0.748731313595519
ENST00000612152.4 0.77778022898225 1.06375257452071 3.00091767488387 0.354475760339502 0.722982366693673 NA
ENST00000614008.4 83.2226874117913 -0.176481709375863 0.356493402266472 -0.495049019852396 0.620565518581719 0.892120965062597
ENST00000373031.5 25.5200220663835 0.0278313866560059 0.389927929551535 0.0713757198362666 0.943098733077851 0.990814121769475
resLFC = lfcShrink(dds, coef = "paris_classification_0.IIa_vs_normal",
type="apeglm")
png("DTE_MA-plot.RSEM.png", width=7, height=5, units = "in", res = 300)
plotMA(resLFC, alpha = 0.05, ylim=c(-6,6),
main = "MA-plot for the shrunken log2 fold changes")
dev.off()