ネットワークのコミュニティ検出ãããããããã¨æã£ã¦é·ããæ¾ç½®ãã¦ããã®ã§ããã
éè¤ããªãã³ãã¥ããã£ã¯igraph, éè¤ãããã³ãã¥ããã£ã¯linkcommã§ã§ããã®ã§ãéè¤ãããã»ããããã
linkcomm ã¯ã©ã¹ã¨ããã®ãã§ããã®ã§æ±ãã«ãããã¨æã£ãããä¸ã«igraphãã§ããã®ã§ããããããã ã£ããããããlinkcommã®ã¾ã¾ããããããã®ã¯ãã©ã¡ã¼ã¿ã®è¨å®ãããã©ãã ã£ãã®ã§æããã
ã¨æã£ãã plotLinkCommGraph ã§ã§ãããããã
ããªãã¿ã®ラブライブの百合解析ãããã¼ã¿ãã¨ãããlinkcommã¯ã¨ãã¸ãªã¹ãããã®ãã¼ã¿ãåãåããããªã®ã§ãã¨ãã¸ãªã¹ãã«å¼·å¶å¤æãã¦æ¸¡ãã
ã³ãã¥ããã£ã®æ¤åºã¯æå°¤æ¨å®ã£ã½ãä½ãã§æãããã£ã½ãã³ãã¥ããã£æ°ã«ãã¦ããããä½ããã©ã¡ã¼ã¿ããããã°å¤ããããã
# res ã«ãªã³ã¯ã®ç¾å matrix ãããã¨ã㦠weightmat <- res + t(res) w <- weightmat[lower.tri(weightmat)] # weight ã®ä½æ # é£æ¥è¡åããã¨ãã¸ãªã¹ãã«ããã mat <- matrix(unlist(strsplit(unlist(mapply(function(i) mapply(function(x) paste(rownames(res)[i], x, sep=" "), rownames(res)[res[i,]>0]), seq(nrow(res)))), " ")), nc=2, byrow=TRUE) library(linkcomm) lc <- getLinkCommunities(mat)
Checking for loops and duplicate edges... 100.00% Found and removed 9 duplicate edge(s) Calculating edge similarities for 21 edges... 100.00% Hierarchical clustering of edges... Calculating link densities... 100.00% Maximum partition density = 0.6063492 Finishing up...4/4... 100.00% Plotting... Colouring dendrogram... 100%
ã
ãªãã¸ã§ã¯ãã«ã¯ igraph ãå
¥ã£ã¦ããã®ã§ããã¡ãã«æ
£ãã¦ãã人ã¯ããã§ã´ãªæ¼ãã§ããã
lc$igraph edgecolor <- numeric(nrow(lc$edgelist)) for(i in seq(lc$cluster)){ edgecolor <- replace(edgecolor, lc$cluster[[i]], i) } E(lc$igraph)$width <- w[w > 0] E(lc$igraph)$color <- edgecolor plot(lc$igraph)
ã
ã³ãã¥ããã£ãåæ ãã¦ã°ã©ããæããå³æ°ãªãã®ã§ã¾ãã¾ã png éããã
ãããã¯ã¼ã¯ã®次数(degree)・近接中心性(closeness)・媒介中心性(betweenness)ãã¤ãã§ã«ãåå¼·ã
stat <- round(cbind(closeness(lc$igraph), betweenness(lc$igraph)), 2) plot(lc, type="graph") s0 <- 0.0038 #æ¡å¤§ç¸®å°ç lay0 <- matrix(unlist(locator(length(V(lc$igraph)))), nc=2) # ãããã座æ¨ãåå¾ããã for(i in seq(pics)){ xleft=lay0[i, 1]*ra - xy0[2, i]/2*s0 ybottom=lay0[i, 2]*ra - xy0[1, i]/2*s0 xright=lay0[i, 1]*ra + xy0[2, i]/2*s0 ytop=lay0[i, 2]*ra + xy0[1, i]/2*s0 rasterImage(image=pics[[i]], xleft=xleft, ybottom=ybottom, xright=xright, ytop=ytop, xpd=TRUE) text(lay0[i,1]-0.1,lay0[i,2],paste(paste(c("Cl", "Be"), stat[i,]), collapse="\n"), adj=c(0,2)) }
ã
ãããªæãã«ãªãããã ããããå°ãçé¢ç®ãªè§£æããããªããhuman_pp ã¨ããHuman Protein Interactome (ç¸äºä½ç¨ã®ããã°ãã¼ã¿ã¿ãããªãã®)ããµã³ãã«ã¨ãã¦ããã®ã§ãããããã£ã¦ã¿ãã
ãããããããããã¨ã©ãã«ãéªéãªã®ã«ã©ãæ¶ãããé¢åã ã£ãã®ã§ããæ°ãããã°â¦
h <- getLinkCommunities(human_pp) plot(h, type="graph")