1

I'm actually using the heatmap.2 package from R

and the idea is that I have a matrix as :

  COL1 COL2 COL3 COL4
A    1    0    0    1
B    1    0    1    1
C    1    0    1    0
D    0    1    1    0

which gives me a heatmap such as :

heatmap.2(as.matrix(matrix), trace="none",density.info="none",key = F)

enter image description here

But now I would like to know if it is possible with heatmap.2 from this matrix :

matrix_hilight_coordonates

 COL1 COL2 COL3 COL4
A    A    B    B    B
B    A    A    A    A
C    A    A    A    B
D    B    B    B    B

with the same dimension to:

  • highlight cells where there is a B as in example A

OR

  • hatch cells where there is a B as in example B

enter image description here

here is a related question : Highlight Subset Cells From Heatmap By Row/Col Index

the problem is that they do not go from a specific df in order to highlight the cells.

Thank you very much for your time and help

data

matrix1

structure(list(COL1 = c(1L, 1L, 1L, 0L), COL2 = structure(c(1L, 
1L, 1L, 2L), .Label = c("0", "1"), class = "factor"), COL3 = c(0L, 
1L, 1L, 1L), COL4 = structure(c(2L, 3L, 1L, 1L), .Label = c("0", 
"1", "1"), class = "factor")), class = "data.frame", row.names = c("A", 
"B", "C", "D"))

matrix_hilight_coordonates

structure(list(COL1 = structure(c(1L, 1L, 1L, 2L), .Label = c("A", 
"B"), class = "factor"), COL2 = structure(c(2L, 1L, 1L, 2L), .Label = c("A", 
"B"), class = "factor"), COL3 = structure(c(2L, 1L, 1L, 2L), .Label = c("A", 
"B"), class = "factor"), COL4 = structure(c(2L, 1L, 2L, 2L), .Label = c("A", 
"B"), class = "factor")), class = "data.frame", row.names = c("A", 
"B", "C", "D"))
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
chippycentra
  • 3,396
  • 1
  • 6
  • 24

0 Answers0