Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple RowSideColor columns heatmap.2 from gplots package

Tags:

r

gplots

I would like to be able to have use two RowSideColor bars with the heatmap.2 function from the R package plots, but I can't figure out how to do it. I've seen this question asked before on stack overflow, and while the question was responded to, the responses didn't address the question. Adding the factors to the input data matrix won't work because it would affect the results of the hierarchical clustering. I am open to using other heatmap-like functions to achieve my goals if that's necessary.

Thanks, Brad

like image 438
Brad Davis Avatar asked Sep 03 '14 16:09

Brad Davis


1 Answers

I've wanted to do this before and always used to make two heatmaps and copy and paste one RowSideColors bar from one heatmap onto the other one. I just did some more searching and found the heatmap.plus package that can do this, though:

# install.packages("heatmap.plus") #install package
require("heatmap.plus")

data(cars) # using cars data as example

# create a matrix of colors for RowSideColors
myCols = cbind(rep(c("yellow", "blue"), 25), rep(c("red", "green"), 25))

heatmap.plus(data.matrix(cars), RowSideColors=myCols)

The RowSideColors argument in this package can accept a matrix of colors to plot multiple row side colors.

like image 78
ping Avatar answered Oct 21 '22 08:10

ping