By default, the x-axis labels for heat maps generated by the pheatmap package rotate 270 degrees. I need to make them 90 degrees.
I traced the pheatmap() function and saw that there is an internal (invisible) function that creates 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 just changed rot = 270 to rot = 90 , and also hjust = 0 to hjust = 1 in the above function using the following command, and it worked:
fixInNamespace("draw_colnames","pheatmap")
But the problem is that fixInNamespace() constantly changes the definition of the function in the package. I would rather be happier not to change the initial definition of the function, but temporarily replace the definition of the draw_colnames() function draw_colnames() my own only in the cases that I need.
Is there any solution?
source share