I have a large dataset of the expression of genes. The rows are the genes. The columns are SPECIFIC tissues- so it is the gene expression in that tissue
I'm using the following code to make a heatmap:
heatmap(expression_all_tissues_matrix, scale= "column",col=brewer.pal(9,"Blues"))
I do not know how to make a legend. I've tried to make the legend/key seperately but I cannot figure out how to use "Blues" in brewer.pal.
Thanks!
The use of the pheatmap package with its eponymous function allows to get what you are looking for. The following code allows you to have the legend on the same graph.
You can also play on several arguments to associate rows and columns by clustering, but if you don't want to classify them, just use the arguments cluster_rows = F and cluster_col = F . Don't forget to normalize the data, it can help you to have a nicer rendering. Use
?pheatmap
for more information.