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")
Import Salmon NumReads values with tximport which contains the transcript-level counts (txIn = TRUE), abundances and average transcript lengths, then output transcript-level estimates (txOut = TRUE)
txi =tximport(files, type ="salmon", txIn =TRUE, txOut =TRUE, countsFromAbundance ="no")
Build a DESeqDataSet from txi, providing also the sample information and a design formula. The DESeqDataSetFromTximport function will take the txi$counts values and use the round function to round them to nearest integer as documented here. The design indicates how to model the samples, here, that we want to measure the difference in expression between pre-lesion and adjacent normal tissue in a paired-sample design
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
res <-results(dds, name ="paris_classification_0.IIa_vs_normal", alpha =0.05)
At a FDR of 0.05, we have 3274 genes up-regulated and 3342 genes down-regulated in 0-IIa pre-lesion versus Normal
>summary(res)out of 159033 with nonzero total read countadjusted p-value <0.05LFC >0 (up) :5020, 3.2%LFC <0 (down) :3728, 2.3%outliers [1] :0, 0%low counts [2] :87402, 55%(mean count <3)[1] see 'cooksCutoff' argument of ?results[2] see 'independentFiltering' argument of ?results
The results res object contains the follow columns
>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>
ENST00000456328.2 0.399730016527216 -0.199743190436256 3.01346565486448 -0.0662835463592627 0.947152082517689 NA
ENST00000450305.2 0 NA NA NA NA NA
ENST00000488147.1 212.684877084654 -0.339571171837121 0.174521709884518 -1.94572452941137 0.0516878384949591 0.229396007387386
ENST00000619216.1 0 NA NA NA NA NA
ENST00000473358.1 0 NA NA NA NA NA
ENST00000469289.1 0.0480413177220545 -0.493640026489245 3.02557680193897 -0.163155675365072 0.870395864425051 NA
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
resLFC =lfcShrink(dds, coef ="paris_classification_0.IIa_vs_normal", type="apeglm")png("DTE_MA-plot.Salmon.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()
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
rld =rlog(dds)vsd =vst(dds)
Perform sample PCA for transformed data using plotPCA, then plot with ggplot
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