Hey Alex,
It is quite easy to do within R, and not to have to go through the laborious route of exporting your data to Excel and then importing it to some silly online heatmap tool.
You should research how to perform data-frame subsetting in R. Your data is probably an ExpressionSet object, but it is still easy.
Here is a completely reproducible example:
1, Download some already-normalised sample data
library(Biobase)
library(GEOquery)
gset <- getGEO("GSE1460", GSEMatrix =TRUE, getGPL=FALSE)[[1]]
class(gset)
[1] "ExpressionSet"
attr(,"package")
[1] "Biobase"
gset
ExpressionSet (storageMode: lockedEnvironment)
assayData: 22283 features, 15 samples
element names: exprs
protocolData: none
phenoData
sampleNames: GSM24511 GSM24609 ... GSM24622 (15 total)
varLabels: title geo_accession ... data_row_count (32 total)
varMetadata: labelDescription
featureData: none
experimentData: use 'experimentData(object)'
pubMedIds: 15210650
Annotation: GPL96
2, randomly select 50 probes and pretend that they are the statistically significant ones
sigprobes <- sample(rownames(gset), 50)
With limma output from topTable()
, you can filter your object easily like this (where results_table contains the output of topTable()
):
results_table_filt <- subset(results_table, abs(logFC) > 2 & adj.P.Val <= 0.05)
...then just take the rownames of results_table_filt
(or the first column, whichever has the names), and then use these to subset your expression matrix as I do in part 4 (below). Using this subset()
command, I am filtering based on absolute log (base 2) fold-change > 2, and adjusted p-value <= 0.05.
3, transform our expression data by scaling row-wise
heat <- t(scale(t(exprs(gset))))
4, subset our data with the statistically significant probes
heat <- heat[sigprobes,]
This works here because the rownames of heat are probe names
5, generate simple heatmap
heatmap(heat)
Please look up other heatmap functions, such as pheatmap()
, heatmap.2()
, and Heatmap()
(from ComplexHeatmap). There are many tutorials and posts on the Web, including on Biostars.
Kevin
Thank you very much, Kevin! I will give this a go!