Need help with heatmap.2
1
0
Entering edit mode
10.4 years ago
madkitty ▴ 690

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))
heatmap RNA-Seq • 4.6k views
ADD COMMENT
1
Entering edit mode

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.

ADD REPLY
2
Entering edit mode
10.4 years ago

You just need to set ColV=F. So:

heatmap.2( assay(rld)[ topVarGenes, ], scale="row", trace="none", dendrogram="row", ColV=F, col = colorRampPalette( rev(brewer.pal(9, "RdBu")) )(255))
ADD COMMENT
0
Entering edit mode

Thanks! Problem solved, but just for reference, colv=FALSE should be placed before scale as below:

> heatmap.2( assay(rld)[ topVarGenes, ], Colv=FALSE, scale="row",
+ trace="none", dendrogram="row",
+ col = colorRampPalette( rev(brewer.pal(9, "RdBu")) )(255))
ADD REPLY
1
Entering edit mode

I should have written Colv, rather than ColV.

ADD REPLY
0
Entering edit mode

Oh now I understand why it was generating an error. Thanks!

ADD REPLY

Login before adding your answer.

Traffic: 1606 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