Reputation: 25
I generated heatmap using heatmap.2
function in R and tried to make two modifications
The colour key scale need to range 5,10,15. However, I could not set that range for the scale by changing the following line,
colors = c(seq(0,5,length=100), seq(5,10,length=100), seq(10,15,length=100))
Number (like 1, 2 3 upto the total number of rows) is shown to the end of each row and I could not delete it.
So, I look forward any suggestion to set the scale and remove the numbered Y-axis.
library(gplots)
library(RColorBrewer)
dat <- read.csv("C:/Users/anikng/Desktop/stress.csv")
dat_matrix <- data.matrix(dat)
colors = c(seq(0,5,length=100),seq(5,10,length=100),seq(10,15,length=100))
my_palette <- colorRampPalette(c("green","black","red"))(n = 299)
heatmap.2(dat_matrix, dendrogram="none", Rowv=FALSE, Colv=FALSE, col = my_palette, breaks=colors, scale="none", key=TRUE, density.info="none", trace="none", symm=F,symkey=T,symbreaks=T)
Upvotes: 0
Views: 382
Reputation: 60462
When asking a question it's always easier if you can provide some example data, so
library(gplots)
library(RColorBrewer)
dat_matrix= matrix(rnorm(1000, 10, 3), ncol=10)
The issue with the range in the symkey was caused by the symkey=TRUE
argument. Removing that argument, your code now works
breaks = c(seq(min(dat_matrix), median(dat_matrix), length.out=128),
seq(median(dat_matrix), max(dat_matrix), length.out=128))
heatmap.2(dat_matrix, dendrogram="none", Rowv=FALSE, Colv=FALSE, breaks=breaks,
key=TRUE, density.info="none", trace="none", col=my_palette)
To remove the numbers from the graph, add the arguments: labRow=FALSE
and labCol=FALSE
Upvotes: 1