How to resize RowSideColor column in R heatmap. 2 ()

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

Why do I want to build a hierarchical map of cluster heating.

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 displays the following image: enter image description here

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

  • Create a heat map where the row side column less than all 5 primary columns. It is currently too wide. These 5 main column sizes are fixed with lwid=0.1 , so don't change.

  • Squeeze the dendogram.

  • If the above two take effect, the line names on the right occupy a prominent place on the page.

How can I change my code above to achieve these goals?

+6
source share

Source: https://habr.com/ru/post/959467/


All Articles