UpSet——集合关系可视化神器

分析背景

提到集合的可视化,大家第一时间想到的是用Venn图来展示,在前期的推文中,小编也给大家分享了venn图的绘制方法。然而,值得一提的是,小编分享的方法是基于R语言,并将根据项目经验,将常规的代码语句进行封装,对于刚入门的小白来说,只需要整理好自己的数据,将数据传入到函数中,即可得到高质量的Venn图,方面快捷,省时省力。但是,当集合数多比如 7个以上的时候那就会看的眼花缭乱了。 针对上面这种情况,小编今天可大家编写了一个用于多个集合数据可视化小程序——集合图,并且小编已经将其封装成函数,小伙伴们只需将自己的数据传入到函数中,即可做出高质量的图片,保存下来,AI编辑一下,就可以插入到自己的论文写作中,话不多说,直接上脚本!

分析方法

安装R包

自定义函数

实战演练

df = readFlie('./upset.txt',type = 'txt',row = F)
# 抽取数据,制造测试数据
set.seed(1234)
df_list = list('Symbol1'=sample(df$symbol,180),'Symbol2'=sample(df$symbol,200),
               'Symbol3'=sample(df$symbol,220),'Symbol4'=sample(df$symbol,240),
               'Symbol5'=sample(df$symbol,260),'Symbol6'=sample(df$symbol,280),
               'Symbol7'=sample(df$symbol,300),'Symbol8'=sample(df$symbol,310),
               'Symbol9'=sample(df$symbol,150))
# 绘制集合图
# 4维集合图
wn_upset(df_list[1:4])
# 6维集合图
wn_upset(df_list[1:6])
# 9维集合图
wn_upset(df_list)
# 保存图片
pdf('./up_set.pdf',height = 9,width = 16)
# 8维集合图
wn_upset(df_list[1:8]) 
dev.off()

 

关注微信公众号,回复关键词“upset”,获取脚本源码和测试数据。

参考文献

  • Lex, A., Gehlenborg, N. Sets and intersections. Nat Methods 11, 779 (2014).

  • A. Lex, N. Gehlenborg, H. Strobelt, R. Vuillemot and H. Pfister, "UpSet: Visualization of Intersecting Sets," in IEEE Transactions on Visualization and Computer Graphics, vol. 20, no. 12, pp. 1983-1992, 31 Dec. 2014.

  • Conway J R, Lex A, Gehlenborg N. UpSetR: an R package for the visualization of intersecting sets and their properties[J]. Bioinformatics, 2017, 33(18): 2938-2940.

posted @ 2020-08-20 09:23  稳我  阅读(558)  评论(0编辑  收藏  举报