R中的加权二部图聚类

时间:2019-03-01 11:08:59

标签: r module cluster-analysis bipartite

我有一个加权二部图,例如:

A   V   5
A   W   4
A   X   1
B   V   5
B   W   6
C   V   7
C   W   4
D   W   2
D   X   5
D   Z   7
E   X   4
E   Y   5
E   Z   8

enter image description here

structure(list(g1 = c("A", "A", "A", "B", "B", "C", "C", "D", 
"D", "D", "E", "E", "E"), g2 = c("V", "W", "X", "V", "W", "V", 
"W", "W", "X", "Z", "X", "Y", "Z"), w = c(5L, 4L, 1L, 5L, 6L, 
7L, 4L, 2L, 5L, 7L, 4L, 5L, 8L)), class = "data.frame", row.names = c(NA, 
-13L))

是否存在一种聚类方法来检测组1和2之间的高度连接的节点。例如,在上面的示例中,似乎存在两个聚类:

A,B,C - V,W
D,E - X,Y,Z

我从两方软件包https://www.rdocumentation.org/packages/bipartite/versions/2.11/topics/computeModules中找到了此功能。但是,我想为每个聚类提供某种p值或分数,以告诉我其“健壮性”。有什么想法吗?

m <- as_adjacency_matrix(graph_from_data_frame(g),attr = "w") %>% 
       as.matrix() %>% 
       computeModules()    
listModuleInformation(m)
[[1]]
[[1]][[1]]
[[1]][[1]][[1]]
[1] "A" "B" "C" "D" "E"

[[1]][[1]][[2]]
[1] "V" "W" "X" "Z" "Y"



[[2]]
[[2]][[1]]
[[2]][[1]][[1]]
[1] "A" "B" "C"

[[2]][[1]][[2]]
[1] "V" "W"


[[2]][[2]]
[[2]][[2]][[1]]
[1] "D" "E"

[[2]][[2]][[2]]
[1] "X" "Z" "Y"

enter image description here

谢谢

1 个答案:

答案 0 :(得分:0)

您是否考虑过使用Watts / Strogatz(也称为“传递性”)的聚类系数?它测量节点的近邻相互连接的趋势。您可以计算网络中所有节点的群集系数,然后在每个群集的节点之间求平均值。结果将表明聚类与顶点(即完全连接的子图)的接近程度。

传递性在igraph包中实现。

有关加权网络的概括,另请参见wiki页。