Reputation: 173
I'm trying to recreate a heatmap, using heatmap.2, similar to this(1):
I'm able to add the "A C G T" labels to the bottom column and right row labels. I'm trying to add "group" names to the top and left axis ("1012T3" etc. and "G>A" etc).
I've tried doing this through the add.expr
function, but this overlays the text on top of the heatmap, and disappears when I try moving it to the left of the heatmap.
I've been able to add it by hard coding the coordinates like this(2):
pos1 <- structure(list(x = c(0.222, 0.861),
y = 0.993),
.Names = c("x", "y"))
text(x=seq(pos1$x[1], pos1$x[2], len=6), y=rep(pos1$y[1],6) ,
srt=0, xpd=TRUE, adj = 0,
labels=c('C>A', 'C>G', 'C>T', 'T>A', 'T>C', 'T>G') )
While it works, I'm not quite satisfied by somewhat hacky solution of having to hard code the coordinates. Does anyone have a solution to adding row/column labels to the left/top without hard coding the coordinates?
Thanks!
Upvotes: 4
Views: 5493
Reputation: 154
A "ñapa" that I have found is by using the parameter, offsetRow.
i.e: heatmap.2(dataframe, offsetRow=-36). offsetRow with negative numbers move the labels to the left.
Upvotes: 2