Diagonal heatmap #773
Replies: 6 comments 15 replies
-
Check this example code: m = matrix(rnorm(100), 10)
cm = cor(m)
od = hclust(dist(cm))$order
cm = cm[od, od]
Heatmap(cm, rect_gp = gpar(type = "none"), cluster_rows = FALSE, cluster_columns = FALSE,
cell_fun = function(j, i, x, y, w, h, fill) {
if(i >= j) {
grid.rect(x, y, w, h, gp = gpar(fill = fill, col = fill))
}
}) One thing needs to be noted: Here we compare the row index and column index in |
Beta Was this translation helpful? Give feedback.
-
Then I think you can directly compare m = matrix(rnorm(100), 10)
cm = cor(m)
Heatmap(cm, rect_gp = gpar(type = "none"), column_dend_side = "bottom",
cell_fun = function(j, i, x, y, w, h, fill) {
if(as.numeric(x) <= 1 - as.numeric(y)) {
grid.rect(x, y, w, h, gp = gpar(fill = fill, col = fill))
}
}) |
Beta Was this translation helpful? Give feedback.
-
Good day! Is it possible to split in diagonal while keeping cluster_rows and cluster_columns as true? |
Beta Was this translation helpful? Give feedback.
-
Greetings! I try to draw a very large matrix in triangle form using Heatmap cell_fun. However, it takes long time to draw it. I checked the document, and layer_fun is a vectorized version of cell_fun and may runs faster. Is that possible to provide a example code here to draw triangle heatmap using layer_fun? Many thanks. Best, |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Thank you so much for your prompt response. It works! Best, |
Beta Was this translation helpful? Give feedback.
-
Good day!
Is there a possibility for a diagonal heatmap ( to have only upper/lower triangular of it plotted)?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions