Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - heatmap - width of columns (layout?)

I am using heatpmap.2() on R to represent some gene expression in different samples. However I tried a lot of things, but I am unable to control the width of my samples. Here is my code basically:

heatmap.2( t(logM[1:6,1:500]), 
       Colv=NA, 
       col=my_palette, 
       colsep=3,
       trace=c("none"),
       density.info=c("none"),
       adjCol = c(1,1), #more or less move text 
       cexRow = 0.1, 
       xlab="Mices")

I would like to reduce the size of my columns (corresponding to my samples, I've got 6 samples, meaning 6 columns, I can't post any pictures as illustration , sorry). I have looked for a while on the internet but couldn't find what I was looking for.

Thank you very much for your help, I think that this it can be solved in 1 or 2 lines, but when you don't find...

Best Regards,

like image 911
mohikran Avatar asked Dec 13 '25 18:12

mohikran


1 Answers

I will recommend using pheatmap library. It not only provides a sensible default parameters but it is easily customizable as well.

edata <- structure(list(Controll = c(1.88652404567248, 7.56216163122565, 
5.14725899353288, 6.08609722473225, -0.299183966356617, 4.25027223369266, 
5.45902343668683, 5.85281618559412, 2.93112975036833, 6.12522039745773
), Controll.1 = c(2.29406389045036, 6.97597451795928, 4.5147662930767, 
6.09625239882511, 0.921990457532795, 4.17832412568404, 5.95377074638688, 
5.37442992479651, 0.54939804990357, 6.72853709005767), Pert. =
c(1.79358946043894, 
7.90872166216125, 5.1124575575158, 6.29352463374008, 0.891739809245287, 
4.84160106842908, 5.07613585232771, 3.61007431367141, 2.44943490047975, 
5.27177316582586), Pert..1 = c(2.20978097040356, 7.57067518392199, 
4.59252962972135, 5.91408661908659, -0.339030105179552, 4.25593889774791, 
4.80784977136993, 3.46482298621816, 2.34957363521685, 4.47242819598903
)), .Names = c("Controll", "Controll.1", "Pert.", "Pert..1"),
row.names = c("ACRV1", 
"DUSP1", "GAB1", "KIF1C", "LASS1", "MITD1", "NR2C2AP", "PLEKHG2", 
"TEKT3", "ZDHHC20"), class = "data.frame")


library(pheatmap)
pheatmap(edata)

Full width

pheatmap(edata, cellwidth=25)

width 25

like image 151
zero323 Avatar answered Dec 16 '25 11:12

zero323



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!