如何在R&#39的热图中修改RowSideColor列大小.2()

时间:2013-12-06 10:33:14

标签: r plot heatmap

我有以下数据:

    foo_06.ix   bar_06.ix   bar_06.iz   qux_06.ix   qux_06.iz
1416474_at Igdcc4   0.563   5.649   1.654   0.776   0.973
1416576_at Socs3    5.793   5.417   0.694   3.256   0.951
...

我想绘制层次聚类热图。

使用此代码:

library(gplots);
library(RColorBrewer);

tm <- read.table("http://dpaste.com/1494806/plain/",header=TRUE,sep="\t")

nofclust <- 21;
# Clustering functions 
hclustfunc <- function(x) hclust(x, method="complete")
distfunc <- function(x) dist(x,method="euclidean")

d.tm <- distfunc(tm)
fit.tm <- hclustfunc(d.tm)
clusters <- cutree(fit.tm, k=nofclust)

# Define colours
hmcols <- rev(brewer.pal(11,"Spectral"));
selcol <- colorRampPalette(brewer.pal(12,"Set3"))
selcol2 <- colorRampPalette(brewer.pal(9,"Set1"))
sdcol= selcol(5);
clustcol = selcol2(nofclust);

# Plot heatmap
pdf(file="tmp.pdf",width=27,height=27);
heatmap.2(as.matrix(tm),dendrogram="row",scale="row",RowSideColors=clustcol[clusters],ColSideColors=sdcol,col=hmcols,trace="none", margin=c(12,12), hclust=hclustfunc,distfun=distfunc,lwid=c(0.1,0.1,0.1,0.1,0.1),keysize=0.5);
dev.off()

它产生下图: enter image description here

使用固定的PDF尺寸(27x27)我想做的事情:

  1. 创建row side column小于全部的热图 5个主要列。目前它太宽了。 我使用lwid=0.1修复了这5个主要列大小,因此请勿更改。

  2. 挤压树形图。

  3. 如果以上两个生效,则右侧的行名称占据页面中的显着空格。
  4. 如何修改上面的代码才能实现这些目标?

0 个答案:

没有答案
相关问题