문제

The following figure enter image description here

Is generated with this code

library(gplots)
setwd("~/Desktop/");
data <- read.table(file='http://pastebin.com/raw.php?i=ZaGkPTGm', 
                   header=TRUE, row.names=1)

mat <- as.matrix(data[,-1])
z <- t(scale(t(mat))) 


# set custom distance and clustering functions
hclustfunc <- function(x) hclust(x, method="complete")
distfunc <- function(x) dist(x,method="maximum")

# obtain the clusters
fit <- hclustfunc(distfunc(z))
clusters <- cutree(fit, 5) 

# require(gplots)
pdf(file='heatmap.pdf', height=50, width=90)
heatmap.2(z, trace='none', dendrogram='row', Colv=F, scale='row', 
             hclust=hclustfunc, distfun=distfunc, col=greenred(256), symbreak=T,
             margins=c(10,20), keysize=0.5, labRow=data$Gene.symbol,
             lwid=c(1,0.05,1), lhei=c(0.03,1), lmat=rbind(c(5,0,4),c(3,1,2)),
             RowSideColors=as.character(clusters))
dev.off()

What I'm to do is to reduce the gap between the dendrogram and the rowside color of the heatmap. How can I achieve that?

The only requirement is that the dimension of the dendrogram and paper size must be kept as it is.

도움이 되었습니까?

해결책

One solution is to adjust globally the x-axis so that it fits the data range:

par(xaxs="i")
heatmap.2(z, trace='none', dendrogram='row', Colv=F, scale='row', 
         hclust=hclustfunc, distfun=distfunc, col=greenred(256), symbreak=T,
         margins=c(10,20), keysize=0.5, labRow=data$Gene.symbol,
         lwid=c(1,0.05,1), lhei=c(0.03,1), lmat=rbind(c(5,0,4),c(3,1,2)),
         RowSideColors=as.character(clusters))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top