一般來(lái)說網(wǎng)絡(luò)圖都是R語(yǔ)言導(dǎo)出數(shù)據(jù)放入cytoscape里面繪制列另,今天想試試在R語(yǔ)言內(nèi)部去畫芽腾,確實(shí)有相應(yīng)的R包(igraph)可以做,不是專門針對(duì)PPI網(wǎng)絡(luò)來(lái)的页衙,自己組織一下數(shù)據(jù)可以畫摊滔。
尤其是基因數(shù)量比較少的情況下阴绢,還是很好用的,省掉手動(dòng)點(diǎn)鼠標(biāo)的重復(fù)操作艰躺。
1.輸入數(shù)據(jù)
string_interactions.tsv是從string網(wǎng)頁(yè)下載的PPI網(wǎng)絡(luò)輸出結(jié)果文件呻袭。
圖上基因的顏色是按照上下調(diào)來(lái)分配的,在這個(gè)例子里基因上下調(diào)信息是編的腺兴,實(shí)際應(yīng)用時(shí)可以從差異分析結(jié)果中得到左电。
2.樣圖
3.代碼如下
library(igraph)
links= read.delim("string_interactions.tsv")
network <- graph_from_data_frame(d=links[,c(1:2,13)], directed=F)
deg <- degree(network, mode="all")
nodes <- data.frame(
name=unique(links$X.node1),
group=c( rep("up",6),rep("down",5)))
network <- graph_from_data_frame(d=links, vertices=nodes, directed=F)
my_color = c("#66C2A5", "#FC8D62", "#8DA0CB")[as.numeric(as.factor(V(network)$group))]
par(bg="grey13", mar=c(0,0,0,0))
plot(network,
vertex.size=deg,
layout=layout.circle,
vertex.color=my_color,
vertex.label.cex=0.7,
vertex.label.color="white",
vertex.frame.color="transparent",
edge.width=E(network)$combined_score*3,
edge.curved=0.1)
legend(x=1, y=1,
legend=unique(V(network)$group),
col = unique(my_color) ,
bty = "n", pch=20 , pt.cex = 2, cex = 1,
text.col="white" , horiz = F)
plot(network,
vertex.size=deg,
layout=layout.fruchterman.reingold,
vertex.color=my_color,
vertex.label.cex=0.7,
vertex.label.color="white",
vertex.frame.color="transparent",
edge.width=E(network)$combined_score*3,
edge.curved=0)
legend(x=1, y=1,
legend=unique(V(network)$group),
col = unique(my_color) ,
bty = "n", pch=20 , pt.cex = 2, cex = 1,
text.col="white" , horiz = F)