Search
Question: Adding a text label to the classvec colour bar in heatplot
0
10.2 years ago by
Aedin Culhane510
United States
Aedin Culhane510 wrote:
Dear Amy Do you want to add a group text label on each sample, or just over the colorbar on the side ? The label on each sample is easy to do. Do you want code for this? However currently I haven't implemented a group text label on colorbars in heatplot. I don't think its available in heatmap or heatmap.2. Another function, we have called pretty.dend draws multiple colorbars beneath a clustering dendrogram and these colorbars have group labels. In the development version I used mtext to add the group labels to the side of the color bar and this is prettier than the function in the current release. Unfortunately I haven't implemented group labels adjacent to the colorbar in heatplot as I would have to write code that doesn't call heatmap/heatmap.2. Let me know if you find an alternative work around, or if you need me to modify heatplot. I can send you the development version of pretty.dend so you can see what the output looks like. The output from a modified version of heatplot would look very similar (but has the option of including a heatmap). Regards Aedin (and.. BioC developers... I know I should modify pretty.dend so it doesn't have a . in the function name... sorry, my mistake, its on my to-do list ;-) Dear BioCs, I'm trying to create a heat plot with a matrix containing real time PCR data for just 5 genes. There are 105 samples, belonging to 7 groups (groups are in numerical order). The matrix looks like this (Age is my grouping variable): Gene1 Gene2 Gene3 Gene4 Gene5 Age A1R_D03 -13.71434 -14.19288 -15.79439 -14.93712 -14.87174 3 A4R_D03 -13.29068 -13.39888 -16.49077 -14.87276 -15.21852 3 A7R_D03 -13.19423 -13.09508 -15.80787 -14.59671 -14.47190 3 A10R_D03 -13.33472 -13.34051 -15.60396 -14.69521 -14.28135 3 A13R_D03 -11.89260 -11.73026 -16.05069 -14.59895 -16.40680 3 A61K_D03 -14.64341 -14.55358 -16.37900 -15.44644 -15.80778 3 ...etc As there are so many samples, it doesn't make sense to have the individual sample names on the graph, so I would like to have the samples in their group order with just the seven group labels. With heatplot I can get the colourbar for my seven groups using the classvec argument, but can't find any way to label the colourbars with text... Also, I'm a little confused about the re-ordering that heatplot does - how can I be sure that the samples belonging to a particular group are underneath the appropriate colourbar (and given my situation I would also want the groups to appear in numerical order)? I have tried using heatmap.2 as well, but it seems only heatplot has the colour bar by group option - heatmap.2 only allows you to add a colourbar representing each column separately? Here is my code: #(Ngenet is a transposition of my matrix and the Age variable is in a separate dataframe so that it doesn't appear directly on the plot). > >heatplot(Ngenet, dend="none", cols.default=FALSE, margin=c(7, 7), labCol=FALSE, lowcol="red", highcol="green", scale="none", classvec=Mop$Age) > If anyone could suggest how I might add the group labels, I'd be very grateful - appologies if this is something very simple, I have actually seen papers with plots showing exactly what I want to do but just can't figure out how to do it. With best wishes, Amy -- Aed?n Culhane, Research Associate Computational Biology and Functional Genomics Laboratory Harvard School of Public Health, Dana-Farber Cancer Institute 44 Binney Street, SM822C Department of Biostatistics and Computational Biology, Dana-Farber Cancer Institute Boston, MA 02115 USA Phone: +1 (617) 632 2468 Fax: +1 (617) 582 7760 Email: aedin at jimmy.harvard.edu Web URL: http://www.hsph.harvard.edu/researchers/aculhane.html ADD COMMENTlink modified 10.2 years ago by Amy Mikhail460 • written 10.2 years ago by Aedin Culhane510 0 10.2 years ago by Amy Mikhail460 Amy Mikhail460 wrote: Hi Aedin, What I'd like to do is add group text labels over the colourbar on the top (the rows in my heatplot are genes, the columns are samples). If you look at figures 2 or 3 in the paper below which is co-authored by Robert Gentleman you can see an example of what I mean - the "Relapse" "CCR" labels on the 3rd figure are the type of thing I'm after. This paper was written a while ago (2003) so not sure if the figures were made with heatplot or something else, but I'd be interested to know how it was done? http://bloodjournal.hematologylibrary.org/cgi/content/abstract/103/7/2 771 The dendrogram group labels are not quite what I'm after but it would be interesting to see anyway. I think it would be useful if heatplot had a straight-forward option to add group labels in this way. Best wishes, Amy -----Original Message----- From: Aedin Culhane [mailto:aedin@jimmy.harvard.edu] Sent: 25 July 2008 00:02 To: bioconductor at stat.math.ethz.ch; Mikhail, Amy Subject: Re: Adding a text label to the classvec colour bar in heatplot Dear Amy Do you want to add a group text label on each sample, or just over the colorbar on the side ? The label on each sample is easy to do. Do you want code for this? However currently I haven't implemented a group text label on colorbars in heatplot. I don't think its available in heatmap or heatmap.2. Another function, we have called pretty.dend draws multiple colorbars beneath a clustering dendrogram and these colorbars have group labels. In the development version I used mtext to add the group labels to the side of the color bar and this is prettier than the function in the current release. Unfortunately I haven't implemented group labels adjacent to the colorbar in heatplot as I would have to write code that doesn't call heatmap/heatmap.2. Let me know if you find an alternative work around, or if you need me to modify heatplot. I can send you the development version of pretty.dend so you can see what the output looks like. The output from a modified version of heatplot would look very similar (but has the option of including a heatmap). Regards Aedin (and.. BioC developers... I know I should modify pretty.dend so it doesn't have a . in the function name... sorry, my mistake, its on my to-do list ;-) Dear BioCs, I'm trying to create a heat plot with a matrix containing real time PCR data for just 5 genes. There are 105 samples, belonging to 7 groups (groups are in numerical order). The matrix looks like this (Age is my grouping variable): Gene1 Gene2 Gene3 Gene4 Gene5 Age A1R_D03 -13.71434 -14.19288 -15.79439 -14.93712 -14.87174 3 A4R_D03 -13.29068 -13.39888 -16.49077 -14.87276 -15.21852 3 A7R_D03 -13.19423 -13.09508 -15.80787 -14.59671 -14.47190 3 A10R_D03 -13.33472 -13.34051 -15.60396 -14.69521 -14.28135 3 A13R_D03 -11.89260 -11.73026 -16.05069 -14.59895 -16.40680 3 A61K_D03 -14.64341 -14.55358 -16.37900 -15.44644 -15.80778 3 ...etc As there are so many samples, it doesn't make sense to have the individual sample names on the graph, so I would like to have the samples in their group order with just the seven group labels. With heatplot I can get the colourbar for my seven groups using the classvec argument, but can't find any way to label the colourbars with text... Also, I'm a little confused about the re-ordering that heatplot does - how can I be sure that the samples belonging to a particular group are underneath the appropriate colourbar (and given my situation I would also want the groups to appear in numerical order)? I have tried using heatmap.2 as well, but it seems only heatplot has the colour bar by group option - heatmap.2 only allows you to add a colourbar representing each column separately? Here is my code: #(Ngenet is a transposition of my matrix and the Age variable is in a separate dataframe so that it doesn't appear directly on the plot). > >heatplot(Ngenet, dend="none", cols.default=FALSE, margin=c(7, 7), > >labCol=FALSE, lowcol="red", highcol="green", scale="none", > >classvec=Mop$Age) > If anyone could suggest how I might add the group labels, I'd be very grateful - appologies if this is something very simple, I have actually seen papers with plots showing exactly what I want to do but just can't figure out how to do it. With best wishes, Amy -- Aed?n Culhane, Research Associate Computational Biology and Functional Genomics Laboratory Harvard School of Public Health, Dana-Farber Cancer Institute 44 Binney Street, SM822C Department of Biostatistics and Computational Biology, Dana-Farber Cancer Institute Boston, MA 02115 USA Phone: +1 (617) 632 2468 Fax: +1 (617) 582 7760 Email: aedin at jimmy.harvard.edu Web URL: http://www.hsph.harvard.edu/researchers/aculhane.html The University of Aberdeen is a charity registered in Scotland, No SC013683.
What I find often very helpful for the final refinements of a heatmaps or any other graphics generated in R is the possibility to save the plots in SVG format (Scalable Vector Graphics). This format allows you to edit all features in an R plot with graphics editors that have SVG support. A very nice and free one is InkScape: http://www.inkscape.org/. Adobe Illustrator should work too. After the import of the SVG file into InkScape you ungroup the graphics object to make all the changes final refinements you want. The SVG format is supported by many web browsers and it is becoming more and more the default graphics format for community web projects like Wikipedia. Here is a short example: library("RSvgDevice") # install package from CRAN devSVG("test.svg") plot(1:10, 1:10) dev.off() Thomas On Fri, Jul 25, 2008 at 01:06:28PM +0100, Mikhail, Amy wrote: > Hi Aedin, > > What I'd like to do is add group text labels over the colourbar on the top (the rows in my heatplot are genes, the columns are samples). If you look at figures 2 or 3 in the paper below which is co-authored by Robert Gentleman you can see an example of what I mean - the "Relapse" "CCR" labels on the 3rd figure are the type of thing I'm after. This paper was written a while ago (2003) so not sure if the figures were made with heatplot or something else, but I'd be interested to know how it was done? > > http://bloodjournal.hematologylibrary.org/cgi/content/abstract/103/7 /2771 > > The dendrogram group labels are not quite what I'm after but it would be interesting to see anyway. I think it would be useful if heatplot had a straight-forward option to add group labels in this way. > > Best wishes, > Amy > > -----Original Message----- > From: Aedin Culhane [mailto:aedin at jimmy.harvard.edu] > Sent: 25 July 2008 00:02 > To: bioconductor at stat.math.ethz.ch; Mikhail, Amy > Subject: Re: Adding a text label to the classvec colour bar in heatplot > > Dear Amy > Do you want to add a group text label on each sample, or just over the colorbar on the side ? The label on each sample is easy to do. Do you want code for this? > > However currently I haven't implemented a group text label on colorbars in heatplot. I don't think its available in heatmap or heatmap.2. > > Another function, we have called pretty.dend draws multiple colorbars beneath a clustering dendrogram and these colorbars have group labels. > In the development version I used mtext to add the group labels to the side of the color bar and this is prettier than the function in the current release. > > Unfortunately I haven't implemented group labels adjacent to the colorbar in heatplot as I would have to write code that doesn't call heatmap/heatmap.2. > > Let me know if you find an alternative work around, or if you need me to modify heatplot. > > I can send you the development version of pretty.dend so you can see what the output looks like. The output from a modified version of heatplot would look very similar (but has the option of including a heatmap). > > Regards > Aedin > > (and.. BioC developers... I know I should modify pretty.dend so it doesn't have a . in the function name... sorry, my mistake, its on my to-do list ;-) > > > > Dear BioCs, > > I'm trying to create a heat plot with a matrix containing real time PCR data for just 5 genes. There are 105 samples, belonging to 7 groups (groups are in numerical order). The matrix looks like this (Age is my grouping variable): > > Gene1 Gene2 Gene3 Gene4 Gene5 Age > A1R_D03 -13.71434 -14.19288 -15.79439 -14.93712 -14.87174 3 > A4R_D03 -13.29068 -13.39888 -16.49077 -14.87276 -15.21852 3 > A7R_D03 -13.19423 -13.09508 -15.80787 -14.59671 -14.47190 3 > A10R_D03 -13.33472 -13.34051 -15.60396 -14.69521 -14.28135 3 > A13R_D03 -11.89260 -11.73026 -16.05069 -14.59895 -16.40680 3 > A61K_D03 -14.64341 -14.55358 -16.37900 -15.44644 -15.80778 3 > > ...etc > > As there are so many samples, it doesn't make sense to have the individual sample names on the graph, so I would like to have the samples in their group order with just the seven group labels. With heatplot I can get the colourbar for my seven groups using the classvec argument, but can't find any way to label the colourbars with text... > > Also, I'm a little confused about the re-ordering that heatplot does - how can I be sure that the samples belonging to a particular group are underneath the appropriate colourbar (and given my situation I would also want the groups to appear in numerical order)? > > I have tried using heatmap.2 as well, but it seems only heatplot has the colour bar by group option - heatmap.2 only allows you to add a colourbar representing each column separately? > > Here is my code: > > #(Ngenet is a transposition of my matrix and the Age variable is in a separate dataframe so that it doesn't appear directly on the plot). > > > > >heatplot(Ngenet, dend="none", cols.default=FALSE, margin=c(7, 7), > > >labCol=FALSE, lowcol="red", highcol="green", scale="none", > > >classvec=Mop$Age) > > > > If anyone could suggest how I might add the group labels, I'd be very grateful - appologies if this is something very simple, I have actually seen papers with plots showing exactly what I want to do but just can't figure out how to do it. > > With best wishes, > Amy > > > > > -- > Aed?n Culhane, > Research Associate > Computational Biology and Functional Genomics Laboratory Harvard School of Public Health, Dana-Farber Cancer Institute > > 44 Binney Street, SM822C > Department of Biostatistics and Computational Biology, Dana-Farber Cancer Institute Boston, MA 02115 USA > > Phone: +1 (617) 632 2468 > Fax: +1 (617) 582 7760 > Email: aedin at jimmy.harvard.edu > Web URL: http://www.hsph.harvard.edu/researchers/aculhane.html > > > > > The University of Aberdeen is a charity registered in Scotland, No SC013683. > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Thomas Girke Assistant Professor of Bioinformatics Director, IIGB Bioinformatic Facility Center for Plant Cell Biology (CEPCEB) Institute for Integrative Genome Biology (IIGB) Department of Botany and Plant Sciences 1008 Noel T. Keen Hall University of California Riverside, CA 92521 E-mail: thomas.girke at ucr.edu Website: http://faculty.ucr.edu/~tgirke Ph: 951-827-2469 Fax: 951-827-4437 ADD REPLYlink written 10.2 years ago by Thomas Girke1.6k You will be glad to know that as of 2.7 R supports a SVG device out of the box (if compiled with Cairo support). Kasper On Jul 25, 2008, at 8:38 AM, Thomas Girke wrote: > What I find often very helpful for the final refinements of a > heatmaps or > any other graphics generated in R is the possibility to save the plots > in SVG format (Scalable Vector Graphics). This format allows you to > edit all features in an R plot with graphics editors that have SVG > support. > A very nice and free one is InkScape: http://www.inkscape.org/. Adobe > Illustrator should work too. After the import of the SVG file into > InkScape you ungroup the graphics object to make all the changes final > refinements you want. The SVG format is supported by many web > browsers and > it is becoming more and more the default graphics format for community > web projects like Wikipedia. > > Here is a short example: > > library("RSvgDevice") # install package from CRAN > devSVG("test.svg") > plot(1:10, 1:10) > dev.off() > > Thomas > > > On Fri, Jul 25, 2008 at 01:06:28PM +0100, Mikhail, Amy wrote: >> Hi Aedin, >> >> What I'd like to do is add group text labels over the colourbar on >> the top (the rows in my heatplot are genes, the columns are >> samples). If you look at figures 2 or 3 in the paper below which >> is co-authored by Robert Gentleman you can see an example of what I >> mean - the "Relapse" "CCR" labels on the 3rd figure are the type of >> thing I'm after. This paper was written a while ago (2003) so not >> sure if the figures were made with heatplot or something else, but >> I'd be interested to know how it was done? >> >> http://bloodjournal.hematologylibrary.org/cgi/content/abstract/103/ 7/2771 >> >> The dendrogram group labels are not quite what I'm after but it >> would be interesting to see anyway. I think it would be useful if >> heatplot had a straight-forward option to add group labels in this >> way. >> >> Best wishes, >> Amy >> >> -----Original Message----- >> From: Aedin Culhane [mailto:aedin at jimmy.harvard.edu] >> Sent: 25 July 2008 00:02 >> To: bioconductor at stat.math.ethz.ch; Mikhail, Amy >> Subject: Re: Adding a text label to the classvec colour bar in >> heatplot >> >> Dear Amy >> Do you want to add a group text label on each sample, or just over >> the colorbar on the side ? The label on each sample is easy to >> do. Do you want code for this? >> >> However currently I haven't implemented a group text label on >> colorbars in heatplot. I don't think its available in heatmap or >> heatmap.2. >> >> Another function, we have called pretty.dend draws multiple >> colorbars beneath a clustering dendrogram and these colorbars have >> group labels. >> In the development version I used mtext to add the group labels to >> the side of the color bar and this is prettier than the function >> in the current release. >> >> Unfortunately I haven't implemented group labels adjacent to the >> colorbar in heatplot as I would have to write code that doesn't >> call heatmap/heatmap.2. >> >> Let me know if you find an alternative work around, or if you need >> me to modify heatplot. >> >> I can send you the development version of pretty.dend so you can >> see what the output looks like. The output from a modified version >> of heatplot would look very similar (but has the option of >> including a heatmap). >> >> Regards >> Aedin >> >> (and.. BioC developers... I know I should modify pretty.dend so it >> doesn't have a . in the function name... sorry, my mistake, its on >> my to-do list ;-) >> >> >> >> Dear BioCs, >> >> I'm trying to create a heat plot with a matrix containing real time >> PCR data for just 5 genes. There are 105 samples, belonging to 7 >> groups (groups are in numerical order). The matrix looks like this >> (Age is my grouping variable): >> >> Gene1 Gene2 Gene3 Gene4 >> Gene5 Age >> A1R_D03 -13.71434 -14.19288 -15.79439 -14.93712 -14.87174 3 >> A4R_D03 -13.29068 -13.39888 -16.49077 -14.87276 -15.21852 3 >> A7R_D03 -13.19423 -13.09508 -15.80787 -14.59671 -14.47190 3 >> A10R_D03 -13.33472 -13.34051 -15.60396 -14.69521 -14.28135 3 >> A13R_D03 -11.89260 -11.73026 -16.05069 -14.59895 -16.40680 3 >> A61K_D03 -14.64341 -14.55358 -16.37900 -15.44644 -15.80778 3 >> >> ...etc >> >> As there are so many samples, it doesn't make sense to have the >> individual sample names on the graph, so I would like to have the >> samples in their group order with just the seven group labels. >> With heatplot I can get the colourbar for my seven groups using the >> classvec argument, but can't find any way to label the colourbars >> with text... >> >> Also, I'm a little confused about the re-ordering that heatplot >> does - how can I be sure that the samples belonging to a particular >> group are underneath the appropriate colourbar (and given my >> situation I would also want the groups to appear in numerical order)? >> >> I have tried using heatmap.2 as well, but it seems only heatplot >> has the colour bar by group option - heatmap.2 only allows you to >> add a colourbar representing each column separately? >> >> Here is my code: >> >> #(Ngenet is a transposition of my matrix and the Age variable is in >> a separate dataframe so that it doesn't appear directly on the plot). >> >> >>>> heatplot(Ngenet, dend="none", cols.default=FALSE, margin=c(7, 7), >>>> labCol=FALSE, lowcol="red", highcol="green", scale="none", >>>> classvec=Mop$Age) >>> >> >> If anyone could suggest how I might add the group labels, I'd be >> very grateful - appologies if this is something very simple, I have >> actually seen papers with plots showing exactly what I want to do >> but just can't figure out how to do it. >> >> With best wishes, >> Amy >> >> >> >> >> -- >> Aed?n Culhane, >> Research Associate >> Computational Biology and Functional Genomics Laboratory Harvard >> School of Public Health, Dana-Farber Cancer Institute >> >> 44 Binney Street, SM822C >> Department of Biostatistics and Computational Biology, Dana-Farber >> Cancer Institute Boston, MA 02115 USA >> >> Phone: +1 (617) 632 2468 >> Fax: +1 (617) 582 7760 >> Email: aedin at jimmy.harvard.edu >> Web URL: http://www.hsph.harvard.edu/researchers/aculhane.html >> >> >> >> >> The University of Aberdeen is a charity registered in Scotland, No >> SC013683. >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor at stat.math.ethz.ch >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >> > > -- > Thomas Girke > Assistant Professor of Bioinformatics > Director, IIGB Bioinformatic Facility > Center for Plant Cell Biology (CEPCEB) > Institute for Integrative Genome Biology (IIGB) > Department of Botany and Plant Sciences > 1008 Noel T. Keen Hall > University of California > Riverside, CA 92521 > > E-mail: thomas.girke at ucr.edu > Website: http://faculty.ucr.edu/~tgirke > Ph: 951-827-2469 > Fax: 951-827-4437 > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor