1

I have an adjacency matrix (netm) with co-occurrences as mostly 0's. I get the heatmap below when I plot it using:

require(gplots)
heatmap.2(netm,col=c("gold", "dark orange","orange","yellow"),
    Rowv=F, Colv=F, dendrogram="none", scale="none", trace="none")

How can I ignore values below a certain threshold in the matrix? I don't want to plot values below 3 in my graph co-occurrence matrix.

enter image description here

Snapshot of data (a co occurence matrix )

    bacardi breezer aldi    rum white   coconut
bacardi 0   2   0   1   0   0
breezer 2   0   0   0   0   0
aldi    0   0   0   1   1   0
rum 1   0   1   0   1   1
white   0   0   1   1   0   0
coconut 0   0   0   1   0   0
drinks  0   0   0   1   0   1
daniel  0   0   0   1   0   0
smci
  • 32,567
  • 20
  • 113
  • 146
EricA
  • 403
  • 2
  • 14
  • Is this correctly tagged `ggplot2`? Where is the `heatmap.2` function from? Can you give us a [minimal reproducible example](http://stackoverflow.com/questions/5963269? – Axeman Jan 17 '18 at 16:06
  • @axeman Its from package gplots – EricA Jan 17 '18 at 16:10

1 Answers1

2

Either you can substitute NA to unwanted values (e.g. 0s), and keep them in the plot:

netm2 <- netm
netm2[netm2 == 0] <- NA
heatmap.2(netm2, col=c("gold", "dark orange","orange","yellow"), Rowv=F, Colv=F, dendrogram="none", scale="none", trace="none")

or manually remove columns/rows which contain NAs:

netm3 <- netm2[complete.cases(netm2), complete.cases(t(netm2))]
heatmap.2(netm3, col=c("gold", "dark orange","orange","yellow"), Rowv=F, Colv=F, dendrogram="none", scale="none", trace="none")
Lorenzo G
  • 561
  • 4
  • 8