欢迎光临散文网 会员登陆 & 注册

R语言绘制VENN图(VennDiagram包的使用)

2023-07-10 14:10 作者:小丑鱼在淡水  | 我要投稿

#下载包

install.packages("VennDiagram")

install.packages("openxlsx")

# 加载R包,没有安装请先安装

library(VennDiagram)

library(openxlsx)

#读取工作目录

getwd()

#设定工作目录

setwd("C:/Users/LD/Desktop/VENN")

#数据读取

VENN_1<-read.xlsx("C:/Users/LD/Desktop/VENN/chengfen.xlsx")

dim(VENN_1) #验证数据中行跟列

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,#两个圆圈一样大小 scaled = T时按照内部数量比例来画圈的大小

             filename = "venn.tiff", #命名

             cex=2, #区域内部数字的字体大小,即个数的字体

             cat.cex = 1.5, #分类名称的字体大小,即组别的字体

             cat.pos = c(3,-3), #分类名称在圆的什么位置

             fill=fill.col)

#取出交集的内容

inter <- get.venn.partitions(a) #get.venn.partitions获得韦恩图结果



下面再放一下VennDiagram包的设置,还有很多命令没有使用


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


R语言绘制VENN图(VennDiagram包的使用)的评论 (共 条)

分享到微博请遵守国家法律