Question: Row labels in a heatmap
0
6.9 years ago by
Liat Shavit Grievink60 wrote:
Hi all, I'm trying to draw a heatmap for some microarray data. Since I have many genes, the gene names (row labels) are not readable. I would like to replace these gene names by seq(0,500,by=100). Any ideas on how to do that? I tried both heatmap and heatmap.2, but couldn't find a good way to do this. Many thanks! Liat. [[alternative HTML version deleted]]
microarray • 20k views
modified 6.9 years ago by James W. MacDonald50k • written 6.9 years ago by Liat Shavit Grievink60
Answer: Row labels in a heatmap
2
6.9 years ago by
United States
James W. MacDonald50k wrote:
Hi Liat, On 7/16/2012 9:12 AM, Liat S wrote: > Hi all, > I'm trying to draw a heatmap for some microarray data. > Since I have many genes, the gene names (row labels) are not readable. > I would like to replace these gene names by seq(0,500,by=100). I don't think you want to use that. Unless you only have 6 genes. ;-D Anyway, heatmap() and heatmap.2() just use the row.names of the matrix you input. So just change them. row.names(yourmatrix) <- seq(1, nrow(yourmatrix),1) You might also consider plotting the heatmap in such a way that you can read the row labels. As a pdf, you can play around with the width and height until you get what you want. Something like pdf("the.pdf", width = 20, height = 500) heatmap.2(yourmatrix, <otherargs>, lhei = c(0.05, 0.95)) dev.off() You want the lhei set so the proportions of the heatmap look reasonable. Best, Jim > Any ideas on how to do that? > I tried both heatmap and heatmap.2, but couldn't find a good way to do this. > Many thanks! > Liat. > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099
Hi James, Thank you! The thing is that I rather not have numbers 1 to 500, but for example: 1, 100, 200, 300,400, 500. or something like this (so show a label only every 100 genes). Thanks again, Liat. On 16.07.2012, at 16:24, James W. MacDonald wrote: > row.names(yourmatrix) <- seq(1, nrow(yourmatrix),1) [[alternative HTML version deleted]]
OK, so just set it to be so. nam <- rep("", nrow(yourmatrix)) nam[seq(1,nrow(yourmatrix), 100)] <- seq(1, nrow(yourmatrix), 100) row.names(yourmatrix) <- nam Best, Jim On 7/16/2012 9:42 AM, Liat Shavit Grievink wrote: > Hi James, > Thank you! > The thing is that I rather not have numbers 1 to 500, but for example: > 1, 100, 200, 300,400, 500. or something like this (so show a label > only every 100 genes). > Thanks again, > Liat. > On 16.07.2012, at 16:24, James W. MacDonald wrote: > >> row.names(yourmatrix) <- seq(1, nrow(yourmatrix),1) > -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099
Hi Liat, I think you have to first run heatmap once, get the order of rows in the graph and feed the corresponding rows with the right name and leave others empty, in order to keep a regular interval between names. # example from ? heatmap x <- as.matrix(mtcars) rc <- rainbow(nrow(x), start=0, end=.3) cc <- rainbow(ncol(x), start=0, end=.3) hv <- heatmap(x, col = cm.colors(256), scale="column", RowSideColors = rc, ColSideColors = cc, margins=c(5,10), xlab = "specification variables", ylab= "Car Models", main = "heatmap(<mtcars data="">, ..., scale = \"column\")") # create a new name vector for the plot nn<-rep('', nrow(x)) nn[hv$rowInd[seq(1,nrow(x), 10)]]<-rownames(x)[hv$rowInd[seq(1,nrow(x), 10)]] # plot again with the desired row names 'labRow' heatmap(x, col = cm.colors(256), scale="column",labRow=nn, RowSideColors = rc, ColSideColors = cc, margins=c(5,10), xlab = "specification variables", ylab= "Car Models", main = "heatmap(<mtcars data="">, ..., scale = \"column\")") Hth, Dan On Mon, 2012-07-16 at 16:42 +0300, Liat Shavit Grievink wrote: > Hi James, > Thank you! > The thing is that I rather not have numbers 1 to 500, but for example: > 1, 100, 200, 300,400, 500. or something like this (so show a label > only every 100 genes). > Thanks again, > Liat. > On 16.07.2012, at 16:24, James W. MacDonald wrote: > > > row.names(yourmatrix) <- seq(1, nrow(yourmatrix),1) > > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor