I'm trying to reproduce the data first:
Here is a sample of my attachment matrix:
data = cbind (c (48,0, 0,0,0,1,3,0,1,0), c (0, 75,0,0,3,2,1,0,0,1), c (0,0) , 34,1, 16,0,3,0,1,1), c (0,0,1,58,0,1,3,1,0,0), c (0,3,16,0,181 , 6,6, 0,2,2), c (1,2,0,1,6,56,2,1,0,1), c (3,1,3,3,6,2,129,0 , 0,1), c (0,0,0,1,0,1,1,0,13,0,1), c (1,0,1,0,2,0,0,0,0,70,0 ), C (0, 1,1,0,2,1,1,1, 0, 85)) colnames (data) = letters [1: nero (data)] rownames (data) = colnames (data) < / Code>
And with these commands I do not Receive the following heatmap:
Library (rhesape) library (ggplot2) data. M = melt data data. M [, "resell"] = round (reserve data (data) [, "Value"]), 3) p = ggplot (data m, aes (x1, x2)) + gom_tile (aes (fill = rescale), color = "white") p = P + scale_fill_gradient (less = "White", high = "black") P + theme (text = element_text (size = 10), axis.text.x = element_text (angle = 90, adjust = 0))
This is similar to the plot of the left side of the Figure 1. The only difference is that (1) the nodes have not been randomly described, but (2) instead of being binary black / white pixels, I am using the "gray shades" palette so that my power Co-occurrence between nodes can be shown
But the thing is that it is difficult to separate any cluster structure (and it would be even more accurate with a full set of 100 nodes). So, I want to order my shorters with a cluster on the heatmap. I have this membership vector from a community identification algorithm:
membership = c (1,2,4,2,5, 3,1,2,2,3)
Now, how can I get a heatmap similar to the plot on the right side of Figure 1 above?
Thanks a lot for any help already
PS: I have used, but what I could not get.
It was very easy. I am still posting the solution, so in my case other people did not waste time like I did.
The first part is fine as before:
data. M = melt data data. M [, "resell"] = round (rescale (data.m [, "value"]), 3)
Now, move that melted data The level of frames should be according to the membership:
data.m [, "x1"] = factor (data.m [, "x1"], level = level (data. M [, "X1"]) [order (subscription)]) data. M [, "X2"] = factor (data.m [, "X2"], level = level (data.
Then, plot a summer map (as before) :
p = Ggplot (data.m, aes (x1, x2)) + geom_tile (aes (fill = rescale, color = "white") p = p + scale_fill_gradient (less = "White", high = "black") P + theme (text = element_text (size = 10), axis. Text.x = element_text (angle = 90, adjust = 0)) < P>
At this time, the cluster is clearly visible .
No comments:
Post a Comment