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.
But I got the following 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.
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 theward.D2
agglomeration method (that is the clustering algorithm).Also, how can I add gene names after adding clustering?
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 beComplexHeatmap
package.