0

Is it possible to generate a heatmap taking into consideration both the color and the transparency, with these two parameters given from two different matrices (matrix 1 defines color, matrix 2 defines alpha)?

A little more information on what I'm after:

I have successfully used R and the heatmap.2 function in the gplots package to generate heatmaps - in this case to visualize miRNA interactions. Here, what I want to show is the probability of a particular nucleotide along the typical 20-24 nucleotides of the miRNA in being engaged in target pairing. My heatmap matrix consists of miRNAs (rows) and positions 1-24 (columns) with numeric paring probability in each cell. An example would be changing the alpha parameter of the color determined by the matrix values, such that white=no pairing and dark red=high pairing.

The heatmap.2 function works great for a single such plot, but I would now like to take in overlap information from two different species. Thus, I would need my heatmap to basically consider two matrices:

1) A matrix with the degree of species overlap, e.g. ranging from red-purple-blue for species1-only to species1+2 to species2-only.

2) A matrix with the average degree of pairing, e.g. visualized by the alpha parameter going from a weak-to-strong average pairing (whatever the color) at a given position in matrix 1.

I have tried to use the principles from this post:

Place 1 heatmap on another with transparency in R

But haven't been able to apply its suggestions to my own question.

Thanks in advance!

Community
  • 1
  • 1
  • 2
    Welcome to SO. You should add a minimal reproducible example, including what you've tried, to your original post. See e.g. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – lukeA Apr 21 '15 at 14:16
  • In the link you provided, it outlines how exactly to do what you are looking for. The key idea is to change your data format from two matrices to one. It should be structured `| x_pos | y_pos | alpha_val | colour_val |`. Then in ggplot you can use `geom_tile(aes(fill = colour_val, alpha = alpha_val))` – Chris Apr 21 '15 at 16:31

0 Answers0