知识分享 | 转录组个性化分析(4)——蛋白互作分析

       蛋白质-蛋白质相互作用(protein-protein interaction, PPI)是指两个或两个以上的蛋白质分子通过非共价键形成蛋白质复合体(protein complex)的过程。在进行数据挖掘的时候往往会得到很多的差异表达的基因,当你对着一堆基因毫无头绪时,此时PPI数据库对你的数据挖掘起了很大的助攻作用。

       接下来,跟着小编一起来学习下PPI分析吧!文中附详细代码,小伙伴们可以使用自己项目数据,一步步复现下结果!

1  PPI分析的意义

       系统分析大量蛋白在生物系统中的相互作用关系,对了解生物系统中蛋白质的工作原理,了解疾病等特殊生理状态下生物信号和能量物质代谢的反应机制,以及了解蛋白之间的功能联系都有重要意义。在生物医药领域有助于从系统的角度研究疾病分子机制、发现新药靶点等等。

       接下来,小编具体讲解下基于STRING数据库,提取目标基因集的互作关系,构建蛋白互作关系,同时利用igraph和ggraph对互作网络进行可视化。对于数据库中未收录信息的物种,可以使用BLAST软件,将目的基因与数据库中的蛋白质进行序列比对,寻找同源蛋白,根据同源蛋白的互作关系对构建互作网络。构建完成的蛋白质互作网络大家也可尝试导入Cytoscape软件进行可视化。

2  创建STRINGdb对象

library(tidyverse)

library(clusterProfiler)

library(org.Hs.eg.db)  小鼠的话,把Hs改成Mm

library(STRINGdb)

library(igraph)

library(ggraph)

# 创建STRINGdb对象

string_db <- STRINGdb$new( version="11", species=9606,

                          score_threshold=400, input_directory="")

#score_threshold是蛋白互作的得分,此值会用于筛选互作结果,400是默认分值,如果要求严格可以调高此值。

3  构建基因列表

#clusterProfiler将Gene Symbol转换为Entrez ID,构建基因列表,可以自己定义值,也可以导入表格,需要表头

gene <- gene %>% bitr(fromType = "SYMBOL",

                      toType = "ENTREZID",

                      OrgDb = "org.Hs.eg.db",

                      drop = T)

4  使用map函数将基因匹配到STRING数据库的ID

data_mapped <- gene %>% string_db$map(my_data_frame_id_col_names = "ENTREZID",

               removeUnmappedRows = TRUE)

string_db$plot_network( data_mapped$STRING_id )

5  get_interactions获取蛋白互作信息,以用于后续可视化

hit<-data_mapped$STRING_id

info <- string_db$get_interactions(hit)

#info包含了蛋白互作的信息,比较重要的是前两列和最后一列:from、to、combined_score,前两列指定了蛋白互作关系的基因对,最后一列是此蛋白互作关系的得分,info数据将用于后续分析。

6  igraph和ggraph可视化蛋白互作网络图

# 转换stringID为Symbol,只取前两列和最后一列

links <- info %>%

 mutate(from = data_mapped[match(from, data_mapped$STRING_id), "SYMBOL"]) %>%

 mutate(to = data_mapped[match(to, data_mapped$STRING_id), "SYMBOL"]) %>%  

 dplyr::select(from, to , last_col()) %>%

 dplyr::rename(weight = combined_score)

# 节点数据

nodes <- links %>% { data.frame(gene = c(.$from, .$to)) } %>% distinct()

# 创建网络图

# 根据links和nodes创建

net <- igraph::graph_from_data_frame(d=links,vertices=nodes,directed = F)

# 添加一些参数信息用于后续绘图

# V和E是igraph包的函数,分别用于修改网络图的节点(nodes)和连线(links)

igraph::V(net)$deg <- igraph::degree(net) # 每个节点连接的节点数

igraph::V(net)$size <- igraph::degree(net)/5 #

igraph::E(net)$width <- igraph::E(net)$weight/10

# 使用ggraph绘图

# ggraph是基于ggplot2的包,语法和常规ggplot2类似

ggraph(net,layout = "kk")+

 geom_edge_fan(aes(edge_width=width), color = "lightblue", show.legend = F)+

 geom_node_point(aes(size=size), color="orange", alpha=0.7)+

 geom_node_text(aes(filter=deg>5, label=name), size = 5, repel = T)+

 scale_edge_width(range = c(0.2,1))+

 scale_size_continuous(range = c(1,10) )+

 guides(size=F)+

 theme_graph()


 #stress布局作图

 ggraph(net,layout = "stress")+ #不同的地方

 geom_edge_fan(aes(edge_width=width), color = "lightblue", show.legend = F)+

 geom_node_point(aes(size=size), color="orange", alpha=0.7)+

 geom_node_text(aes(filter=deg>5, label=name), size = 5, repel = T)+

 scale_edge_width(range = c(0.2,1))+

 scale_size_continuous(range = c(1,10) )+

 guides(size=F)+

 theme_graph()  


 #环形布局    

 ggraph(net,layout = "linear", circular = TRUE)+

 geom_edge_fan(aes(edge_width=width), color = "lightblue", show.legend = F)+

 geom_node_point(aes(size=size), color="orange", alpha=0.7)+

 geom_node_text(aes(filter=deg>5, label=name), size = 5, repel = F)+

 scale_edge_width(range = c(0.2,1))+

 scale_size_continuous(range = c(1,10) )+

 guides(size=F)+

 theme_graph()


# 去除游离的互作关系:其和主网络并不相连,像这种互作关系可以去掉,此时出来的图就会更加美观。

# 如果links数据框的一个link的from只出现过一次,同时to也只出现一次,则将其去除

links_2 <- links %>% mutate(from_c = count(., from)$n[match(from, count(., from)$from)]) %>%

 mutate(to_c = count(., to)$n[match(to, count(., to)$to)]) %>%

 filter(!(from_c == 1 & to_c == 1)) %>%

 dplyr::select(1,2,3)

# 新的节点数据

nodes_2 <- links_2 %>% { data.frame(gene = c(.$from, .$to)) } %>% distinct()

# 创建网络图

net_2 <- igraph::graph_from_data_frame(d=links_2,vertices=nodes_2,directed = F)

# 添加必要的参数

igraph::V(net_2)$deg <- igraph::degree(net_2)

igraph::V(net_2)$size <- igraph::degree(net_2)/5

igraph::E(net_2)$width <- igraph::E(net_2)$weight/10

#如果去除了游离的互作关系,那么可以使用一种中心布局的方式,它是根据一个节点的连接数而排列其位置,连接数越大,节点越倾向于在中间位置排列,会更容易看得出重要节点。另外环形布局的线使用弧形线(geom_edge_arc)会更美观:

ggraph(net,layout = "linear", circular = TRUE)+

 geom_edge_arc(aes(edge_width=width), color = "lightblue", show.legend = F)+

 geom_node_point(aes(size=size), color="orange", alpha=0.7)+

 geom_node_text(aes(filter=deg>5, label=name), size = 5, repel = F)+

 scale_edge_width(range = c(0.2,1))+

 scale_size_continuous(range = c(1,10) )+

 guides(size=F)+

 theme_graph()

基因蛋白互作网络图
互作关系结果

combined_score 互作得分,<400 低可信,400~700 中可信,>700 高可信。

你可能感兴趣的:(知识分享 | 转录组个性化分析(4)——蛋白互作分析)