R語(yǔ)言繪制VENN圖(VennDiagram包的使用)
#下載包
install.packages("VennDiagram")
install.packages("openxlsx")
# 加載R包,沒(méi)有安裝請(qǐng)先安裝
library(VennDiagram)
library(openxlsx)
#讀取工作目錄
getwd()
#設(shè)定工作目錄
setwd("C:/Users/LD/Desktop/VENN")
#數(shù)據(jù)讀取
VENN_1<-read.xlsx("C:/Users/LD/Desktop/VENN/chengfen.xlsx")
dim(VENN_1) #驗(yàn)證數(shù)據(jù)中行跟列
VENN_2<-read.xlsx("C:/Users/LD/Desktop/VENN/jibing.xlsx")
dim(VENN_2)
#列表制作
a<-list(A=VENN_1$gene,
? ? ? ? B=VENN_2$gene)
fill.col<-c("#0055AA","#C40003") #顏色填充
venn.diagram(x=a,
? ? ? ? ? ? ?scaled = F,#兩個(gè)圓圈一樣大小 scaled = T時(shí)按照內(nèi)部數(shù)量比例來(lái)畫(huà)圈的大小
? ? ? ? ? ? ?filename = "venn.tiff", #命名
? ? ? ? ? ? ?cex=2, #區(qū)域內(nèi)部數(shù)字的字體大小,即個(gè)數(shù)的字體
? ? ? ? ? ? ?cat.cex = 1.5, #分類(lèi)名稱(chēng)的字體大小,即組別的字體
? ? ? ? ? ? ?cat.pos = c(3,-3), #分類(lèi)名稱(chēng)在圓的什么位置
? ? ? ? ? ? ?fill=fill.col)
#取出交集的內(nèi)容
inter <- get.venn.partitions(a) #get.venn.partitions獲得韋恩圖結(jié)果
下面再放一下VennDiagram包的設(shè)置,還有很多命令沒(méi)有使用
area1 The size of the first set
area2 The size of the second set
area3 The size of the third set
area4 The size of the fourth set
cross.area The size of the intersection between the sets
category A vector (length 2) of strings giving the category names of the sets
euler.d Boolean indicating whether to draw Euler diagrams when conditions are met or
not (Venn Diagrams with moveable circles)
scaled Boolean indicating whether to scale circle sizes in the diagram according to set
sizes or not (euler.d must be true to enable this)
inverted Boolean indicating whether the diagram should be mirrored long the vertical
axis or not
ext.text Boolean indicating whether to place area labels outside the circles in case of
small partial areas or not
ext.percent A vector (length 3) indicating the proportion that a partial area has to be smaller
than to trigger external text placement. The elements allow for individual control
of the areas in the order of area1, area2 and intersect area.
lwd A vector (length 2) of numbers giving the line width of the circles’ circumferences
lty A vector (length 2) giving the line dash pattern of the circles’ circumferences
col A vector (length 2) giving the colours of the circles’ circumferences
fill A vector (length 2) giving the colours of the circles’ areas
alpha A vector (length 2) giving the alpha transparency of the circles’ areas
label.col A vector (length 3) giving the colours of the areas’ labels
cex A vector (length 3) giving the size of the areas’ labels
fontface A vector (length 3) giving the fontface of the areas’ labels
fontfamily A vector (length 3) giving the fontfamily of the areas’ labels
cat.pos A vector (length 2) giving the positions (in degrees) of the category names along
the circles, with 0 (default) at the 12 o’clock location
cat.dist A vector (length 2) giving the distances (in npc units) of the category names
from the edges of the circles (can be negative)
cat.cex A vector (length 2) giving the size of the category names
cat.col A vector (length 2) giving the colours of the category names
cat.fontface A vector (length 2) giving the fontface of the category names
cat.fontfamily A vector (length 2) giving the fontfamily of the category names
cat.just List of 2 vectors of length 2 indicating horizontal and vertical justification of
each category nam