I am trying to reproduce the results of the R tutorial of the WGCNA package.

In section I number 5, when generating the heatmap it is quite similar to the one provided by the pdf but the colours of the heatmap differ from the document. Is it possible to change it?

I attach the image together with the code used.

[image obtained

Image Obtained

image of tutorial

Image of tutorial

nSelect = 400
select = sample(nGenes, size = nSelect);
selectTOM = dissTOM[select, select];
selectTree = hclust(as.dist(selectTOM), method = "average")
selectColors = moduleColors[select];
plotDiss = selectTOM^7;
diag(plotDiss) = NA;
TOMplot(plotDiss, selectTree, selectColors, main = "Network heatmap plot, selected genes")
  • $\begingroup$ Could you please provide a link to the WGCNA tutorial? $\endgroup$
    – gringer
    Commented Jul 4, 2022 at 4:18
  • $\begingroup$ Please consider the answer by @CorteZero - looks fine to me - and consider upvoting/accepting. Accepting an answer does help with site stats $\endgroup$
    – M__
    Commented Sep 14, 2023 at 12:17

1 Answer 1


You can add a color palette to the plot.


my_palette <- colorRampPalette(c("red", "orange", "yellow","white"))(n = 100);
TOMplot(plotDiss, selectTree, selectColors, main ="Network heatmap plot, selected genes", col=my_palette)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.