Generating a heatmap in DEG analysis
2
0
Entering edit mode
3.7 years ago
Pranathi ▴ 10

After performing DESEQ2 on my data, I could able to plot MA, PCA, and EnhancedVolcano plots including a (.xlsx) file consisting of log fold change ratios, base mean values, and p- values adjusted, and normal p-values were obtained. I would like to now generate a heatmap.

This is my R-script until now:

countData <- read.table("gene_count_matrix.csv", header = TRUE, sep = ",", row.names = 1)
head(countData)
metaData <- read.table("phenodata.csv", header = TRUE, sep = ",")
head(metaData)

#Deseq2
library(DESeq2)

dds <- DESeqDataSetFromMatrix(countData=countData, colData=metaData, design=~stage_condition)
dds <- DESeq(dds)
dds <- dds[rowSums(counts(dds)) > 0]
res <- results(dds)

head(res)
summary(res)

res <- res[order(res$padj),]
head(res)

resSig <- res[ which(res$pvalue < 0.05)]
res_lfc <- subset(resSig, abs(log2FoldChange) > 2) 
head(res_lfc) 

#MA plot

plotMA(res, ylim=c(-2,2))

#plot for PCA
log_dds<-rlog(dds)
plotPCAWithSampleNames(log_dds, intgroup="treatment", ntop=40000)

#volcano plot
library("EnhancedVolcano")

EnhancedVolcano(res,lab = rownames(res),x = 'log2FoldChange',y = 'pvalue',labSize = 0, pCutoff = 0.05,FCcutoff = 1,xlim=c(-30,12))
plot(EnhancedVolcano)
Differential-gene-expression RNA-Seq • 2.7k views
ADD COMMENT
1
Entering edit mode

Please format the code in your posts appropriately in the future using the code formatting button (the one with 1s and 0s) for clarity. I have done it for you this time.

ADD REPLY
0
Entering edit mode

Thanks so much, Sir!

ADD REPLY
1
Entering edit mode
3.7 years ago

There are many ways to create heatmaps. The most common packages are probably pheatmap and ComplexHeatmap. The latter is much more flexible, but requires slightly more knowledge/reading to use effectively. Regardless, it's an excellent package and worth learning how to use.

devarora shows how to create sample distance heatmaps in their answer, which are a useful QC measure. The DESeq2 vignette shows how to create heatmaps for the count matrix itself via pheatmap.

ADD COMMENT
0
Entering edit mode
3.7 years ago
tothepoint ▴ 940

Heatmap

library("RColorBrewer")

library('pheatmap')

Perform Variance transformation or rlog. say

variance_dds<- vst(dds, blind=FALSE)

sampleDists<-dist(t(assay(variance_dds)))

sampleDistMatrix <- as.matrix(sampleDists)

rownames(sampleDistMatrix) <- paste(variance_dds$Condition, variance_dds$sample, sep="-")

colnames(sampleDistMatrix) <- NULL

colors <- colorRampPalette( rev(brewer.pal(9, "Blues")) )(255)

pheatmap(sampleDistMatrix, clustering_distance_rows=sampleDists,clustering_distance_cols=sampleDists, col=colors)

Hopefully you will get a heatmap. With little tweaks you can change colors too.

ADD COMMENT
0
Entering edit mode

I got a cluster of my samples but not really a heatmap. What do I do now?? Umm.. do you think you can help me a li'l bit more here? Thanks anyways!!!

ADD REPLY

Login before adding your answer.

Traffic: 987 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6