From a matrix of read counts per gene containing 1 control and 2 independent treatments (3 replicates each, total of 9 columns) I ran the DESeq2 pipeline and generated a heatmap with the following code, even though I specify that the dendrogram should be on the genes only [dendrogram="row"
] it reorganizes my samples. So instead of having Control 1, Control 2, Control 3, Treatment A1 Treatment A2, Treatment A3, Treatment B1, Treatment B2, Treatment B3, all my samples are in a fancy disorder as if the dendrogram re-organization happened, but the dendrogram isn't displayed.
I just want to have a simple heatmap with:
- Samples in the same order as in the spreadsheet: Control 1, Control 2, Control 3, Treatment A1 Treatment A2, Treatment A3, Treatment B1, Treatment B2, Treatment B3
- Genes, should be on the one side (right of left) and dendrogram should be on the same side of the genes.
Is there any way to improve the following code to have that kind of heatmap? (I think it has to do with my topVarGenes
variables, though I'm not sure how to use that..)
# Apply rlog transform to generate the heatmap
rld <- rlogTransformation(dds)
you had estimated gene-wise dispersions, removing these
you had estimated fitted dispersions, removing these
# Calculate sample distance
sampleDistsclba <- dist( t( assay(rld) ) )
# Load proper libraries
library( "genefilter" )
library(gplots)
# Select top 35 differentially expressed genes
topVarGenes <- order( rowVars( assay(rld) ), decreasing=TRUE ) [1:35]
#Generates heatmap with dendrogram on genes
heatmap.2( assay(rld)[ topVarGenes, ], scale="row",
trace="none", dendrogram="row",
col = colorRampPalette( rev(brewer.pal(9, "RdBu")) )(255))
What does your current heat map look like? It's a little hard to see how you want to improve upon your current heat map when we can't see what you already have.