Question: Heatmap - with diagonally split tiles
4
2.9 years ago by
YaGalbi1.5k
Biocomputing, MRC Harwell Institute, Oxford, UK
YaGalbi1.5k wrote:

Hi all,

I'd like to create a heatmap in which the individual cells are split diagonally so that:

1 - each cell can contain 2 colours

2 - different colours can be assigned based on category

3 - different shades can be applied based on a numerical scale

I'm not even sure what terms are used to search for this type of heatmap so am struggling to find a tool that can do it.

This image is a nice example from this paper but the methods don't state the tool used to create it.

EDIT: I contacted the authors who shared the bespoke script for the heatmap - it is 700 lines of AWK code :( - I think I'll be giving that a skip in favour of EagleEye's suggestion below :)

UPDATE: For completion, corrplot works great when X and Y axis labels are identical (i.e. when plotting a correlation). But this does not work otherwise. Jean Karims suggestion of instead finding another way of plotting 3D data would be better e.g. plot3D

heatmap split • 2.3k views
modified 2.8 years ago • written 2.9 years ago by YaGalbi1.5k
1

I'd probably do it from scratch as this gives more control. Basically you want to layout some two-color squares in a grid. You could do this with your favorite scripting language.
To reuse existing code, I can think of a few options in R:
- use the igraph package with custom node graphics
- adapt the pieGlyph() function from the Rgraphviz package
- adapt the pies() function from the caroline package

However, I don't find this kind of plot particularly informative. What you're trying to do is represent a 3D data set in 2D. Depending on what message you want to convey, there may be better ways of visualizing it.
If you want to keep the heatmap style, you could convert the two values per cell into one. For example, the 2 values could be seen as the x,y coordinates of the end of a vector so if you are interested in how the two change together, you could replace the two values by the cosine of the angle of the vector (maybe projecting on the unit circle).

Thank you both Jean Karim and EagleEye... I will have a look at both of those suggestions.

I am trying to represent 3D data in 2D, that is correct. I want to split each tile on the heatmap diagonally. The upper diagonal is to be represent the number of significant differentially expressed genes identified by diffbind with increased expression, while the lower diagonal will show those with decreased expression. Should be simple enough but will make good practice as a starting point for showing something more complicated in future.

Thanks again :)

2
2.9 years ago by
EagleEye6.6k
Sweden
EagleEye6.6k wrote:

Did you have a look at corrplot ? https://cran.r-project.org/web/packages/corrplot/vignettes/corrplot-intro.html

Try method "pie" and make 50-50% division and have two colors in single cell with two different categories.

I think that's the simplest option EagleEye - I actually found an example of that here - thank you

Note: Edited to correct html link.

Hi EagleEye,

I've done what I can with corrplot, however I don't see any options for editing what "pie" displays, or any way of having 2 colors in a single cell. The best I've managed is a plot where the cells of the upper right triangle contain the values for one variable (upregulation count) while the lower left triangle contains the values for the other (downregulation count).

Any suggestions?