This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Combine Multiple Separate Heatmaps Together

Hi, everyone

Do you known how thay get this type of pictures? Thank you!

I known seqMiner can give this type of picture, but I have to work on server(only command line available) for it will cost lots of memory. Can this be finished by R or other programming languages?

The input data format may like this, several groups of data, each group has same columns:

#                      grp1                       grp2                              grp3
Gene    1       2       3       4       1       2       3       4       1       2       3       4
a       0.1     0.2     0.3     0.4     0.1     0.2     0.3     0.4     0.1     0.2     0.2     0.4
b       0.1     0.2     0.3     0.4     0.1     0.2     0.3     0.4     0.1     0.2     0.2     0.4
c       0.1     0.2     0.3     0.4     0.1     0.2     0.3     0.4     0.1     0.2     0.2     0.4
d       0.1     0.2     0.3     0.4     0.1     0.2     0.3     0.4     0.1     0.2     0.2     0.4
e       0.1     0.2     0.3     0.4     0.1     0.2     0.3     0.4     0.1     0.2     0.2     0.4
f       0.1     0.2     0.3     0.4     0.1     0.2     0.3     0.4     0.1     0.2     0.2     0.4

enter image description here

And also when using heatmap.2 to draw heatmap for lots of data, it will take a large amount of time. Is there any fast tools to solve it?

Thank you!

heatmap

bit small picture, also this doesn't look like a heatmap. and most important: which data were used to generate this? It's hard to help out of context with contradictory information.

Sorry for my ambigous information. The a larger picture and sample data are attached. It is not a classical heatmap but more like color each point according to its value.

2 answers

This should get you started. You'll require packages ggplot2 and reshape2. I don't see any clustering here. Hope I'm right.

require(ggplot2)
require(reshape2)
x <- as.data.frame( matrix(rnorm(1200,100,35), ncol=12) )
names(x) <- paste( "g", sort(rep(1:3,4)), rep(1:4,3), sep="")
head(x)
x$id <- paste( "gene", 1:dim(x)[1], sep="")

x.m <- melt( x, c("id"), names(x)[1:12] )
x.m$grp <- c( rep("g1",400), rep("g2",400), rep("g3",400) )
x.m$grp <- factor(x.m$grp, levels=c("g1","g2","g3"), ordered=T )
x.m <- subset( x.m, select=c(grp, id, variable, value) )

p <- ggplot( data=x.m, aes(variable, id)) + geom_tile(aes(fill = value), colour = "white") + scale_fill_gradient(low = "white", high = "steelblue")
p <- p + facet_grid( .~grp, scale="free")
p

This is how it looks. You can build on this as you want. In case you don't follow, let me know. I'll try to comment the code later.

Good work, but R cries when the list (before melting) > 10K-15K and with facets, launch the code and go out for a walk. Then, best is to remove the labels on y axis. Also, concerning clustering one never knows, it might be centroid :)

It is slow with ggplot2 on large data. True. However, I run on the cluster and continue with the other tasks. Doesn't seem to bother me so much, yet! :)

Are you running it on parallel nodes, which lib are you using for that or a custom code

Nope. For loading a data and for creating the plot using ggplot2, I don't think there's any amount of parallelism possible. For the in-betweens I use package doMC with plyr

I merely stated it to explain that there are no constraints on memory. Usually, the loading is faster than ggplot2 creation.

Yeah yeah, I got it, one can also use 'ff' for loading.

Cheers

Do you mean "p + opts(axis.ticks=themeblank(), axis.text=themeblank()) "?

yeah, just the axis.text should be axis.text.y, because x axis is fine, just y axis is cluttered up

Great great answer, Thanks Arun! I wonder if I can cluster data first, then do the heatmap?

In that case, I think you require something like this?

Obtain coverage for your factor within certain range like +/-2.5 kb with a binsize like 50 and then load this matrix in javatree view. It should work. Save multiple plots and line them together manually or you can try comibing geomtile for heatmap generation with facetsgrid for multiple maps of the ggplot2 lib in R.

Cheers

Log in to answer this question.