I’m trying to produce a heatmap of some gene expression data. Currently, the data I’d like to visualize is stored in an expression set data type, but the samples are not grouped correctly; that is, control samples and experimental samples are not grouped together. Here’s an abbreviated work flow:
output <- //analysis of raw data eset
someGenes <- eset [output$Table1, ]
heatmap(exprs(someGenes))
Essentially, I’d like to rearrange the samples in the eset before plotting. I’ve tried to treat the sample names as “columns” but haven’t been able to alter their position within the eset. I’m quite new to R, so any and all help would be greatly appreciated.
Here’s a link to the expression set data type for reference: http://rss.acs.unt.edu/Rdoc/library/Biobase/html/class.ExpressionSet.html
Many thanks.
For a reproducible example, we load Biobase and the sample data
then take a look at what we’ve got:
We can subset an ExpressionSet like a matrix, so for instance using indices or
sampleNames, e.g., by creating a column indexcidxfrom a shuffle of the current sampleNamescidx is just a character vector. And then we re-order the columns with
So you’ve re-ordered the columns before plotting. But heatmap is, by default, going to cluster the samples based on their ‘distance’ between one another. So it doesn’t matter that you’ve re-ordered the samples, heatmap will figure out the same distances, and plot the same heatmap. You might want
image, or to provide the argumentColv(see?heatmap) or use heatmap.2 in the gplots package, or… Hope that helps.