The x-axis labels of heatmaps produced by package pheatmap are 270 degrees rotated by default. I need to make them 90 degrees rotated.
I have traced the pheatmap() function and see there is an internal (invisible) function that produces labels:
draw_colnames <- function (coln, ...)
{
m = length(coln)
x = (1:m)/m - 1/2/m
grid.text(coln, x = x, y = unit(0.96, "npc"), vjust = 0.5,
hjust = 0, rot = 270, gp = gpar(...))
}
I simply changed the rot = 270 by rot = 90 and also hjust = 0 by hjust = 1 in above function using the following command, and it worked:
fixInNamespace("draw_colnames","pheatmap")
But the problem is that fixInNamespace() permanently modifies the function definition in the package. I rather would be more happy not to alter the original function definition, but temporarily replace the definition of draw_colnames() function by my own one just in cases that I need.
Is there any solution?