[R] Cutting heatmap dendrogram
maechler at stat.math.ethz.ch
Wed Jul 21 12:25:21 CEST 2004
>>>>> "Sean" == Sean Davis <sdavis2 at mail.nih.gov>
>>>>> on Wed, 21 Jul 2004 06:01:33 -0400 writes:
Sean> Paul, You can certainly get a heatmap of a subset of
Sean> your data by simply subsetting. If you have a group
Sean> of genes obtained from cutree, simply do a heatmap on
Sean> that set of genes. If you obtain a set of genes, say
Sean> A, and want to do a heatmap on that subset, simply do
Sean> heatmap(as.matrix(data[A,])) where A contains either a
Sean> logical vector or indices for the genes of interest.
Sean> The dendrograms will be generated for those samples
Sean> and genes based on the subset of data. You could, of
Sean> course, pass in the sample dendrogram from the
Sean> original clustering of all genes if you like.
this was probably helpful but didn't really answer the original question.
One thing you (Paul) should do is to "cut()" the dendrogram
instead of "cutree()"ing the hclust result and then *pass* the
cut()ed dendrogram directly to heatmap().
I'm interested to hear if that works (haven't got time to
experiment with that just now).
Sean> It sounds like you are aiming for interactive
Sean> clustering, which R does not do well. Consider using
Sean> an external viewer such as the cluster/treeview combo
Sean> or the TIGR clustering program (can't remember name).
Sean> Finally, for future reference, it is probably worthwhile posting
Sean> microarray questions to the Bioconductor mailing list rather than
I disagree. This was a question about heatmap() an R function
of more general use than microarrays.
I would have found it "wrong" to ask this question on the
bioconductor mailing list.
Sean> On Jul 20, 2004, at 9:39 PM, Paul Boutros wrote:
>> I've been clustering my data using hclust and cutting the resulting
>> with cutree. Separately, I visualize the clusterings with heatmap.
>> Is it
>> possible to have the dendrogram on the heatmap reflect the cutree
>> That is, instead of having one large dendrogram, it would have 4 or 25
>> the example below. Any guidance on if that's possible or not, and what
>> kinds of commands I should be looking into would be very much
>> I'm using R 1.9.0 on Windows XP.
>> # load libraries
>> # working copy of data
>> set1 <- as.matrix(data);
>> set2 <- t(set1);
>> # genes
>> genes.distance <- as.dist(1-cor(set2));
>> genes.clusters <- hclust(genes.distance);
>> genes.dendrogr <- as.dendrogram(genes.clusters);
>> # samples
>> samples.distance <- as.dist(1-cor(set1));
>> samples.clusters <- hclust(samples.distance1);
>> samples.dendrogr <- as.dendrogram(samples.clusters1);
>> # cut the trees
>> samples.members <- cutree(samples.clusters, k=4);
>> genes.members <- cutree(genes.clusters, k=25);
>> # heatmap colouring
>> my.colors <- function(n = 20, low.col = 0.35, high.col=1, saturation =
>> if (n < 2) stop("n must be greater than 2")
>> n1 <- n%/%2
>> n2 <- n - n1
>> c(hsv(low.col, saturation, seq(1,0,length=n1)),
>> hsv(high.col, saturation, seq(0,1,length=n2)))
>> # make the heatmap
>> hv <- heatmap(as.matrix(data), Rowv=genes.dendrogr,
More information about the R-help