Reputation: 101
I am trying to increase sepwidth betweeen rows and columns in my heatmap. I use sepwidth, however when i try to increase sepwidth, it does not move columns or rows to right.
Here is an example
library(gplots)
mat = matrix( rnorm(100), ncol=5 )
colorside = gray(1:5/5)
bk1 = seq(min(mat),max(mat),length.out=11)
col = redgreen(10)
# And now the heatmap
heatmap.2( mat,
key=FALSE,
trace="none",
ColSideColors=colorside,
cexRow=0.6,
breaks=bk1,
col=col,
sepwidth=c(0.4,0.4),
sepcolor="purple",
colsep=1:ncol(mat),
rowsep=1:nrow(mat))
Thank you for any help.
Upvotes: 2
Views: 1029
Reputation: 4283
I am not sure I completely understand what you want. Anyway my guess is that you want to add space before the first column and above the first row.
sepwidth
defines the amount of space between columns and rows, and applies that space based on the values in the vectors colsep
and rowsep
. In your case, you simple have to start one unit earlier in the definitions of colsep
and rowsep
, like in the following code:
setseed(8765) ## added for reproducibility
# Your code
library(gplots)
mat = matrix( rnorm(100), ncol=5 )
colorside = gray(1:5/5)
bk1 = seq(min(mat),max(mat),length.out=11)
col = redgreen(10)
## First call to get "hm1"
hm1 <- heatmap.2( mat,
key=FALSE,
trace="none",
ColSideColors=colorside,
cexRow=0.6,
breaks=bk1,
col=col,
sepwidth=c(0.4,0.4),
sepcolor="purple",
colsep=0:ncol(mat), ## changed
rowsep=0:nrow(mat)) ## changed
# Look at lwid and define a new one to use
hm1$layout$lwid
# [1] 1.5 4.0
my_lwid <- c(1.0, 4.5)
## call with altered lwid
hm2 <- heatmap.2( mat,
key=FALSE,
trace="none",
ColSideColors=colorside,
cexRow=0.6,
breaks=bk1,
col=col,
sepwidth=c(0.4,0.4),
sepcolor="purple",
lwid = my_lwid, ## added
colsep=0:ncol(mat),
rowsep=0:nrow(mat))
hm2$layout$lwid
Please, let me know whether this is what you wanted.
Upvotes: 3