title: map colours to values in heatmap (pheatmap)
body: <p>A simple question, although I'm not able to figure out how to solve it. I have a dataframe and I've plotted its values using a heatmap by means of <code>pheatmap</code>. The values range in this dataframe is from 0.098 to 2.94. My data has a lof of <em>1s</em>. I Would like to set 1 as white and the rest of values should be in grey scale, with maximum value as black. I get something similar with my code, but the desire result is that the grey scale containing the values from 0.098 to 1 should be in increasing order, I mean, from light greys to dark greys. I don't know if it is possible.</p>
  
  <p>Many thanks</p>
  
  <p>My code:</p>
  
  <pre><code>bk = unique(c(seq(-2,0.98, length=50), seq(0.98,1, 50), seq(1, 4, length=50))) #to set 1 as white
  
  colors = colorRampPalette(c("gray", "white", "black"))(length(bk)-1)
  
  hm &lt;- pheatmap(as.matrix(df), color=colors, breaks=bk, scale="none", cluster_rows=F, cluster_cols=F)
  </code></pre>
  
  <p>And here is the <code>dput</code> for my dataframe</p>
  
  <pre><code>structure(list(NA1 = c(1, 0.676970665403866, 0.180735940449527, 1), NA14 = c(1, 2.47335986105386, 1, 0.212477914884324), N15 = c(1, 2.01728907209032, 1, 1), NA21 = c(0.0984152452957471, 1.03793278974722, 0.164466463565078, 1), NA23 = c(0.198799370310219, 0.11781214850331, 1, 1), NA27 = c(1, 0.424548617359722, 1, 1), Normal_A8 = c(1, 2.09520458406257, 0.757835484114982, 0.157189452261399), N07 = c(1, 1.82165624404929, 1, 0.750571089868513), Normal_nappa08 = c(0.197195537223992, 1.2943605496238, 1, 0.794285534644797), N1 = c(1.25697210168845, 0.834233608595822, 1, 1.34137057159538), N19 = c(1, 1, 1, 0.860574607416193), N21 = c(0.113712044593094, 0.557227424763336, 1, 0.930914683241786), N25 = c(0.507590735428859, 1, 1, 0.800048340098232), N21 = c(1, 0.315218478784923, 1, 1), N6 = c(1, 1, 1, 1), NA17 = c(1, 1, 1, 1), NA27 = c(1, 1, 1, 1), NA8 = c(0.558064364395163, 1.10333648844397, 1, 1), OA10 = c(1, 1, 1, 1), OA12 = c(1, 1.83681188388072, 1.01642919085048, 0.533410476703701), OA13 = c(1, 1.132050506061, 1, 1), OA16 = c(1, 1, 1, 1), OA18 = c(1, 2.83528162888438, 2.35542585752491, 1.29415196470609), OA22 = c(1, 1.13005418598598, 1, 1), OA26 = c(2.0173633027974, 2.87949980947019, 1.58383227721729, 1.06280472739899), OA5 = c(1, 2.27572364708314, 1, 1), OA7 = c(1, 1.9536510191507, 1, 1), O05 = c(1.37192500010228, 2.40797118258484, 1, 1.61682421728384), O10 = c(0.464932731013085, 1.77383521716872, 1, 2.12342767372253), O13 = c(1, 2.94005281829921, 1, 1.20578447782737), O20 = c(1.24926832014166, 1.74277194088959, 1, 1.79755040142869), O23 = c(1, 1.2123413008167, 1, 1.02707435049319), O9 = c(1, 1.97284676801732, 1, 1.15270850832198), OA1 = c(1.81809297607138, 1.10632758180511, 0.761078669190445, 1), OA23 = c(1, 1, 1, 1), OA_slide_A9 = c(1, 0.324430405028968, 1, 1), O12 = c(0.773389048380233, 1, 1.24407185437909, 1), O5 = c(1, 1, 1, 1)), .Names = c("NA1", "NA14", "NA15", "NA21", "NA23", "NA27", "NA8", "N07", "N08", "N1", "N19", "N21", "N25", "N21", "N6", "NA17", "NA27", "NA8", "OA10", "OA12", "OA13", "OA16", "OA18", "OA22", "OA26", "OA5", "OA7", "O05", "O10", "O13", "O20", "O23", "O9", "OA1", "OA23", "OA9", "O12", "O5"), row.names = c("CD", "CHST", "LEP", "PCO"), class = "data.frame")
  </code></pre>