For modifying the font size of the colour key, just use the
key.lab parameter (as I do below).
For changing the 'length' of the dendrogram, you have to realise that the dendrogram heights are representative of the distances between your samples and are measured on the scale that you used during the creation of the distance matrix, usually Euclidean distance. Euclidean distances can be large, depending on your data-type, even into the 100s.
You can play around with the margins in order to 'squeeze' the dendrgrams - you can do this via
par(oma). Here, I have modified the left margin with
data <- replicate(20, rnorm(50))
rownames(data) <- paste("Gene", c(1:nrow(data)))
colnames(data) <- paste("Sample", c(1:ncol(data)))
par(oma=c(1,15,1,1)); heatmap.2(data, key=TRUE, keysize=1.5, key.xlab="X-axis", key.ylab="", key.title="", key.par=list(mar=c(4,0,1,2), cex=1.0, cex.lab=2.0, cex.axis=2.0), margins=c(5,5))
If you wanted a distance metric that is measured on a smaller range, you could do correlation distance by adding
distfun=function(x) as.dist(1-cor(t(x))) to the
heatmap.2 function, as I do here: A: Hierarchical Clustering in single-channel agilent microarray experiment