<p>You can add a color palette to the plot.</p>
<p>e.g.</p>
<pre class="lang-r prettyprint-override"><code>my_palette &lt;- colorRampPalette(c(&quot;red&quot;, &quot;orange&quot;, &quot;yellow&quot;,&quot;white&quot;))(n = 100);
TOMplot(plotDiss, selectTree, selectColors, main =&quot;Network heatmap plot, selected genes&quot;, col=my_palette)
</code></pre>

CC BY-SA 4.0
2022-12-01T15:14:59.720Z
2022-12-01T18:57:04.057Z
2022-12-01T18:57:04.057Z
CorteZero
<p>I am trying to reproduce the results of the R tutorial of the WGCNA package.</p>
<p>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?</p>
<p>I attach the image together with the code used.</p>
<p>[<img src="https://i.sstatic.net/hufTa.png" alt="image obtained" /></p>
<p>Image Obtained</p>
<p><a href="https://i.sstatic.net/zQR2m.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zQR2m.png" alt="image of tutorial" /></a></p>
<p>Image of tutorial</p>
<pre class="lang-r prettyprint-override"><code>nSelect = 400
set.seed(10);
select = sample(nGenes, size = nSelect);
selectTOM = dissTOM[select, select];
selectTree = hclust(as.dist(selectTOM), method = &quot;average&quot;)
selectColors = moduleColors[select];
sizeGrWindow(9,9)
plotDiss = selectTOM^7;
diag(plotDiss) = NA;
TOMplot(plotDiss, selectTree, selectColors, main = &quot;Network heatmap plot, selected genes&quot;)
</code></pre>

CC BY-SA 4.0
2022-07-04T04:18:13.490Z
Could you please provide a link to the WGCNA tutorial?
gringer
CC BY-SA 4.0
2023-09-14T12:17:01.250Z
Please consider the answer by @CorteZero - looks fine to me - and consider upvoting/accepting. Accepting an answer does help with site stats
M__
<rna-seq><wgcna>
Tutorial for the WGCNA: changes in heatmap colours
# Tutorial for the WGCNA: changes in heatmap colours

(Asked by: username_0 on 2022-07-02)

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 of tutorial
nSelect = 400
set.seed(10);
select = sample(nGenes, size = nSelect);
selectTOM = dissTOM[select, select];
selectTree = hclust(as.dist(selectTOM), method = "average")
selectColors = moduleColors[select];
sizeGrWindow(9,9)
plotDiss = selectTOM^7;
diag(plotDiss) = NA;
TOMplot(plotDiss, selectTree, selectColors, main = "Network heatmap plot, selected genes")

**Tags:** rna-seq, wgcna
> **Comments:**
> **username_1**: Could you please provide a link to the WGCNA tutorial?  
> **username_2**: Please consider the answer by @CorteZero - looks fine to me - and consider upvoting/accepting. Accepting an answer does help with site stats  

---

## 1 answers

### Answer by username_3 on 2022-12-01. Score: 1

You can add a color palette to the plot.
e.g.
my_palette <- colorRampPalette(c("red", "orange", "yellow","white"))(n = 100);
TOMplot(plotDiss, selectTree, selectColors, main ="Network heatmap plot, selected genes", col=my_palette)


---

