Can I use the WGCNA dendrogram to display a heatmap of gene expression?
1
0
Entering edit mode
Jon Bråte ▴ 250
@jon-brate-6263
Last seen 2.6 years ago
Norway

Sorry for the bad title, but I have identified co-expressed gene modules using the WGCNA-package. And it gives you a dendrogram showing the module colors. Like this:

I would like to create somehting like this, where the gene expression of the different samples are shown as a heatmap, with genes ordered in the same way as the dendrogram. Like this:

But I am not sure how I should proceed with this. Any advice will be greatly appreciated!


 

wgcna heatmap desq2 clustering • 5.3k views
ADD COMMENT
1
Entering edit mode
Dario Strbenac ★ 1.5k
@dario-strbenac-5916
Last seen 4 hours ago
Australia

You can create a heatmap with genes shown in the same order as the dendrogram. You have already created a dendrogram before creating the first plot with the plotDendroAndColors function. The dendrogram contains a list element with the ordering of samples from one side of the dendrogram to the other side. Simply order the rows of your gene expression matrix in the same order as the dendrogram and plot it with heatmap.2. You must set Rowv to FALSE to prevent heatmap.2 from changing the order of genes in the plot.

library(gplots)
expressionMatrix <- expressionMatrix[dendro[["order"]], ]
heatmap.2(expressionMatrix, Rowv = FALSE, Colv = FALSE, dendrogram = "none", trace = "none")
ADD COMMENT
0
Entering edit mode

Thanks for the advice!

I get this error:

> heatmap.2(expressionMatrix, Rowv = FALSE, Colv = FALSE, dendrogram = "none", trace = "none")
Error in par(op) : invalid value specified for graphical parameter "pin"

I used as.matrix to convert from data frame. Otherwise I got the error about x must be a numeric

 

Edit: The error did not occur again for some reason, but it seems that all the values are so low. I am using normalized raw gene counts. Should I transform the gene counts?

ADD REPLY
0
Entering edit mode

If you found modules using read counts, they will be wrong. WGCNA is designed for normally-distributed data, such as data that is measured by microarray. You should use the rlog transformation from DESeq2 before doing any network analysis.

ADD REPLY
0
Entering edit mode

Yes, you're right. I used log2-transformed values to detect modules. I also used these to make the heatmap and it looks better.

If I may ask another question: Is there a way to display the original dendrogram on the heatmap? I can't get a dendrogram without shuffling the rows.

Thanks!

ADD REPLY
1
Entering edit mode

Use the layout function in the graphics package to create a two-column layout with a narrower first column and a wider second column. Then, plot the dendrogram, followed by the heatmap.

ADD REPLY

Login before adding your answer.

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