It appears your problem is with the colsep
and rowsep
arguments. From the help file:
colsep, rowsep, sepcolor
(optional) vector of integers indicating which columns or rows should be separated from the preceding columns or rows by a narrow space of colorsepcolor
Instead of "indicating which columns or rows should be separated", your code creates a vector as long as the number of elements in the matrix. If you had set colsep=c(1,3)
, the separator between the 1st and 2rd columns and the separator between the 3rd and 4th columns would have been colored. I don't believe there is a way to color the cell borders without using the colsep
and rowsep
arguments. The cell borders are, by default, not drawn unless these arguments are given values.
# First, a reproducible data set
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.1,0.1),
sepcolor="purple",
colsep=1:ncol(mat),
rowsep=1:nrow(mat))