How to draw a heatmap from a matrix of 305 columns and 865 rows in R.
The code I have written for the matrix is
nba <- read.csv("mydata.csv", sep=",")
row.names(nba) <- nba[,1]
nba <- nba[,2:865]
nba_matrix <- data.matrix(nba)
nba_heatmap <- heatmap(nba_matrix, Rowv=NA, Colv=NA, col = brewer.pal(9, "Blues"), scale="column", margins=c(5,10))
Now the code gives me the heatmap as shown bellow, but the labels are not clear. Please help me to get a clear heatmap.
since you stated that you need all the labels, the only way I see is reducing the font size. You can do this by setting the cexCol
and cexRow
parameters in your call to heatmap()
; for example like this:
heatmap(as.matrix(iris[,1:3]),cexRow = 0.1, cexCol = 0.1,)