I am trying to add the color side bar to the heat map columns.
My cases/samples belongs to different groups/classes (like e.g. samples are the results of many genes expression in various cells and groups are different species).
I would like the color side bar to reflect different species. The column are labelled already by the type of the cell. I know that I can assign different colors to different species (using if and else) one by one but having more than 20 species and over 200 samples it is not practical. Same it is not practical to sort the data by the group and assign the different colors to e.g. samples 1 to 10, 11 to 25, etc...
I have found that as.character(as.numeric(data[,XXX])
, where XXX
is the column with my groups names works fine. However it delivers appalling colors. Any suggestion how to apply e.g. just a few shades from rainbow colors to it?
colCol from heatmap.2
seemed to be suitable but when used it is ignoring the same class/group and assigning e.g. the palette of colors across all the samples...
Further to the above I am wondering how to do the same when just the dendrogram is plotted. It seems to be even more complicated... Will appreciate any help!