美文网首页生物信息分析
用VennDiagram画Venn图

用VennDiagram画Venn图

作者: 笺牒九州的怪咖 | 来源:发表于2022-03-13 00:27 被阅读0次

两图

venn.plot <- draw.pairwise.venn(  area1 = 80,  #区域1的数 
area2 = 30,   #区域2的数 
cross.area = 2,  #重叠的个数 
category = c("First", "Second"),#分类命名
fill = c("blue", "red"),#1 2 区域分别的填充颜色 
lty = "blank",  #1 2 区域的边框线类型 
cex = 2,        #1 2 区域内部数字的字体大小 
cat.cex = 2,    # 分类名称的字体大小 
cat.dist = 0.09,   #分类名称距离边的距离 实际调整 
cat.just = list(c(-1, -1), c(1, 1)),  #分类名称的位置  ,圈内或者圈外
ext.pos = 30,  #线的角度 默认是正上方12点位置 
ext.dist = -0.05,   #外部线的距离  跟根据圆圈的大小适当调整
ext.length = 0.85,  #外部线长度 
ext.line.lwd = 2,  #外部线的宽度 
ext.line.lty = "dashed" )  #外部线为虚线);
grid.draw(venn.plot)

三图

venn.plot <- draw.triple.venn(
area1 = 80,
area2 = 70,
area3 = 50,
n12 = 38,
n23 = 18,
n13 = 28,
n123 = 8,
category = c("First", "Second", "Third"),
fill = c("blue", "red", "green"),
lty = "blank",
cex = 2,
cat.cex = 2,
cat.col = c("blue", "red", "green"))
grid.draw(venn.plot)

四图

A <- sample(1:1000, 500, replace = FALSE);
B <- sample(1:1000, 600, replace = FALSE);
C <- sample(1:1000, 700, replace = FALSE);
D <- sample(1:1000, 800, replace = FALSE);
E <- sample(1:1000, 900, replace = FALSE);
venn.plot <- venn.diagram(#数据列表
x = list(A = A,B = B,C = C,D = D),
filename = "Venn_4set.png",    #保存文件名
col = "transparent",      #指定图形的圆周边缘颜色  transparent 透明          
fill = c("blue", "green", "yellow", "grey50"),  #填充颜色
alpha = 0.50,     #透明度
label.col = c("orange", "white", "grey50", "white","white", "white", "white", "white", "darkblue", "white","white", "white", "white", "darkgreen", "white"),
cex = 1.2,    #每个区域label名称的大小
cat.col = c("darkblue", "darkgreen", "orange", "grey50"),  #分类颜色
cat.cex = 1.2,      #每个分类名称大小
cat.dist = 0.07,   
cat.pos = 0,        #
cat.fontfamily = "serif",     #分类字体
rotation.degree = 0,        #旋转角度
margin = 0.2 )   
Venn_4set.png

五图

venn.plot <- venn.diagram( 
x = list(    A = A,    B = B,    C = C,    D = D,    E = E  ), 
filename = "Venn_5set.png", 
col = "black", 
fill = c("dodgerblue", "goldenrod1", "darkorange1", "seagreen3", "orchid3"), 
alpha = 0.50, 
cat.col = c("darkblue", "darkgreen", "orange", "grey50","purple"), 
cat.cex = 1.5, 
cat.fontface = "bold", 
margin = 0.05);
Venn_5set.png

画PDF格式

#将filename设置成NULL
#将画出来的图先保存到venn.plot中
venn.plot <- venn.diagram(
  x = list (
    A = 1:10,
    B = 6:25
  ),  
  cat.col=c("red","blue"),
  fill = c("red","blue"),
  filename = NULL
)

#将venn.plot通过grid.draw画到pdf文件中
pdf("venn.pdf")
grid.draw(venn.plot)
dev.off()
venn.pdf

导出Venn图的list

dat <- read.table('TEST.list', header = TRUE, sep = '\t',na.strings = "")  #有2列数据
venn.diagram(dat, filename = 'TEST.venn.png', imagetype = 'png', fill = c('red', 'blue'), alpha = 0.50, cat.col = rep('black', 1),col = 'grey', cex = 1.0,   fontfamily = 'serif',cat.cex = 1.0, cat.dist = 0.01,cat.just = list(c(-0.25, -0.25), c(1, 1)), cat.fontfamily = 'serif')
inter1 <- get.venn.partitions(dat)
for (i in 1:nrow(inter1)) inter1[i,'values'] <- paste(inter1[[i,'values']], collapse = ', ')
write.table(inter1[-c(3, 4)], 'TEST_venn_inter.txt', row.names = FALSE, sep = '\t', quote = FALSE)    #将Venn数据追加到第3和第4列
TEST.venn.png

TEST_venn_inter.txt:


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------I'm a line ! Thanks !---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

相关文章

  • 用VennDiagram画Venn图

    两图 三图 四图 五图 画PDF格式 导出Venn图的list TEST_venn_inter.txt: ----...

  • VennDiagram包画venn图

    VennDiagram包提供了2到5个集合的绘图函数:包括绘制两个集合的韦恩图的draw.pairwise.ven...

  • R IN ACTION SELF-TUTORIAL-68 用gg

    问题:发现之前用library(VennDiagram)绘制的venn图没法用来与ggplot绘制的图进行组合pa...

  • 2019-04-01

    画相关性分析图的韦恩图部分:使用VennDiagram包最普通的功能是venn.diagram(),输入的是向量(...

  • R语言:VennDiagram绘制venn图

    导读 使用VennDiagram函数包中的venn.diagram函数绘制三数据集venn图。 安装依赖包: 一、...

  • R 画韦恩图

    调用包 VennDiagram 两个集的韦恩图 四个集的韦恩图 venn.diagram()画韦恩图 当前路径下生...

  • R绘制韦恩图

    目前做Venn图的R包中,VennDiagram是常用的包,可以做2元到5元的图。下面介绍一下2元到5元venn图...

  • 【R画图学习6.1】Venn图---VennDiagram

    这2天我们系统的学习一些画venn图的一些技巧。我们今天先测试这个最常用的包VennDiagram。 librar...

  • Venn--VennDiagram

    报错:执行结束后没有产生想要的结果 原因分析:G1和F1是df格式,不是value格式。使用venn.diagra...

  • R:韦恩图可视化

    画韦恩图,常见的如下。 常见的R包比如gplots、venneuler、VennDiagram等最多只能画5元。 ...

网友评论

    本文标题:用VennDiagram画Venn图

    本文链接:https://www.haomeiwen.com/subject/fcwldrtx.html