Hi,
I aim to narrow the width of each cell and minimize the space within them. Although I attempted to do this by modifying 'width = width/2' in cell_fun1, this reduced the width but the color block did not properly fit to the cell. Any advice or solutions would be highly appreciated.
cell_fun1 = function(j, i, x, y, width, height, fill) {
grid.rect(x = x, y = y, width = width, height = height,
gp = gpar(col = "gray", fill = fill))
if(mut_mat[i, j] != 0) {
if(mut_mat[i, j] > 9) {
grid.text(mut_mat[i, j], x, y, gp = gpar(col = "white"))
} else {
grid.text(mut_mat[i, j], x, y, gp = gpar(col = "black"))
}
}
}
col_fun1 = colorRamp2(c(0, 5, 10, 20, 40), c("white","#bae4b3","#74c476", "#31a354", "#006d2c"))
hm1 <- Heatmap(mut_mat,
name = "#_of_LOE_mutations",
cluster_rows = FALSE,
cluster_columns = FALSE,
show_row_names = TRUE,
show_column_names = TRUE,
column_names_side = "top",
row_names_side = "left",
column_names_gp = gpar(fontsize=13,fontface="bold"),
row_names_gp = gpar(fontsize=10,fontface="bold"),
cell_fun = cell_fun1,
col = col_fun1,
show_heatmap_legend = FALSE,
width = heatmap_width,
height = heatmap_height
)
hm1
Original heatmap:
After modifying "width = width" to "width = width/2" in cell_fun1
I may be missing something, but can you not just shrink the width of the heatmap in general? That is how one would typically do this.
How are you setting
heatmap_width
andheatmap_height
? That's what you'll need to tweak.