简体   繁体   中英

How do I edit the dendrogram whilst using heatmap.2 function in r

I am trying to create a heatmap to represent the change of gene expression over a period of time. the code I have used is this:

coul <- colorRampPalette(brewer.pal(8, "Reds"))(25)
heatmap.2(dm, dendogram=c("row"),Colv=NA, xlab="Time points", ylab="Genes of interest", scale="row", col=coul, tracecol = NA) 

As one cant really see the branches of the dendogram that well, I was wondering whether you can somehow stretch it out to become more visible?

I was also wondering how to remove the "colour key and histogram" label. Many thanks!

if you don't mind the color guide being wide, you just use the lwid option, you specify a vector that decides the ratio of dendrogram to heatmap, below I use c(3,3), which means 1:1.

set.seed(100)
x = matrix(rnorm(1000),100,10)
heatmap.2(x,trace="none",Colv=NA,dendrogram=c("row"),tracecol = NA)

在此处输入图片说明

heatmap.2(x,trace="none",Colv=NA,
dendrogram=c("row"),lwid=c(3,3),tracecol = NA,keysize=0.75)

在此处输入图片说明

One way to narrow the margins of the color guide is to use key.par, where you set the margins on the right to be larger (I use 10 in example below).

heatmap.2(x,trace="none",Colv=NA,dendrogram=c("row"),
lwid=c(3,3),tracecol = NA,keysize=0.75,key.par=list(mar=c(3,3,3,10)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM