Hi Sean, Martin
>>>>>> "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.
Yeah, I'm okay with getting subsets and plotting them separately, but the
goal
is to be able to automatically show and label the subsets on the heatmap itself.
>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().
Ahh, that makes sense, but maybe I'm missing something?
###########################################> samples.dendrogr2 <- cut(samples.dendrogr1, 4);
> samples.dendrogr2
$upper
`dendrogram' with 2 branches and 2 members total, at height 1.082017
$lower
$lower[[1]]
`dendrogram' with 2 branches and 4 members total, at height 0.0631504
$lower[[2]]
`dendrogram' with 2 branches and 12 members total, at height 0.5823986
> plot(samples.dendrogr2);
Error in plot.window(xlim, ylim, log, asp, ...) :
need finite xlim values
In addition: Warning messages:
1: no finite arguments to min; returning Inf
2: no finite arguments to max; returning -Inf
3: no finite arguments to min; returning Inf
4: no finite arguments to max; returning -Inf
> hv <- heatmap(as.matrix(data), Rowv=genes.dendrogr,
Colv=samples.dendrogr2);
Error in lV + rV : non-numeric argument to binary operator
> traceback();
8: oV(x[[1]], wts)
7: oV(x[[1]], wts)
6: oV(x, wts)
5: inherits(x, "dendrogram")
4: midcache.dendrogram(oV(x, wts))
3: reorder.dendrogram(ddc, Colv)
2: reorder(ddc, Colv)
1: heatmap(as.matrix(data), Rowv = genes.dendrogr, Colv = samples.dendrogr2,
col = my.colors())
###########################################
Any ideas are (still) very much appreciated!
Paul
>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).
I'll check out MeV, then, but since the rest of my processing is in R....
Sean>> Finally, for future reference, it is probably worthwhile
posting
Sean>> microarray questions to the Bioconductor mailing list rather
than
Sean>> R-Help.
>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.
>Martin Maechler
Sean>> Sean
Sean>> On Jul 20, 2004, at 9:39 PM, Paul Boutros wrote:
>> Hello,
>>
>> I've been clustering my data using hclust and cutting the
resulting
>> tree
>> with cutree. Separately, I visualize the clusterings with heatmap.
>> Is it
>> possible to have the dendrogram on the heatmap reflect the cutree
>> results?
>> That is, instead of having one large dendrogram, it would have 4 or
25
>> in
>> 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
>> appreciated.
>> I'm using R 1.9.0 on Windows XP.
>>
>> Thanks!
>> Paul
>>
>> # load libraries
>> library(stats);
>>
>> # 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 =
>> 0.85)
>> {
>> 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,
>> Colv=samples.dendrogr,
>> col=my.colors());
>>