I have used heatmap to visualize my microarray data. I have a matrix of M-values. I do the following. #The distance between the columns. sampdist <- dist(t(matrix[,]), method="euclidean") sclus <- hclust(sampdist, method="average") #The distance between the rows. genedist <- dist(matrix[,], method="euclidean") gclus <- hclust(genedist, method="average") heatmap(matrix[,],Rowv=as.dendrogram(gclus),Colv=as.dendrogram(sclus), col=rbg) So far so good. But what if I want to look at a group of genes that appear to have the same expression pattern in the heatmap? How do I zoom in on a dendogram in a heatmap to look at which genes that are forming the interesting clusters? I would really appreciate if someone could give me a pointer. Best regards. / Johan ******************************************************************************************* Johan Lindberg Royal Institute of Technology AlbaNova University Center Stockholm Center for Physics, Astronomy and Biotechnology Department of Molecular Biotechnology 106 91 Stockholm, Sweden Phone (office): +46 8 553 783 45 Fax: + 46 8 553 784 81 Visiting adress: Roslagstullsbacken 21, Floor 3 Delivery adress: Roslagsv?gen 30B
Johan -
Disclaimer: I've never used heatmap(), so probably I shouldn't
be answering this.
However ... the function heatmap() probably calls either plot()
or image() (regular graphics) or xyplot() (lattice graphics) in
order to set up axes and initialize the actual plotting. heatmap()
may also have a "..." argument which passes additional parameters
through to plot(), unchanged. If both of my guesses are correct
(use help("heatmap") to find out) then I would try calling
heatmap() again with an additional parameter ylim=c(a,b), where
"a" and "b" are two numbers, with a < b, which indicate
plotting
coordinates which bracket the group of genes you wish to zoom in on.
It will take a bit of experimentation to figure out what internal
coordinate system heatmap() uses to do the plotting, but this
seems like a direct way to zoom in on just a part of the plot.
This is completely untested. I leave it to you to read
help("heatmap")
and see whether any of this makes sense. Hope this helps.
- tom blackwell - u michigan medical school - ann arbor -
On Sun, 4 Jan 2004, Johan Lindberg wrote:
>
> I have used heatmap to visualize my microarray data. I have a matrix of
> M-values. I do the following.
>
> #The distance between the columns.
> sampdist <- dist(t(matrix[,]), method="euclidean")
> sclus <- hclust(sampdist, method="average")
> #The distance between the rows.
> genedist <- dist(matrix[,], method="euclidean")
> gclus <- hclust(genedist, method="average")
> heatmap(matrix[,],Rowv=as.dendrogram(gclus),Colv=as.dendrogram(sclus),
col=rbg)
>
> So far so good. But what if I want to look at a group of genes that appear
> to have the same expression pattern in the heatmap? How do I zoom in on a
> dendogram in a heatmap to look at which genes that are forming the
> interesting clusters? I would really appreciate if someone could give me a
> pointer.
>
> Best regards.
>
> / Johan
>
>
>
>
*******************************************************************************************
> Johan Lindberg
> Royal Institute of Technology
> AlbaNova University Center
> Stockholm Center for Physics, Astronomy and Biotechnology
> Department of Molecular Biotechnology
> 106 91 Stockholm, Sweden
>
> Phone (office): +46 8 553 783 45
> Fax: + 46 8 553 784 81
> Visiting adress: Roslagstullsbacken 21, Floor 3
> Delivery adress: Roslagsv?gen 30B
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
Thanks for the ideas but I already tested to give the heatmapfunction the
argument ylim but I get the following error message:
Error in image.default(1:nc, 1:nr, x, xlim = 0.5 + c(0, nc), ylim = 0.5 + :
formal argument "ylim" matched by multiple actual arguments
So then I tried to adjust the function and changed the ylim argument when
the "heatmapfunction" calls "image". But this only makes it
possible to
zoom in on the "picture" that is drawn in the heatmapfunction. The
result
is that the function draws the full dendogram on a truncated picure.
Any ideas, anyone?
/ Johan
At 13:31 2004-01-04 -0500, you wrote:>Johan -
>
>Disclaimer: I've never used heatmap(), so probably I shouldn't
>be answering this.
>
>However ... the function heatmap() probably calls either plot()
>or image() (regular graphics) or xyplot() (lattice graphics) in
>order to set up axes and initialize the actual plotting. heatmap()
>may also have a "..." argument which passes additional
parameters
>through to plot(), unchanged. If both of my guesses are correct
>(use help("heatmap") to find out) then I would try calling
>heatmap() again with an additional parameter ylim=c(a,b), where
>"a" and "b" are two numbers, with a < b, which
indicate plotting
>coordinates which bracket the group of genes you wish to zoom in on.
>
>It will take a bit of experimentation to figure out what internal
>coordinate system heatmap() uses to do the plotting, but this
>seems like a direct way to zoom in on just a part of the plot.
>
>This is completely untested. I leave it to you to read
help("heatmap")
>and see whether any of this makes sense. Hope this helps.
>
>- tom blackwell - u michigan medical school - ann arbor -
>
>On Sun, 4 Jan 2004, Johan Lindberg wrote:
>
> >
> > I have used heatmap to visualize my microarray data. I have a matrix
of
> > M-values. I do the following.
> >
> > #The distance between the columns.
> > sampdist <- dist(t(matrix[,]), method="euclidean")
> > sclus <- hclust(sampdist, method="average")
> > #The distance between the rows.
> > genedist <- dist(matrix[,], method="euclidean")
> > gclus <- hclust(genedist, method="average")
> > heatmap(matrix[,],Rowv=as.dendrogram(gclus),Colv=as.dendrogram(sclus),
> col=rbg)
> >
> > So far so good. But what if I want to look at a group of genes that
appear
> > to have the same expression pattern in the heatmap? How do I zoom in
on a
> > dendogram in a heatmap to look at which genes that are forming the
> > interesting clusters? I would really appreciate if someone could give
me a
> > pointer.
> >
> > Best regards.
> >
> > / Johan
> >
> >
> >
> >
>
*******************************************************************************************
> > Johan Lindberg
> > Royal Institute of Technology
> > AlbaNova University Center
> > Stockholm Center for Physics, Astronomy and Biotechnology
> > Department of Molecular Biotechnology
> > 106 91 Stockholm, Sweden
> >
> > Phone (office): +46 8 553 783 45
> > Fax: + 46 8 553 784 81
> > Visiting adress: Roslagstullsbacken 21, Floor 3
> > Delivery adress: Roslagsv?gen 30B
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >
*******************************************************************************************
Johan Lindberg
Royal Institute of Technology
AlbaNova University Center
Stockholm Center for Physics, Astronomy and Biotechnology
Department of Molecular Biotechnology
106 91 Stockholm, Sweden
Phone (office): +46 8 553 783 45
Fax: + 46 8 553 784 81
Visiting adress: Roslagstullsbacken 21, Floor 3
Delivery adress: Roslagsv?gen 30B
You are using the xlim and ylim arguments incorrectly. You should be doing something like xlim=c(0.5, nc+0.5), ylim=c(0.5, nc+0.5). The error message gave you this hint. HTH, Jim James W. MacDonald Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623>>> Johan Lindberg <johanl at kiev.biotech.kth.se> 01/05/04 06:19AM >>>Thanks for the ideas but I already tested to give the heatmapfunction the argument ylim but I get the following error message: Error in image.default(1:nc, 1:nr, x, xlim = 0.5 + c(0, nc), ylim = 0.5 + : formal argument "ylim" matched by multiple actual arguments So then I tried to adjust the function and changed the ylim argument when the "heatmapfunction" calls "image". But this only makes it possible to zoom in on the "picture" that is drawn in the heatmapfunction. The result is that the function draws the full dendogram on a truncated picure. Any ideas, anyone? / Johan At 13:31 2004-01-04 -0500, you wrote:>Johan - > >Disclaimer: I've never used heatmap(), so probably I shouldn't >be answering this. > >However ... the function heatmap() probably calls either plot() >or image() (regular graphics) or xyplot() (lattice graphics) in >order to set up axes and initialize the actual plotting. heatmap() >may also have a "..." argument which passes additional parameters >through to plot(), unchanged. If both of my guesses are correct >(use help("heatmap") to find out) then I would try calling >heatmap() again with an additional parameter ylim=c(a,b), where >"a" and "b" are two numbers, with a < b, which indicate plotting >coordinates which bracket the group of genes you wish to zoom in on. > >It will take a bit of experimentation to figure out what internal >coordinate system heatmap() uses to do the plotting, but this >seems like a direct way to zoom in on just a part of the plot. > >This is completely untested. I leave it to you to read help("heatmap") >and see whether any of this makes sense. Hope this helps. > >- tom blackwell - u michigan medical school - ann arbor - > >On Sun, 4 Jan 2004, Johan Lindberg wrote: > > > > > I have used heatmap to visualize my microarray data. I have a matrix of > > M-values. I do the following. > > > > #The distance between the columns. > > sampdist <- dist(t(matrix[,]), method="euclidean") > > sclus <- hclust(sampdist, method="average") > > #The distance between the rows. > > genedist <- dist(matrix[,], method="euclidean") > > gclus <- hclust(genedist, method="average") > > heatmap(matrix[,],Rowv=as.dendrogram(gclus),Colv=as.dendrogram(sclus), > col=rbg) > > > > So far so good. But what if I want to look at a group of genes that appear > > to have the same expression pattern in the heatmap? How do I zoom in on a > > dendogram in a heatmap to look at which genes that are forming the > > interesting clusters? I would really appreciate if someone could give me a > > pointer. > > > > Best regards. > > > > / Johan > > > > > > > > > ******************************************************************************************* > > Johan Lindberg > > Royal Institute of Technology > > AlbaNova University Center > > Stockholm Center for Physics, Astronomy and Biotechnology > > Department of Molecular Biotechnology > > 106 91 Stockholm, Sweden > > > > Phone (office): +46 8 553 783 45 > > Fax: + 46 8 553 784 81 > > Visiting adress: Roslagstullsbacken 21, Floor 3 > > Delivery adress: Roslagsv?gen 30B > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >******************************************************************************************* Johan Lindberg Royal Institute of Technology AlbaNova University Center Stockholm Center for Physics, Astronomy and Biotechnology Department of Molecular Biotechnology 106 91 Stockholm, Sweden Phone (office): +46 8 553 783 45 Fax: + 46 8 553 784 81 Visiting adress: Roslagstullsbacken 21, Floor 3 Delivery adress: Roslagsv?gen 30B ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
I don't think Jim has the answer: c(0.5, nc+0.5) and
0.5 + c(0, nc) are identical.
I think the problem is this call within heatmap():
image(1:nc, 1:nr, x, xlim = 0.5 + c(0, nc), ylim = 0.5 +
c(0, nr), axes = FALSE, xlab = "", ylab = "", ...)
So, if you put a `ylim` in your ... argument, the above call has two
ylim arguments.
Edit your own copy of myheatmap <- fix(heatmap); put
xlim = NULL, ylim = NULL in the arguments to
the myheatmap function, change the image call to state
xlim = if (is.null(xlim)) 0.5 + c(0, nc) else xlim,
ylim = if (is.null(ylim)) 0.5 + c(0, nc) else ylim,
and then you can specify a ylim or not, as required.
WARNING: THE ABOVE CODE IS NOT TESTED
Simon
PS it is always good to read `heatmap` as well as `?heatmap`!
> -----Original Message-----
> From: James MacDonald [mailto:jmacdon at med.umich.edu]
> Sent: 05 January 2004 13:35
> To: johanl at kiev.biotech.kth.se; r-help at stat.math.ethz.ch
> Subject: Re: [R] Analyzing dendograms??
>
>
> Security Warning:
> If you are not sure an attachment is safe to open please contact
> Andy on x234. There are 0 attachments with this message.
> ________________________________________________________________
>
> You are using the xlim and ylim arguments incorrectly. You
> should be doing something like xlim=c(0.5, nc+0.5),
> ylim=c(0.5, nc+0.5). The error message gave you this hint.
>
> HTH,
>
> Jim
>
>
>
> James W. MacDonald
> Affymetrix and cDNA Microarray Core
> University of Michigan Cancer Center
> 1500 E. Medical Center Drive
> 7410 CCGC
> Ann Arbor MI 48109
> 734-647-5623
>
> >>> Johan Lindberg <johanl at kiev.biotech.kth.se> 01/05/04
06:19AM >>>
> Thanks for the ideas but I already tested to give the
> heatmapfunction the
> argument ylim but I get the following error message:
>
> Error in image.default(1:nc, 1:nr, x, xlim = 0.5 + c(0, nc),
> ylim = 0.5 + :
> formal argument "ylim" matched by multiple actual
arguments
>
> So then I tried to adjust the function and changed the ylim
> argument when
> the "heatmapfunction" calls "image". But this only
makes it
> possible to
> zoom in on the "picture" that is drawn in the
> heatmapfunction. The result
> is that the function draws the full dendogram on a truncated picure.
>
> Any ideas, anyone?
>
> / Johan
>
>
> At 13:31 2004-01-04 -0500, you wrote:
> >Johan -
> >
> >Disclaimer: I've never used heatmap(), so probably I
shouldn't
> >be answering this.
> >
> >However ... the function heatmap() probably calls either plot()
> >or image() (regular graphics) or xyplot() (lattice graphics) in
> >order to set up axes and initialize the actual plotting. heatmap()
> >may also have a "..." argument which passes additional
parameters
> >through to plot(), unchanged. If both of my guesses are correct
> >(use help("heatmap") to find out) then I would try calling
> >heatmap() again with an additional parameter ylim=c(a,b), where
> >"a" and "b" are two numbers, with a < b, which
indicate plotting
> >coordinates which bracket the group of genes you wish to zoom in on.
> >
> >It will take a bit of experimentation to figure out what internal
> >coordinate system heatmap() uses to do the plotting, but this
> >seems like a direct way to zoom in on just a part of the plot.
> >
> >This is completely untested. I leave it to you to read
> help("heatmap")
> >and see whether any of this makes sense. Hope this helps.
> >
> >- tom blackwell - u michigan medical school - ann arbor -
> >
> >On Sun, 4 Jan 2004, Johan Lindberg wrote:
> >
> > >
> > > I have used heatmap to visualize my microarray data. I
> have a matrix of
> > > M-values. I do the following.
> > >
> > > #The distance between the columns.
> > > sampdist <- dist(t(matrix[,]), method="euclidean")
> > > sclus <- hclust(sampdist, method="average")
> > > #The distance between the rows.
> > > genedist <- dist(matrix[,], method="euclidean")
> > > gclus <- hclust(genedist, method="average")
> > >
> heatmap(matrix[,],Rowv=as.dendrogram(gclus),Colv=as.dendrogram
> (sclus),
> > col=rbg)
> > >
> > > So far so good. But what if I want to look at a group of
> genes that appear
> > > to have the same expression pattern in the heatmap? How
> do I zoom in on a
> > > dendogram in a heatmap to look at which genes that are forming
the
> > > interesting clusters? I would really appreciate if
> someone could give me a
> > > pointer.
> > >
> > > Best regards.
> > >
> > > / Johan
> > >
> > >
> > >
> > >
> >
> **************************************************************
> *****************************
> > > Johan Lindberg
> > > Royal Institute of Technology
> > > AlbaNova University Center
> > > Stockholm Center for Physics, Astronomy and Biotechnology
> > > Department of Molecular Biotechnology
> > > 106 91 Stockholm, Sweden
> > >
> > > Phone (office): +46 8 553 783 45
> > > Fax: + 46 8 553 784 81
> > > Visiting adress: Roslagstullsbacken 21, Floor 3
> > > Delivery adress: Roslagsv?gen 30B
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch mailing list
> > > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > >
>
> **************************************************************
> *****************************
> Johan Lindberg
> Royal Institute of Technology
> AlbaNova University Center
> Stockholm Center for Physics, Astronomy and Biotechnology
> Department of Molecular Biotechnology
> 106 91 Stockholm, Sweden
>
> Phone (office): +46 8 553 783 45
> Fax: + 46 8 553 784 81
> Visiting adress: Roslagstullsbacken 21, Floor 3
> Delivery adress: Roslagsv?gen 30B
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 644449
Fax: +44 (0) 1379 644445
email: Simon.Fear at synequanon.com
web: http://www.synequanon.com
Number of attachments included with this message: 0
This message (and any associated files) is confidential and\...{{dropped}}
Post script: I'm afraid my `solution` was no good, because I forgot the need to change nc and nr. (I got bogged down in passing ylim and lost track of your real question.) Hopefully someone with a deeper understanding of the original problem will come to the rescue. If not there may be milage on restricting your matrix[,] to matrix[<cond1>,<cond2>] according to information in sclus and gclus. But I am in over my depth here.> >On Sun, 4 Jan 2004, Johan Lindberg wrote: > > > > > > > > I have used heatmap to visualize my microarray data. I > have a matrix of > > > M-values. I do the following. > > > > > > #The distance between the columns. > > > sampdist <- dist(t(matrix[,]), method="euclidean") > > > sclus <- hclust(sampdist, method="average") > > > #The distance between the rows. > > > genedist <- dist(matrix[,], method="euclidean") > > > gclus <- hclust(genedist, method="average") > > > > heatmap(matrix[,],Rowv=as.dendrogram(gclus),Colv=as.dendrogram > (sclus), > > col=rbg) > > > > > > So far so good. But what if I want to look at a group of > genes that appear > > > to have the same expression pattern in the heatmap? How > do I zoom in on a > > > dendogram in a heatmap to look at which genes that are forming the > > > interesting clusters? I would really appreciate if > someone could give me a > > > pointer.Simon Fear Senior Statistician Syne qua non Ltd Tel: +44 (0) 1379 644449 Fax: +44 (0) 1379 644445 email: Simon.Fear at synequanon.com web: http://www.synequanon.com Number of attachments included with this message: 0 This message (and any associated files) is confidential and\...{{dropped}}