I am trying to create a heatmap in R. I have tried using the heatmap.2 command.
My data consists of x, and y columns and associated relative frequency of a point(frequency divided by the total frequency)
with zero frequency in most places and a small relative frequency in others. I have converted my data to a matrix since this seems what the heatmap command wants and attempted to remove the x and y-coordinates.
BB <- matrix(as.matrix(surfacerevfreq1[, 3]), ncol = 35, byrow = T)
There are two problems as I see it, not all x and y -coordinates are listed. i.e. the x-coordinate starts at 1 and goes to 35 whereas the y-coordinate starts at 11 and goes to 30. The heatmap function does not seem to like this. I have thought over inserting zeros at the beggining of the data set so that each point from 1- 10 on the y-axis had a value. However, I am not sure if this is the best idea.
So I suppose my question is: how do I format my data in such a way that I can a valid heatmap from this data? I should add that I want the numbers on my x and y-scale displayed also if possible. Since the purpose it to graphically show the relative frequency associated with each point.
thanks.
here is a subset of my data so that you can see what it looks like in matrix form
col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12
0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
col13 col14 col15 col16 col17 col18 col19 col20 col21 col22 col23 col24
0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0005017561 0.0005017561 0.0000000000
col25 col26 col27 col28 col29 col30 col31 col32 col33 col34 col35
0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
and here is the heatmap command that I am using:
hU <- heatmap.2(xx, Rowv=FALSE, symm=TRUE, trace="none", density.info="none", dendrogram="none")