Question: Change color using colRow only for some rows in heatmap?
gravatar for star
11 months ago by
star240 wrote:

I draw a heatmap using below command: but I want to color some rows in a different color (like red) in the heatmap e.g. only ABCB5 and MAD1L1


        gene.ID   name   A     B
ENSG00000002822 MAD1L1  0.00 0.01818182
ENSG00000007264   MATK  1.00 0.00000000
ENSG00000004846  ABCB5  0.00 0.00000000
ENSG00000006837  CDKL3  0.08 0.00000000

Data 2 is the list of genes that I like to change their color in red.

Data 2:



      col=colorRampPalette(rev(brewer.pal(10, "RdYlBu"))) 
      main="", na.rm=TRUE,
      key=T, keysize=0.8,key.title= NA, key.xlab = "Ratio", dendrogram 
= "non", scale="non","none",
      reorderfun=function(d,w) reorder(d, w, agglo.FUN=mean),
      trace="none",cexRow=0.5, cexCol=0.8, labRow = 
Data$name,distfun=function(x) dist(x, method="euclidean"),
          hclustfun=function(x) hclust(x, method="ward.D2"))

I have tried colRow=c('red','black','red','black') but I have 400 rows that I like to color 100 of them in red. I would like to know is there any easier way?

Also, I have tried colRow=c(Data 2$name,'red'), but It gives different colors to the selected name.

heatmap R • 228 views
ADD COMMENTlink written 11 months ago by star240

I think ComplexHeatmap is the way to go once you start customizing heatmaps. That is the package that provides the most customizability in a really nice sensible API that also produces a bunch of S4 objects instead of inaccessible graphical objects.

ADD REPLYlink written 11 months ago by RamRS28k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1782 users visited in the last hour