r - 如何缩短heatmap.2()中ColSideColors的高度

标签 r plot heatmap

我的以下代码:

library(gplots);
library(RColorBrewer);

dat <- read.table("http://pastebin.com/raw.php?i=wM7WxEvY",sep="\t",na.strings="NA",header=TRUE)
dat <- dat[complete.cases(dat),]
dat.log <- log2(dat);

# Clustering and distance function
hclustfunc <- function(x) hclust(x, method="ward")
distfunc <- function(x) dist(x,method="maximum")

# Here we cluster based on the Celltype (Column)
d <- distfunc(t(dat.log))
fit <- hclustfunc(d)
clusters <- cutree(fit, h=20)
nofclust.height <-  length(unique(as.vector(clusters)));


# Colors setting 
hmcols <- rev(redblue(256));
selcol <- colorRampPalette(brewer.pal(9,"Set1"))
clustcol.height = selcol(nofclust.height);


pdf(file="temp.pdf",width=30,height=40);
heatmap.2(as.matrix(dat.log),Colv=FALSE,lhei = c(0.25,4),ColSideColors=clustcol.height[clusters],density.info="none",scale="none",margin=c(10,10),col=hmcols,symkey=F,trace="none",dendrogram="none",keysize=1,hclust=hclustfunc,distfun=distfunc);
dev.off();

生成此图: enter image description here

请注意,ColSideColors 太高。怎么才能缩短呢?

最佳答案

?heatmap.2:可以通过为 lmat、lwid 和 指定适当的值来覆盖 RowSideColorColSideColor 的布局lhei。lmat控制每个元素的相对位置,而lwid控制列宽,lhei控制行高。请参阅帮助页面layout 了解如何使用这些参数的详细信息。”

就您而言,您必须更改 lhei,请尝试 lhei=c(1,15)

关于r - 如何缩短heatmap.2()中ColSideColors的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20675242/

相关文章:

r - 如何将数据导入R中的向量

r - dplyr:gather 中的两个键

plot - GNUplot Autoscale 设置 xrange 等于 yrange

python - OpenStreetMap 背景上的 Cartopy 热图

python - Seaborn 在热图中显示 3 位数字的科学记数法

gnuplot - 空图 gnuplot

python - pandas 是否具有与 R 的 'with()' 和 'within()' 函数等价的功能?

r - 如何使用列之一中的值对data.frame进行过滤/子集设置

r - 分层/多级饼图

python - 你如何在情节图例中显示文本标签? (例如,删除图例中的标签线)