I'm using heatmap.2 to obtain a triangular heatmap (where the upper part of the matrix is deleted).
I used this code:
my_data_t <- t( as.matrix(my_data) )
`cor.matrix <- cor( my_data_t, method = "spearman")`
`cor.matrix[upper.tri( cor.matrix )] <- NA`
`my.col <- c( "blue", "green", "yellow", "orange", "red" )`
`my.breaks <- c( 0, 0.2, 0.6, 0.8, 1 )`
`hm2 <- heatmap.2( cor.matrix, scale="none", Rowv=NA, Colv=NA,
col=my.col, breaks=my.breaks, margins(5,5),
cexRow=0.5,cexCol=1.0,key=TRUE,keysize=1.5,
trace="none")`
my_data was something like this:
my_data <- "Taxon NO8.4 NO6.1 NO7.3 NO9.4 N09.7
a 0.1 0.05 0.01 0.2 0.06
b 0.0 0.8 0.8 0.0 0.0
c 0.7 0.0 0.0 0.0 0.1
d 0.0 0.01 0.08 0.0 0.09
e 0.0 0.0 0.0 0.0 0.0
f 0.09 0.05 0.01 0.04 0.0
g 0.07 0.7 0.0 0.01 0.08"
Now I'd like to have the color key on the right of the heatmap and I'd like tomake it bigger (as a bar on the right of the heatmap, as long as this one).
Is it possile in the heatmap.2
function??
I also tried to use the legend()
command, but it seems to me that it can generate only box legends, with one box for each color, so no an unique side bar, right??