I am trying to place a label "participants" beside the y-axis of a heatmap instead of the row names. Removing row names was easy with changing the default to show_rownames = F, but I did get no response to label_row when I changed it from NULL to either T of "participants". Is there a way of placing a label instead of row names?
Thank you, Seidel. Yes, I want to avoid the row names, and I did that earlier: show_rownames = FALSE, which worked well. I also removed the dendrogram along the y-axis. The aim was to put the label "participants" into the position where the rownames were before. I played around with the grid.text function but I couldn't make it work. I end up getting an error message: non-numeric argument to binary operator
Maybe easier to show, here is my codeline:
I get the error message I don't know how to post an image of my heatmap but maybe that's not necessary.
Is the "with: + " line part of your code? That will cause an error. There should only be two separate lines to draw the figure: (1) pheatmap(stuff), and (2) grid.text(otherstuff). You don't need a plus sign. Just each function on its own line.
Ok, without the plus I don't get any error code and I do get a heatmap but the label 'participants' is positioned not beside the legend on the outside instead it is in the map, in the last column. It's a step in the right direction I feel. Is there a way of moving it to the outside?
Yes. The coordinate space of the plot is mapped from 0 to 1 for both x and y starting at the upper left corner. So simply play with the x and y numbers, and execute the function over and over again until it's where you want (0.93, 0.95, etc.). When it's right, execute both functions a last time to draw the final version. (you can execute with grid.text() over and over again, which is messy but quick and easy. In fact you can give it a vector of numbers instead of just one to try many positions at once).
Great, I can move it around now. Next issue I didn't think of is that pheatmap automatically places the legend next to the last column. After removing the row names it is now right beside the map. I like to move it to make room for 'participants'. Would you know how to do it?