当前位置: 首页 > news >正文

复现NC图表:二分图 (bipartite plot) 网络绘制(三种方法)-应用于细胞互作受配体展示-调控网络展示等等

如题,这个标题有点长,首先我们需要展示的图是bipartite plot,中文有叫二分图、连线图的,总之就是展示两组之间网络关系。可以应用的地方有很多,不只是我们介绍的互作关系、或者ligands-target。起源是一篇《nature communications》文章的图,它展示的是ligand于targets。原文提供了代码,可以学习!

image.png

image.png

(reference:Gliovascular transcriptional perturbations in Alzheimer’s disease reveal molecular mechanisms of blood brain barrier dysfunction)
ggraph,首先相比于igraph,在很多设置上因为与ggplot互通,所以会简单很多,没有那么复杂,可操作性更强。layout可以自己设定,也可以参照上面的!

node_info <- rbind(data.frame(node = rownames(active_ligand_target_links), group="target"),
                   data.frame(node = colnames(active_ligand_target_links), group="ligands"))


no <- c(rep("no", 20), sample(c('up','down'), size = nrow(node_info)-20, replace = TRUE))
node_info$reg <- sample(no, size =nrow(node_info), replace = TRUE)


#构建ggraph作图数据
df_graph <- as_tbl_graph(as.matrix(active_ligand_target_links)) %>% 
  mutate(group=node_info$group, #添加分组信息
         reg  = node_info$reg)



#plot
# sugiyama
ggraph(df_graph, layout = 'igraph', algorithm='bipartite') +
  geom_edge_link(aes(colour=weight), edge_width =1)+
  scale_edge_color_gradientn(colours = c("grey80","grey50","grey30","black"))+
  geom_node_point(aes(fill=reg, filter= group =='ligands'), 
                  size=2,shape=21) +
  geom_node_point(aes(fill=reg, filter= group =='target'), 
                  size=2,shape=23)+
  scale_fill_manual(values = c("#E4502E","#69B7CE","black"),
                    breaks = c("up",'down',"no"),
                    labels = c("up",'down',"no"))+
  geom_node_text(aes(filter= group =='ligands',
                     label = name),
                  fontface = "italic",
                 hjust=1.1)+
  geom_node_text(aes(filter= group =='target',
                     label = name),
                 fontface = "italic",
                 hjust=-0.1)+
  coord_flip()+
  theme_minimal() +
  scale_y_discrete(expand = c(0.2,0.2))+
  ggraph::th_no_axes()




#调整layout

LO1 <- layout_as_bipartite(df_graph, maxiter=0);
re_pos <- c(seq(from = 0.5, by = 1, length.out = length(LO1[which(LO1[,2]==1)])),
            seq(from = 0.5, by = 1.1, length.out = length(LO1[which(LO1[,2]==0)])))

LO1[,1] <- re_pos



ggraph(df_graph, layout = LO1) +
  geom_edge_link(aes(colour=weight), edge_width =1)+ #连线
  scale_edge_color_gradientn(colours = c(alpha("grey90",0.5),
                                         alpha("grey60",0.5),
                                         alpha("grey30",0.5),"black"))+#连线颜色
  geom_node_point(aes(fill=reg, filter= group =='ligands'), 
                  size=2,shape=21) +#节点设置
  geom_node_point(aes(fill=reg, filter= group =='target'), 
                  size=2,shape=23)+
  scale_fill_manual(values = c("#E4502E","#69B7CE","black"),
                    breaks = c("up",'down',"no"),
                    labels = c("up",'down',"no"))+
  geom_node_text(aes(filter= group =='ligands',
                     label = name),
                 fontface = "italic",
                 hjust=1.1)+ #文字标注
  geom_node_text(aes(filter= group =='target',
                     label = name),
                 fontface = "italic",
                 hjust=-0.1)+
  coord_flip()+
  theme_minimal() +
  scale_y_discrete(expand = c(0.2,0.2))+
  ggraph::th_no_axes()

image.png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.dtcms.com/a/44945.html

相关文章:

  • Windows安装sql server2017
  • GitCode 助力 JeeSite:开启企业级快速开发新篇章
  • week 3 - More on Collections - Lecture 3
  • 线反转法实现矩形键盘按键识别
  • QT播放视频保持视频宽高比消除黑边
  • 基于javaweb的SSM+Maven幼儿园管理系统设计和实现(源码+文档+部署讲解)
  • brew search报错,xcrun:error:invalid active developer path CommandLineTools
  • 通俗易懂的分类算法之决策树详解
  • 使用Simulink中的IsUpdated获取Rport的更新状态
  • 当我删除word文件时无法删除,提示:操作无法完成,因为已在Microsoft Word中打开
  • 一、舵机模块的分析与使用
  • flowable使用
  • 问题修复-后端返给前端的时间展示错误
  • 7.1 - 定时器之中断控制LED实验
  • SpringBoot原理-02.自动配置-概述
  • 微服务即时通信系统---(七)文件管理子服务
  • 飞书考勤Excel导入到自己系统
  • 网络原理--TCP/IP(2)
  • 神经网络|(十一)|神经元和神经网络。
  • 深入了解 K-Means 聚类算法:原理与应用
  • C++22——哈希(上)
  • GD32F303 系统时钟
  • 例子 DQN + CartPole: 深入思考一下,强化学习确实是一场智能冒险之旅!
  • 《今日AI-人工智能-编程日报》
  • 深入解析 Svelte:下一代前端框架的革命
  • mosfet的驱动设计-开关损耗
  • 算法(三)——最大公约数、最小公倍数、同余原理
  • LeetCode 873. Length of Longest Fibonacci Subsequence(2025/2/27每日一题)
  • 西门子S7-1200比较指令
  • @[TOC](Java实现 图书管理系统) # 一、菜单 该图书管理系统的菜单界面主要有以下两种: **管理员菜单:** **用户菜单:**