library("DESeq2")library(scales)options(repr.plot.width=4, repr.plot.height=3)matrixFile = path.expand("~/data/work/RNAseq/all_CVSQ.gene.counts.tsv")countData <- as.matrix(read.csv(matrixFile, sep="\t", row.names="Geneid"))head(countData)colnames(countData) <- c("Control1", "Control2", "Quiescence1", "Quiescence2")head(countData)condition <- factor(c("Control", "Control", "Quiescence", "Quiescence"))print(condition)colData <- data.frame(sampleName = colnames(countData), condition = condition)colDatadds <- DESeqDataSetFromMatrix(countData = countData, colData = colData, design = ~ condition)colnames(dds) <- colnames(countData)ddsdds$conditiondds <- DESeq(dds)options(repr.plot.width=6, repr.plot.height=4)barplot(sizeFactors(dds))options(repr.plot.width=6, repr.plot.height=4)barplot(colSums(countData))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.
rld <- rlogTransformation(dds, blind=TRUE)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.
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.
options(repr.plot.width=5, repr.plot.height=4)plotMA(dds,ylim=c(-4.5,4.5))res <- results(dds)res <- res[order(res$padj),]head(res)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.
res.sign <- res[(!is.na(res$padj)) & (res$padj < 0.05),]dim(res.sign)res.sign <- res[(!is.na(res$padj)) & (res$padj < 0.05) & (res$log2FoldChange > 1),]dim(res.sign)res.sign <- res[(!is.na(res$padj)) & (res$padj < 0.05) & (res$log2FoldChange < -1),]dim(res.sign)write.table(res, "deseq.results.tsv", sep="\t", col.names=NA, quote=FALSE)options(repr.plot.width=6)barplot(assay(rld)["SREBF2",])options(repr.plot.width=6)barplot(assay(rld)["E2F1",])