很全的路由器默认初始密码集合.txt_UpSet——集合关系可视化神器
學習更多生信小技巧,點上方藍字關注我們
分析背景
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/") # 自定義函數## 快速讀入數據readFlie=function(input,type,row=T,header=T){ # input 為讀入文件的路徑,type為讀入文件的類型,格式為‘.txt’或‘.csv’,row=T,將文件的第一列設置為列名 library(data.table,quietly = TRUE) if(type=='txt'){ 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_upset=function(list,bar_cor='lightblue2',point_cor = 'blue',keep.order=F,order.by=c("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) g=upset(fromList(list), nsets = length(list),sets=names(list),keep.order=keep.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.color=bar_cor,mainbar.y.label = "Intersection Size", # 下方條形圖的填充顏色 sets.bar.color=corlor[1:length(list)], matrix.color=point_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)}實戰演練
03
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”,獲取腳本源碼和測試數據。參考文獻
04
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.
微信號:mimazilab
生物信息學實操 實驗操作技能
科研繪圖技巧? 行業動態播報
-這里只有干貨 掃碼關注我們-
關注我們,了解更多總結
以上是生活随笔為你收集整理的很全的路由器默认初始密码集合.txt_UpSet——集合关系可视化神器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 查询手机号段对应地区编码_2020陕西专
- 下一篇: 判别分析分为r型和q型吗_电流互感器天天