0

Im new to R so be easy on me, I'm having trouble generating a heatmap for my genes. I performed diffrential gene analysis using DESeq2 package and found the 30 most downregulated genes and with fdr<0.05 for cell lines. I was trying to create a heatmap using the pheatmap package and I wasn't able to generate my heatmap as I want to. I want to generate a heatmap for my top 30 genes for each cell line(which are 8) Here's my code :

dds <- DESeqDataSetFromMatrix(countData = GSM_subset,
                          colData = subset,
                          design = ~ Condition)

d_analysis <- DESeq(dds)
res <- results(d_analysis)
res

nrow(dds)
dds <- dds[rowSums(counts(dds)) > 1,]
nrow(dds)        


mcols(res, use.names = TRUE)
summary(res)

resLFC1 <- results(d_analysis, lfcThreshold=3)

table(resLFC1$padj<0.05)
resLFC1 <- resLFC1[complete.cases(resLFC1),]
resLFC1
resSig <- subset(resLFC1, log2FoldChange=-3)
resSig <- subset(resLFC1, padj<0.05)
top30=head(resSig[ order(resSig$log2FoldChange), ],30)
top30<-as.data.frame(top30)

library(pheatmap)
pheatmap(top30)
Halake
  • 13
  • 3

1 Answers1

0

Heatmaps in the genomics context usually use the scaled (that is Z-transformed) normalized counts on the log2 scale, or similar transformation such as vst or rlog from the DESeq2 package.

Given you already use DESeq2 you can do with dds being your DESeqDataSet:

vsd <- assay(vst(dds)) # log-normalized and variance-stabilized counts
Z   <- t(scale(t(vsd))) # z-transformation
Z.select <- Z[your.genes.of.interest,] # subset to genes of interest

...and from there use the heatmap package of your choice.

ATpoint
  • 603
  • 5
  • 17