labeling a hclust tree with custom labels
3
0
Entering edit mode
@iain-gallagher-2532
Last seen 9.3 years ago
United Kingdom
An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/bioconductor/attachments/20080328/ 4b67901d/attachment.pl
• 2.6k views
ADD COMMENT
0
Entering edit mode
@sean-davis-490
Last seen 3 months ago
United States
On Fri, Mar 28, 2008 at 10:26 AM, IAIN GALLAGHER <iaingallagher at="" btopenworld.com=""> wrote: > Hi All. > > I am clustering affymetrix expression data using hclust. I would like to label the tree with the sample name and group from which the sample comes from. I can generate a vector of labels from my phenoData slot > > eg > > graph_labels <- paste(pData(rma_data)$group, pData(rma_data)$label, sep=' : ') > > but I can't get them to sit on the right branches using > > plot (clust, labels = graph_labels). > > I suspect this has to do with the labeling in the dist object. > > I was wondering if there was a way to change the labels in the dist object to reflect my preferred labeling or a way to quickly re-order my preferred labeling vector to match that of the dist object. > Hi, Iain. What you are showing looks to be the correct way to go about things. The labels will be reordered as necessary, I believe. However, since we cannot see how you created the "clust" object, it is impossible to tell where the problem might be. Only after you post all the relevant code can anyone really help you. Also, it is a really good idea to post the output of sessionInfo() for every question to the list. Even if it isn't important, no one will ever fault you for doing so. Sean
ADD COMMENT
0
Entering edit mode
Amy Mikhail ▴ 460
@amy-mikhail-1317
Last seen 10.2 years ago
Hi Iain, I'm guessing that the labels currently coming up on hclust are the names of your .cel files? If your expressionset is called my.expressionset, and your desired sample names for images are "Control 1" etc, you could just do: sampleNames(my.expressionset) <- c("Control 1", "Control 2", "Control 3", "Treatment 1", "Treatment 2", "Treatment 3") Nb1. You would have to follow the same order for the new sample names as the order of columns in your expressionset. If you have a lot of files and already have a vector of your preferred sample names (in the right order) you could just put that in instead of the list above and it would be even faster ;-) Nb2. Anything else you do after this code will now show your preferred sample labels instead of the .cel file names. Hope that helps, Best wishes, Amy ---------------------------------------------------------------------- -- --------------------------------------- On Fri, Mar 28, 2008 at 10:26 AM, IAIN GALLAGHER <iaingallagher at="" btopenworld.com=""> wrote: > Hi All. > > I am clustering affymetrix expression data using hclust. I would like to label the tree with the sample name and group from which the sample comes from. I can generate a vector of labels from my phenoData slot > > eg > > graph_labels <- paste(pData(rma_data)$group, pData(rma_data)$label, sep=' : ') > > but I can't get them to sit on the right branches using > > plot (clust, labels = graph_labels). > > I suspect this has to do with the labeling in the dist object. > > I was wondering if there was a way to change the labels in the dist object to reflect my preferred labeling or a way to quickly re-order my preferred labeling vector to match that of the dist object. > Hi, Iain. What you are showing looks to be the correct way to go about things. The labels will be reordered as necessary, I believe. However, since we cannot see how you created the "clust" object, it is impossible to tell where the problem might be. Only after you post all the relevant code can anyone really help you. Also, it is a really good idea to post the output of sessionInfo() for every question to the list. Even if it isn't important, no one will ever fault you for doing so. Sean The University of Aberdeen is a charity registered in Scotland, No SC013683.
ADD COMMENT
0
Entering edit mode
Amy Mikhail ▴ 460
@amy-mikhail-1317
Last seen 10.2 years ago
P.s. - forgot to mention that the below should be done before you create your dist object - then the new sample names will automatically appear in the right place on the hclust dendrogram. Also, appologies - I have always just typed my new sample names but just tried using a vector of names instead and can't get this to work (the argument expects strings). I am sure there should be an easy way to do this though... Best wishes, Amy -----Original Message----- From: Mikhail, Amy Sent: 29 March 2008 12:40 To: bioconductor at stat.math.ethz.ch Cc: 'iaingallagher at btopenworld.com'; 'sdavis2 at mail.nih.gov' Subject: Re: [BioC] labeling a hclust tree with custom labels Hi Iain, I'm guessing that the labels currently coming up on hclust are the names of your .cel files? If your expressionset is called my.expressionset, and your desired sample names for images are "Control 1" etc, you could just do: sampleNames(my.expressionset) <- c("Control 1", "Control 2", "Control 3", "Treatment 1", "Treatment 2", "Treatment 3") Nb1. You would have to follow the same order for the new sample names as the order of columns in your expressionset. If you have a lot of files and already have a vector of your preferred sample names (in the right order) you could just put that in instead of the list above and it would be even faster ;-) Nb2. Anything else you do after this code will now show your preferred sample labels instead of the .cel file names. Hope that helps, Best wishes, Amy ---------------------------------------------------------------------- -- --------------------------------------- On Fri, Mar 28, 2008 at 10:26 AM, IAIN GALLAGHER <iaingallagher at="" btopenworld.com=""> wrote: > Hi All. > > I am clustering affymetrix expression data using hclust. I would like > to label the tree with the sample name and group from which the sample > comes from. I can generate a vector of labels from my phenoData slot > > eg > > graph_labels <- paste(pData(rma_data)$group, pData(rma_data)$label, > sep=' : ') > > but I can't get them to sit on the right branches using > > plot (clust, labels = graph_labels). > > I suspect this has to do with the labeling in the dist object. > > I was wondering if there was a way to change the labels in the dist object to reflect my preferred labeling or a way to quickly re-order my preferred labeling vector to match that of the dist object. > Hi, Iain. What you are showing looks to be the correct way to go about things. The labels will be reordered as necessary, I believe. However, since we cannot see how you created the "clust" object, it is impossible to tell where the problem might be. Only after you post all the relevant code can anyone really help you. Also, it is a really good idea to post the output of sessionInfo() for every question to the list. Even if it isn't important, no one will ever fault you for doing so. Sean The University of Aberdeen is a charity registered in Scotland, No SC013683.
ADD COMMENT

Login before adding your answer.

Traffic: 768 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6