If you look at the source code for the pheatmap function, you will see that after some data involvement, it calls the heatmap_motor function.
Looking at this function (it is not exported, so you will need to enter pheatmap:::heatmap_motor to see its source code), you will see that it uses the functions from the grid package to build a heat map, so using abline or text will not work, but grid.abline or grid.text will be!
For example (note that the coordinates were found by trial and error):
library(pheatmap) library(grid) a <- matrix(rnorm(100), 10, 10) pheatmap(a, cluster_rows = F, cluster_cols = F) grid.text(1:100, x=rep(seq(0.05, 0.91, length.out=10), 10), y=rep(seq(0, 1, 0.1)+0.05, each=10))
nico
source share