Changing LFC font size on Complex Heatmap
I am having trouble with the font size of a complex heatmap. I created it as follow:
l2_val <- as.matrix(genes$log2FoldChange)
h2 <- Heatmap(l2_val,row_km = 10,row_names_gp = gpar(fontsize = 5),row_labels = genes$external_gene_name,
cluster_rows = F, name="logFC", top_annotation = ha, col = col_logFC,
cell_fun = function(j, i, x, y, w, h, col) { # add text to each grid
grid.text(round(l2_val[i, j],2), x, y)
})
The result is the following:
How can I make the numbers smaller, so that they can fit in the cells?
• 1,423 views
•
link
1 answer
Please change grid.text(round(l2_val[i, j],2), x, y) section of your code into grid.text(sprintf("%.1f", l2_val[i, j]), x, y, gp = gpar(fontsize = 20)).
Your final code will be like this. I have not tried it though.
l2_val <- as.matrix(genes$log2FoldChange)
h2 <- Heatmap(l2_val,row_km = 10,row_names_gp = gpar(fontsize = 5),row_labels = genes$external_gene_name,
cluster_rows = F, name="logFC", top_annotation = ha, col = col_logFC,
cell_fun = function(j, i, x, y, width, height, fill) { # add text to each grid
grid.text(sprintf("%.1f", l2_val[i, j]), x, y, gp = gpar(fontsize = 20))
})
• 0 views
•
link
Log in to answer this question.