Heatmap for DEGs from DESeq2
0
0
Entering edit mode
3.5 years ago
Aynur ▴ 60

Hello, I am still finding my way in RNA-Seq analysis using DESeq2. Please help me change my codes in order to get the heatmap I am looking for. I want to make a heatmap for 50 significantly up-regulated and 50 down-regulated genes from the DESeq2 result. I also want to add gene names to it, instead of having Ensemble IDs. Any help is appreciated. Thank you very much. Here is the heatmap I want.
Picture1

But I got the following heatmap. OSM-Heatmap

I used the following code for the heatmap.

rld <- rlog( dds) 
topVarGenes <- head( order( rowVars( assay(rld) ), 
                        decreasing=TRUE ),20 )
heatmap.2( assay(rld)[ topVarGenes, ], scale="row", 
       trace="none", dendrogram="column", 
       col = colorRampPalette( rev(brewer.pal(9, "RdBu")) )(255),
       ColSideColors = c( control="darkgreen", OSM="orange" )[
         colData(rld)$condition ] )

I want to add gene names using the biomaRt and used the following codes to add names.

ensembl = useMart( "ensembl", dataset = "mmusculus_gene_ensembl" )
 genemap <- getBM( attributes = c("ensembl_gene_id", "mgi_symbol"),
              filters = "ensembl_gene_id",
              values = res$ensembl,mart = ensemble )
     idx <- match( res$ensembl, genemap$ensembl_gene_id )
  res$mgi_symbol <- genemap$mgi_symbol[ idx ]

But then I can't combine these codes to the previous codes to generate a heatmap with gene names. Thank you very much.

OSM-Heatmap

R RNA-Seq • 4.7k views
ADD COMMENT
1
Entering edit mode

You have to cluster the rows, please check out hclust(). Probably the your heatmap package as a built-in function for this. Check tis documentation towards clustering. I personally use the ward.D2 agglomeration method (that is the clustering algorithm).

ADD REPLY
0
Entering edit mode

Also, how can I add gene names after adding clustering?

ADD REPLY
1
Entering edit mode

Read the manual. labRow is the argument you want. I mean, in the one above the gene names are present, just out of bounds. Check on how to set margins in R. An alternative package with much more examples and code could be ComplexHeatmap package.

ADD REPLY

Login before adding your answer.

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