來復(fù)現(xiàn)一幅基因互作網(wǎng)絡(luò)圖曾掂,這種圖一般使用cytoscape可以完成芹彬。這里我們使用ggraph簡單復(fù)現(xiàn)一下鄙早。
圖片
(圖片來源:https://sourceforge.net/projects/rarevator/)數(shù)據(jù)準備:需要兩個文件删窒,一個是互作結(jié)果舟误,就是基因之間的關(guān)系造垛。還有一個文件是基因的分組信息等等魔招,兩個文件合并構(gòu)建ggraph結(jié)構(gòu)文件。
setwd("D:/KS項目/公眾號文章/互作網(wǎng)絡(luò)圖")
gene_info <- read.csv("gene_group.csv", header = T)
interaction <- read.csv("string_interactions.csv", header = T)
library(igraph)
library(ggraph)
library(tidyverse)
library(tidygraph)
graph <- as_tbl_graph(interaction) %>%
mutate(interaction = centrality_degree(mode='out'),
group=gene_info$group)
作圖很簡單五辽,標記分組办斑,并將節(jié)點大小用互作數(shù)目表示。
ggraph(graph, layout = 'kk') +
geom_edge_fan(color='grey60',
show.legend=T) +
geom_node_point(aes(size = interaction,
fill=factor(group)),
shape=21)+
geom_node_text(aes(filter= interaction>5,
label=name),
size=2.5,
repel = T)+
theme_graph()
圖片
連線粗細也可以用互作強度來表示:
ggraph(graph, layout = 'kk') +
geom_edge_fan(color='grey60',
show.legend=T,
aes(edge_width=automated_textmining)) +
geom_node_point(aes(size = interaction,
fill=factor(group)),
shape=21)+
geom_node_text(aes(filter= interaction>5,
label=name),
size=2.5,
repel = T)+
scale_edge_width(range=c(0,1))
圖片
這樣就完成了,其他更多的分組及設(shè)置可參照上面添加乡翅,當(dāng)然了鳞疲,ggraph還有很多的布局展示,包括我們之前說過的circle蠕蚜,感興趣可自行探索尚洽!
更多精彩請至我的公眾號---KS科研分享與服務(wù)