Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

heatmap2 lmat,lhei, lwid parameters?

Tags:

r

heatmap

I'm trying to make a heat map with dendrogram in R. I'm also trying to make it so that the color matrix is on the bottom of the heat map. i understand that I would have to change the value of lmat for this. So far I have something like this for lmat.

 lmat=rbind(c(0,3,0), c(2,1,0), c(0,4,0)).

After I run it, it asks me to update the lhei and lwid values. After looking at the documentation, I understand that these are vectors for column width and row height. But I don't understand the multiple values needed for their values. For ex, when I set this , I get this error.

  lhei must have length = nrow(lmat) = 3

I'm not sure what the three values for lhei would correspond to. This leads me to a broader question, what does each value in the vectors for lhei and lwid correspond to?

like image 822
shwetaaaa Avatar asked Jan 31 '23 01:01

shwetaaaa


1 Answers

lhei is the relative heights of the rows in the plot. Heatmaps in R are a bit screwy. The graphics device (think of a canvas you want to paint on) is divided into a grid where each element of the heatmap will be plotted: color key, dendrograms and the heatmap. This makes a 2x2 grid. when you add the colsideColors or rowsidecolors the grid expands by 1 in the appropriate dimension, (e.g. 1 more row when adding colsidecolors). When you add this extra row you need to tell R how much (relative) space it needs.

mat <- matrix(rnorm(200), nrow = 20)
colCols <- rep(c("red", "blue"), 5)
heatmap.2(mat, trace="none", ColSideColors = colCols,
          lmat=rbind(c(5,4), c(3,2), c(0,1)),
          lhei=c(2,4,0.2))

enter image description here

like image 165
emilliman5 Avatar answered Feb 03 '23 03:02

emilliman5