0
votes

I would like to create kind of a heatmap to visualize if variables contain the value zero or one (0/1), f.e. zero = white, one = black (or any other color).

Data structure: I want to heatmap 10 different antibiotics (columns, ab1 to ab10) and 100 different bacteria (rows, bac1 to bac100). F.e. if bacterium 51 is sensitive to ab 4, this value contains "1", otherwise "0".

With the following code I get a heatmap with at least 5 or 6 different colors (white to dark red), although the values in the variables are only 0 or 1.

heatmap(data, scale = "row")

Has anyone an idea, what I do wrong? According to the idea of a heatmap (higher values return colors more towords the upper end of a scale) a plot with only white or dark red squares should be returned and nothing in between... Or am I wrong?

Thank you!

1
I suspect the issue is that you're scaling the data across each row. Based on your description, you don't want to scale your data (remove the scale = "row") - jared_mamrot
sorry, I overlooked your answer - thank you very much for your reply! - MDStat

1 Answers

0
votes

You should not scale your data. scale="row" makes your data get averaged by row and the deviation from this row mean be visualized as heatmap.

Since the default of scale= is "row", just leaving out it won't solve the problem (you can see the same information also, if you in your R console type: ?heatmap and press RETURN). You have to set scale="none".

Thus do:

heatmap(data, scale = "none")