Change color using colRow only for some rows in heatmap?
0
0
Entering edit mode
5.2 years ago
star ▴ 350

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

Data:

        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:

 name
 MAD1L1 
 ABCB5

command:

heatmap.2(as.matrix(Data[-c(1,2)]),
      col=colorRampPalette(rev(brewer.pal(10, "RdYlBu"))) 
 (8),margins=c(8,8),
      main="", na.rm=TRUE,
      key=T, keysize=0.8,key.title= NA, key.xlab = "Ratio", dendrogram 
= "non", scale="non",
      density.info="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.

R heatmap • 864 views
ADD COMMENT
0
Entering edit mode

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 REPLY

Login before adding your answer.

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