Question: How to reduce the length (size) of the dengrogram in heatmap.2
1
gravatar for BIOAWY
7 months ago by
BIOAWY100
HUJI
BIOAWY100 wrote:

This is the code I've used to build by Heatmap with dendrogram

heatmap.2(as.matrix(SI_Ratios), scale = "none", col = bluered(100), 
      trace = "none", density.info = "none", cexRow=0.5, cexCol=0.75, margins = c(5,20),
      key.xlab = "Ln(Peak Area / T0)")

HeatMap https://ibb.co/dNVODn

How can I reduce the length of the dendrogram? Also How to increase the font size of the Color Key description?

R gene • 1.4k views
ADD COMMENTlink modified 7 months ago by Kevin Blighe33k • written 7 months ago by BIOAWY100
1
gravatar for Kevin Blighe
7 months ago by
Kevin Blighe33k
Republic of Ireland
Kevin Blighe33k wrote:

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 par(oma=c(1,15,1,1)):

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

Screen_Shot_2018_05_01_at_14_44_14


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

Kevin

ADD COMMENTlink written 7 months ago by Kevin Blighe33k

Thanks, Kevin,

This works for me. However, I can not zoom the Heatmap and its blurred. How can I save this to a PNG with good resolution

ADD REPLYlink written 7 months ago by BIOAWY100
2

Don't use PNG if you want a very clear image. PNG, TIFF, BMP, etc., are pixel-based. If you instead use a vector-based graphics format, then you would get publication-ready figures. You can then use the width and height parameters in order to modify the size (inches) of the output.

#Default size
pdf("Heatmap.pdf", width=7, height=7)
   ...
dev,.off()

#Wide heatmap
pdf("Heatmap.pdf", width=9, height=4)
   ...
dev,.off()

#Skinny heatmap
pdf("Heatmap.pdf", width=4, height=9)
   ...
dev,.off()
ADD REPLYlink modified 7 months ago • written 7 months ago by Kevin Blighe33k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1241 users visited in the last hour