This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to plot a heat map for the top 30 differentially expressed genes.

Hi every body, I would like to plot a heatmap using the values from DESeq data analysis. Assuming that I have a huge data matrix (nrow = 60483) as follow (in which col = samples, rows = genes), I would like to plot only the top 30 differentially expressed genes. How can I plot only the 30 more expressed genes?

Thanks!

> data_matrix
                                35          36          37          38          39         40         41        42        43
    ENSG00000000003.13  9.515818e-01 -1.199291e+00  7.030973e-01  1.903798e-01  1.129030e+00  4.855549e-01 -1.039498e+00 -1.2278705805
    ENSG00000000005.5  -4.665423e-01 -1.682807e+00 -5.235347e-01  7.505233e-01  8.055402e-01 -4.752508e-01 -9.794633e-02  0.4070017770
    ENSG00000000419.11  1.785959e-01 -5.223666e-01  2.805222e-01  2.282151e-01  1.403419e+00  2.464082e-01 -1.359234e+00 -1.0095513538
    ENSG00000000457.12  5.008357e-02 -3.191885e-01  4.039360e-01  2.084041e-01  5.122391e-01  5.425087e-01 -4.842307e-01 -1.0902778764
    ENSG00000000460.15  3.201132e-01 -3.708055e-01  5.611609e-02  9.130751e-01  7.333537e-01 -3.095782e-01 -1.870436e-01 -0.4494496398
    ENSG00000000938.11 -1.002005e+00  2.676634e+00  1.319074e-02 -5.919397e-02  1.027381e-01 -6.944992e-01  2.024029e+00  1.8773521101
    ENSG00000000971.14  1.047723e-01  1.122440e+00 -1.833268e-01 -2.489012e-01  7.001233e-01 -1.095065e+00  4.624576e-02  0.8451430544
rna-seq deseq heatmap

3 answers

What I did is:

library(pheatmap)
mat <- assay(vsd)[head(order(res2$padj), 50), ]
class(vsd)
mat <- mat - rowMeans(mat)
pheatmap(mat)

And, apparently, it works for me!

You can use results function on your DESeq object:

res <- results(dds)

res

then get rid of genes that do not expressed differentially:

res <- res[res$padj > 0.01 ] (you can choose another value of padj)

then you can sort your table by baseMean column:

res <- res[order(res[, 1]), ]

and choose any number of most expressed genes

many plots automatically order the data alphabetically although you order them in a specific way. to save yourself from this you can first order your data the way you want. then try my_data$ens_id <- factor(my_data$ens_id, levels = my_data$ens_id) and then plot.

Compute the differential expression itself: dds <- DESeq(dds_7)

RLog: rld <- rlog(dds, blind=F)

Select the top genes topVarGenes <- head(order(-rowVars(assay(rld))),30)

mat <- assay(rld)[ topVarGenes, ]

mat <- mat - rowMeans(mat) pheatmap(mat)

Log in to answer this question.