使用STRING构建蛋白互作网络(PPI)
STRING 链接 https://string-db.org/
数据集我使用R语言包clusterProfiler
中经常用作示例的基因列表
获取gene symbol的代码
library(clusterProfiler)
help(package="clusterProfiler")
library(DOSE)
data(geneList)
geneList
genelist<-names(geneList)[1:30]
gene.df<-bitr(genelist,fromType = "ENTREZID",
toType = "SYMBOL",OrgDb = "org.Hs.eg.db")
gene.df
write.table(gene.df$SYMBOL,file="../../PPI_pra_example_gene_symbol.txt",
row.names = F,quote = F,col.names = F)
将gene symbol上传到 STRING网站
得到结果
![](https://img.haomeiwen.com/i6857799/e4ed52f228c56dbf.png)
但是现在我想编辑这个图像,所以我就可以下载文件
![](https://img.haomeiwen.com/i6857799/2a4679649730ea30.png)
通常可以把这个文件导入到Cytoscape软件里进行可视化,但是我昨天试了一下,没有找到批量分组添加颜色的办法,比如这个30个基因是我转录组差异分析得到的结果,其中10个上调表达基因,20个下调表达基因。我想给上调基因添加红色,下调基因添加蓝色。我不知道Cytoscape是否可以实现,反正我现在还不知道怎么实现。
下面记录自己用R语言的ggraph
包的实现过程
准备数据
- 基因列表文件
PPI_pra_example_gene_symbol.txt
- PPI分析结果文件
string_interactions.tsv
初步结果
library(ggraph)
help(package="ggraph")
library(igraph)
nodes<-read.csv("../../PPI_pra_example_gene_symbol.txt",header=F)
links<-read.table("../../string_interactions.tsv",header=F,sep="\t")
nodes
links
net<-graph_from_data_frame(d=links,vertices=nodes,directed = T)
plot(net)
ggraph(net,layout = "linear",circular=T)+
geom_edge_link(color="blue")+
geom_node_point(size=10,color="red",alpha=0.5)+
theme_void()
![](https://img.haomeiwen.com/i6857799/39b722307480eaa9.png)
![](https://img.haomeiwen.com/i6857799/093d9d374e69f7f6.png)
ggraph(net,layout = "kk")+
geom_edge_link(color="blue")+
geom_node_point(size=10,color="red",alpha=0.5)+
theme_void()
![](https://img.haomeiwen.com/i6857799/bca146e85f3197e7.png)
几个layout比较下来还是layout="kk"好看一点。
接下来试着添加基因名字并按照上调和下调添加颜色
library(ggraph)
help(package="ggraph")
library(igraph)
nodes<-read.csv("../../PPI_pra_example_gene_symbol.txt",header=F)
links<-read.table("../../string_interactions.tsv",header=F,sep="\t")
nodes
links
nodes$Name<-nodes$V1
nodes$Group<-c(rep("Up",10),rep("Down",20))
net<-graph_from_data_frame(d=links,vertices=nodes,directed = T)
ggraph(net,layout = "kk")+
geom_edge_link()+
geom_node_point(size=10,aes(color=Group))+
geom_node_text(aes(label=Name))+
theme_void()
![](https://img.haomeiwen.com/i6857799/c6a8eadf1701c930.png)
以上用到的数据大家可以自己准备,或者在我的公众号留言就可以了。
欢迎大家关注我的公众号
小明的数据分析笔记本
![](https://img.haomeiwen.com/i6857799/b28879bb5142b7fc.jpg)
网友评论