how to set the size of cell of heatmap.2 in R
3
1
Entering edit mode
9.4 years ago
Zhilong Jia ★ 2.2k

How to resize the size of cell in a heatmap via heatmap.2?

The main reason is the row label on the right of heatmap is not shown completely. Thank you.

heatmap.2 R • 44k views
ADD COMMENT
0
Entering edit mode

For your problem of showing the row labels on the right of the heatmap.2 add the argument "margins"

e.g.

heatmap.2(x, margins = c(5,20)) # The first number is the bottom margin, and the second is the left margin of the plot
ADD REPLY
1
Entering edit mode
9.4 years ago

The size of each row is dependent on (A) how many rows there are and (B) how tall the image/window/whatever is. You can play around with margins a bit, but essentially if you need taller cells then either plot fewer of them or make the whole thing larger.

ADD COMMENT
0
Entering edit mode

Exactly. I had similar issues with the row labels not showing completely, I set the margins and it worked.

ADD REPLY
1
Entering edit mode
8.1 years ago

cexRow and cexCol are probably more helpful overall, but you can also modify the cell sizes using

For example, lhei = c(1,8) and lwid = c(0.5,4) will make the heatmap portion larger relative to the scale (which buys you a little extra space), where the first value is the legend size and the second value is the main heatmap size. If you are plotting dozens of genes, this might matter.

ADD COMMENT
0
Entering edit mode
8.1 years ago

Specifiy cexRow in the heatmap.2() call to change the row label font size. For example:

> heatmap.2(..., cexRow=0.075, ...)

Likewise, specify cexCol for column label font size.

I don't know of any way to automate this — it seems necessary to tweak per figure, depending on the number of rows and other features shown. A non-R tool like matrix2png can make this is a little easier if you don't need clustering or dendrograms.

ADD COMMENT

Login before adding your answer.

Traffic: 3149 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6