How to modify the RowSideColor column size in R's heatmap.2()

Viewed 2195

I have the following data:

    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
...

Which I want to plot the hierarchical clustering heat map.

With this code:

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()

It produces the following figure: enter image description here

Using the fixed PDF size (27x27) what I want to do:

  1. Create the heatmap where the row side column is smaller than all 5 primary columns. Currently it's too wide. These 5 primary column size I fixed with lwid=0.1, so do not change.

  2. Squeeze the dendogram.

  3. If the above two takes effect, the row names on the right takes prominent space in the page.

How can I modify my code above to achieve these?

0 Answers
Related