<p>This dataset is for a specific disease-gene-test results. The dataset goes like this. </p>

<p>| Test | Gene | Relevance | Values |</p>

<p>Test and Gene are the two parameters on x and y axis. Values are the combined results for the parameters pair. 
The problem for me here is that I have one more parameter called Relevance which represents the relevance of the test-gene pair and it is boolean (only two values YES/NO).</p>

<ul>
<li>The dataset (Relevance) should be differentiated in the map with different colour (like red and green).</li>
<li>Gradient of that colour represents numerical values between that interaction.</li>
</ul>

<p>The end result I was aiming at was, Test on x-axis and Gene on y-axis and the map for these interaction will be only with two colours (representing Relevance values) and the gradient of that colour representing Values. 
Is this possible to achieve this kind of Heatmap, if Yes how can I achieve.
If not is there any other option to display such kind of data (similar to heatmap)</p>

<p>Help appreciated !!</p>

<p>Thanks,</p>

<p>RDS</p>

<p>something like this -
<img src='http://www.mathworks.com/matlabcentral/fx_files/24253/2/heatmap.png' alt='something like this' /></p>

<p>Here is some R code that may help. I must admit I do not understand exactly how your <code>Relevance</code> and <code>Value</code> variables are related (or expected to interact). I have made some guesses. If I have guessed wrong, perhaps you can post some sample data to help clear up my confusion?</p>

<p>I have used <code>scale_fill_gradient2</code> in these examples. You can specify three different colors: high, mid (default is white), low. You can specify the midpoint (value that maps to mid color, default=0), and upper and lower value limits. This may provide enough flexibility to show your data the way you want it.</p>

<p>In Example 1, negative values range from red to white, and positive values range from white to blue. In Example 2, where <code>relevance</code> is FALSE, no color is plotted and where <code>relevance</code> is TRUE, the color gradient spans the range red-white-blue.</p>

<pre><code>library(ggplot2)

# Create test data.
dat1 = data.frame(x=factor(rep(c("A", "B", "C"), 3)), 
                  y=factor(rep(c(37, 8.7, -17.7), c(3, 3, 3))), 
                  z=c(34, 18, 31, 9, -2, 4, -21, -33, -13))

p1 = ggplot(dat1, aes(x=x, y=y, fill=z)) +
     theme_bw() +
     geom_tile() +
     geom_text(aes(label=paste(z))) +
     scale_fill_gradient2(midpoint=0, low="#B2182B", high="#2166AC") +
     opts(title="Example 1")

ggsave(plot=p1, filename="plot_1.png", height=4.5, width=5)
</code></pre>

<p><img src="http://dl.dropbox.com/u/15656938/plot_1_20121105.png" alt="http://dl.dropbox.com/u/15656938/plot&lt;em&gt;1&lt;/em&gt;20121105.png"/></p>

<pre><code># Create a slightly different test dataset.
dat2 = data.frame(
         gene=factor(rep(c("Gene_A", "Gene_B", "Gene_C"), 3)), 
         test=factor(rep(c("Test_1", "Test_2", "Test_3"), c(3, 3, 3))),
         relevance=c(TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE), 
         value=c(-16, 3, NA, NA, -13, 25, -4, NA, -26))

p2 = ggplot(dat2, aes(x=gene, y=test, fill=value)) +
     theme_bw() +
     geom_tile() +
     geom_text(aes(label=paste(value))) +
     scale_fill_gradient2(midpoint=0, low="#B2182B", high="#2166AC") +
     opts(title="Example 2")

ggsave(plot=p2, filename="plot_2.png", height=4.5, width=5)
</code></pre>

<p><img src="http://dl.dropbox.com/u/15656938/plot_2_20121105.png" alt="http://dl.dropbox.com/u/15656938/plot&lt;em&gt;2&lt;/em&gt;20121105.png"/></p>
