Question: Need help with heatmap.2
0
gravatar for madkitty
5.1 years ago by
madkitty580
Canada
madkitty580 wrote:

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 • 2.6k views
ADD COMMENTlink modified 3.8 years ago by Biostar ♦♦ 20 • written 5.1 years ago by madkitty580
1

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 REPLYlink modified 5.1 years ago • written 5.1 years ago by Josh Herr5.6k
2
gravatar for Devon Ryan
5.1 years ago by
Devon Ryan91k
Freiburg, Germany
Devon Ryan91k wrote:

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 COMMENTlink written 5.1 years ago by Devon Ryan91k

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 REPLYlink modified 5.1 years ago • written 5.1 years ago by madkitty580
1

I should have written Colv, rather than ColV.
 

ADD REPLYlink written 5.1 years ago by Devon Ryan91k

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

ADD REPLYlink written 5.1 years ago by madkitty580
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 702 users visited in the last hour