How to make a (limma) heatmap displaying gene ID's as rownames
3
1
Entering edit mode
mat149 ▴ 80
@mat149-11450
Last seen 24 days ago
United States

Hello,

I am generating a series of heatmaps using the MArrayLM eBayes object from a limma linear model analysis of microarray data.  I have the heatmap generated but I would like to put gene symbols in place of the probeID (row).  Can anyone describe a way to do this? Thanks for looking into this, the code I am using for this process is attached below.

- Matt

 

ph = CELdat@phenoData 
ph@data[ ,1] = c("WT1","WT2","WT3","WT4","WT5","WT6","WT7","WT8","MO1","MO2","MO3","MO4","RS1","RS2","RS3","RS4")
ph@data[ ,2] = c("control","control","control","control","control","control","control","control","morphant","morphant","morphant","morphant","rescue","rescue","rescue","rescue")
colnames(ph@data)[2]="Treatment"
colnames(ph@data)[1]="Sample"
groups = ph@data$Treatment
f = factor(groups,levels=c("control","morphant","rescue"))

eset<-rma(CELdat, background=TRUE, normalize=TRUE, subset=NULL, target="core")     
library(affycoretools)
eset <- annotateEset(eset, annotation(eset))
library(org.Dr.eg.db)
fd <- fData(eset)
fd$ENTREZID <- mapIds(org.Dr.eg.db, as.character(fd$SYMBOL), "ENTREZID","SYMBOL",multiVals="first")
fData(eset) <- fd

library(limma)
design = model.matrix(~ 0 + f)
colnames(design)=c("control","morphant","rescue")
design
data.fit = lmFit(eset,design)
contrast.matrix = makeContrasts(morphant-control,rescue-control,morphant-rescue,levels=design)
data.fit.con = contrasts.fit(data.fit,contrast.matrix)
data.fit.eb = eBayes(data.fit.con)
results <- decideTests(data.fit.eb,p.value=0.01,adjust="BH",lfc=1.5)

 

library(gplots)
y<-exprs(eset)
tab2 <- topTable(data.fit.eb, coef=2, adjust="BH",sort.by="P",p.value=0.01,lfc=1.5, n=Inf)
tab1 <- topTable(data.fit.eb, coef=1, adjust="BH",sort.by="P",p.value=0.01,lfc=1.5, n=Inf)
heatmap.2(y[rownames(tab1),], main="Leptin-A Morphant", ylab="Probeset ID", xlab="Microarray Sample",col=greenred(75),cexRow=0.5,scale="none",key=TRUE, symkey=FALSE, density.info="none", trace="none")
heatmap.2(y[rownames(tab2),], main="Leptin-A Rescue", ylab="Probeset ID", xlab="Microarray Sample",col=greenred(75),cexRow=0.5,scale="none",key=TRUE, symkey=FALSE, density.info="none", trace="none")

 

 

R version 3.3.1 (2016-06-21)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] limma_3.28.21            org.Dr.eg.db_3.3.0       AnnotationDbi_1.34.4    
 [4] affycoretools_1.44.3     pd.zebgene.1.1.st_3.12.0 RSQLite_1.0.0           
 [7] DBI_0.5-1                oligo_1.36.1             Biostrings_2.40.2       
[10] XVector_0.12.1           IRanges_2.6.1            S4Vectors_0.10.3        
[13] Biobase_2.32.0           oligoClasses_1.34.0      BiocGenerics_0.18.0     

loaded via a namespace (and not attached):
  [1] httr_1.2.1                    munsell_0.4.3                
  [3] latticeExtra_0.6-28           BSgenome_1.40.1              
  [5] dichromat_2.0-0               R.utils_2.5.0                
  [7] lazyeval_0.2.0                tibble_1.2                   
  [9] PFAM.db_3.3.0                 httpuv_1.3.3                 
 [11] R6_2.2.0                      ensembldb_1.4.7              
 [13] graph_1.50.0                  affxparser_1.44.0            
 [15] BiocInstaller_1.22.3          data.table_1.9.6             
 [17] reshape_0.8.6                 annotate_1.50.1              
 [19] xtable_1.8-2                  gdata_2.17.0                 
 [21] tools_3.3.1                   stringr_1.1.0                
 [23] rtracklayer_1.32.2            mime_0.5                     
 [25] GSEABase_1.34.1               shiny_0.14.2                 
 [27] chron_2.3-47                  R.oo_1.21.0                  
 [29] GOstats_2.38.1                foreach_1.4.3                
 [31] digest_0.6.10                 KernSmooth_2.23-15           
 [33] GO.db_3.3.0                   GenomeInfoDb_1.8.7           
 [35] codetools_0.2-15              GGally_1.3.0                 
 [37] ff_2.2-13                     GenomicAlignments_1.8.4      
 [39] gplots_3.0.1                  genefilter_1.54.2            
 [41] scales_0.4.1                  stringi_1.1.2                
 [43] locfit_1.5-9.1                R.methodsS3_1.7.1            
 [45] assertthat_0.1                gcrma_2.44.0                 
 [47] lattice_0.20-34               AnnotationForge_1.14.2       
 [49] interactiveDisplayBase_1.10.3 biovizBase_1.20.0            
 [51] Rcpp_0.12.8                   OrganismDbi_1.14.1           
 [53] caTools_1.17.1                Hmisc_4.0-0                  
 [55] Formula_1.2-1                 ggplot2_2.2.0                
 [57] htmlTable_1.7                 Category_2.38.0              
 [59] grid_3.3.1                    ReportingTools_2.12.2        
 [61] GenomicRanges_1.24.3          preprocessCore_1.34.0        
 [63] plyr_1.8.4                    RBGL_1.48.1                  
 [65] survival_2.40-1               edgeR_3.14.0                 
 [67] acepack_1.4.1                 affy_1.50.0                  
 [69] rpart_4.1-10                  magrittr_1.5                 
 [71] SummarizedExperiment_1.2.3    VariantAnnotation_1.18.7     
 [73] gridExtra_2.2.1               affyio_1.42.0                
 [75] biomaRt_2.28.0                htmltools_0.3.5              
 [77] ggbio_1.20.2                  knitr_1.15                   
 [79] nnet_7.3-12                   gtable_0.2.0                 
 [81] zlibbioc_1.18.0               colorspace_1.3-0             
 [83] geneplotter_1.50.0            cluster_2.0.5                
 [85] gtools_3.5.0                  RCurl_1.95-4.8               
 [87] DESeq2_1.12.4                 bitops_1.0-6                 
 [89] RColorBrewer_1.1-2            Matrix_1.2-7.1               
 [91] foreign_0.8-67                bit_1.1-12                   
 [93] GenomicFeatures_1.24.5        hwriter_1.3.2                
 [95] reshape2_1.4.2                XML_3.98-1.5                 
 [97] AnnotationHub_2.4.2           iterators_1.0.8              
 [99] splines_3.3.1                 BiocParallel_1.6.6           
[101] Rsamtools_1.24.0             

limma microarray • 3.5k views
ADD COMMENT
0
Entering edit mode

Thank you all for commenting.

I found that adding: "labRow=tab1$SYMBOL" solved my problems. (Gordon knows his stuff!)

ADD REPLY
2
Entering edit mode
@gordon-smyth
Last seen 2 hours ago
WEHI, Melbourne, Australia

In my opinion, the heatmap is not doing the right thing for you. You are plotting genes that are differentially expressed, but the heatmap is clustering together genes that have the similar average expression levels (high or low) instead of clustering together genes that have similar DE patterns. I suspect this is not what you want. The culprit here is heatmap.2, a function that makes it very hard to set arguments correctly for expression data.

I suggest you instead try:

coolmap(y[rownames(tab1),], labRow=tab1$SYMBOL)
ADD COMMENT
1
Entering edit mode
Aaron Lun ★ 28k
@alun
Last seen 2 hours ago
The city by the bay

Just replace the row names of y with whatever you want to use. Reading ?heatmap.2 also suggests the labRow argument.

ADD COMMENT
0
Entering edit mode
jaro.slamecka ▴ 140
@jaroslamecka-7419
Last seen 2.2 years ago
Mitchell Cancer Institute, Mobile AL, U…

As Aaron suggested, this is done by specifying the labRow argument, try adding labRow=fData(eset)[["SYMBOL"]] to your list of arguments for heatmap.2:

heatmap.2(y[rownames(tab1),], main="Leptin-A Morphant", ylab="Probeset ID",
    xlab="Microarray Sample",col=greenred(75),cexRow=0.5,scale="none",key=TRUE,
    symkey=FALSE, density.info="none", trace="none", labRow=fData(eset)[["SYMBOL"]])

heatmap.2(y[rownames(tab2),], main="Leptin-A Rescue", ylab="Probeset ID",
    xlab="Microarray Sample",col=greenred(75),cexRow=0.5,scale="none",key=TRUE,
    symkey=FALSE, density.info="none", trace="none", labRow=fData(eset)[["SYMBOL"]])

ADD COMMENT
0
Entering edit mode

That won't annotate the heatmap correctly. The OP is selecting a subset of genes based on the row.names of one or the other tables and your suggestion will choose ALL of the gene symbols from the underlying ExpressionSet.

ADD REPLY

Login before adding your answer.

Traffic: 561 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