电子商务类网站建设,加盟教育培训哪个好,网站建设哪里好,广州冼村姓什么学习更多生信小技巧#xff0c;点上方蓝字关注我们分析背景01提到集合的可视化#xff0c;大家第一时间想到的是用Venn图来展示#xff0c;在前期的推文中#xff0c;小编也给大家分享了venn图的绘制方法。然而#xff0c;值得一提的是#xff0c;小编分享的方法是基于R语… 学习更多生信小技巧点上方蓝字关注我们分析背景01 提到集合的可视化大家第一时间想到的是用Venn图来展示在前期的推文中小编也给大家分享了venn图的绘制方法。然而值得一提的是小编分享的方法是基于R语言并将根据项目经验将常规的代码语句进行封装对于刚入门的小白来说只需要整理好自己的数据将数据传入到函数中即可得到高质量的Venn图方面快捷省时省力。但是当集合数多比如 7个以上的时候那就会看的眼花缭乱了。 针对上面这种情况小编今天给大家编写了一个用于多个集合数据可视化小程序——集合图并且小编已经将其封装成函数小伙伴们只需将自己的数据传入到函数中即可做出高质量的图片保存下来AI编辑一下就可以插入到自己的论文写作中话不多说直接上脚本分析方法02# 安装R包if (!requireNamespace(UpSetR, quietly TRUE)) install.packages(UpSetR,repos https://mirrors.tuna.tsinghua.edu.cn/CRAN/)if (!requireNamespace(RColorBrewer, quietly TRUE)) install.packages(RColorBrewer,repos https://mirrors.tuna.tsinghua.edu.cn/CRAN/)if (!requireNamespace(data.table, quietly TRUE)) install.packages(data.table,repos https://mirrors.tuna.tsinghua.edu.cn/CRAN/) # 自定义函数## 快速读入数据readFliefunction(input,type,rowT,headerT){ # input 为读入文件的路径type为读入文件的类型格式为‘.txt’或‘.csv’,rowT,将文件的第一列设置为列名 library(data.table,quietly TRUE) if(typetxt){ dat fread(input,header header,sep\t,stringsAsFactors F,check.names F) if(row){ dat as.data.frame(dat,stringsAsFactors F) rownames(dat) dat[,1] dat dat[,-1] }else{ dat as.data.frame(dat,stringsAsFactors F) } }else{ dat fread(input,header header,sep,,stringsAsFactors F,check.names F) if(row){ dat as.data.frame(dat,stringsAsFactors F) rownames(dat) dat[,1] dat dat[,-1] }else{ dat as.data.frame(dat,stringsAsFactors F) } } return(dat)}## 绘制集合图wn_upsetfunction(list,bar_corlightblue2,point_cor blue,keep.orderF,order.byc(freq,degree)){ # list 传入数据为一个list # bar_cor 上方条形图的填充颜色 # point_cor 共有集合点阵图的颜色 # keep.order 根据list中的向量顺序展示样本默认为FALSE此时按照样本中物种数量由多至少顺序展示 # order.by是否按照频数和度进行排序默认矩阵先按度然后按频率排序 # 定义颜色体系 require(RColorBrewer,quietly T,warn.conflicts F) corlor c(brewer.pal(12,Set3),brewer.pal(12,Paired),brewer.pal(11,Spectral)) require(UpSetR,quietly T,warn.conflicts F) gupset(fromList(list), nsets length(list),setsnames(list),keep.orderkeep.order, number.angles 30, point.size 2.5, line.size 0.20,mb.ratio c(0.55, 0.45), text.scale c(1.5,1, 1.5, 1, 1,1), # 上方条形图的填充颜色 main.bar.colorbar_cor,mainbar.y.label Intersection Size, # 下方条形图的填充颜色 sets.bar.colorcorlor[1:length(list)], matrix.colorpoint_cor, sets.x.label Set Size, order.by order.by,shade.color brewer.pal(9,BuPu)[2], shade.alpha 0.70, matrix.dot.alpha 0.85) return(g)}实战演练03df readFlie(./upset.txt,type txt,row F)# 抽取数据制造测试数据set.seed(1234)df_list list(Symbol1sample(df$symbol,180),Symbol2sample(df$symbol,200), Symbol3sample(df$symbol,220),Symbol4sample(df$symbol,240), Symbol5sample(df$symbol,260),Symbol6sample(df$symbol,280), Symbol7sample(df$symbol,300),Symbol8sample(df$symbol,310), Symbol9sample(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”获取脚本源码和测试数据。参考文献04Lex, 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.微信号mimazilab生物信息学实操 实验操作技能科研绘图技巧 行业动态播报-这里只有干货 扫码关注我们-关注我们了解更多