跳转至

画韦恩图,常见的如下。 image.png image.png 对于已经司空见惯的veen图,审稿人也是审美疲劳了。那就换一个让他眼前一亮的veen图。 image.png image.png 目前数据不完善,计划做6元Veen图。数据没凑齐,暂时不做。 参考链接1 参考链接2 参考链接3 参考链接4

常见的R包比如gplots、venneuler、VennDiagram等最多只能画5元。

R包venn,它能绘制6元、7元韦恩图。 R包UpSetR,是做出上述点线图格式的工具。

#演示数据
install.packages("UpSetR")
library("UpSetR")
require(ggplot2); require(plyr); require(gridExtra); require(grid);
movies <- read.csv(system.file("extdata","movies.csv",package = "UpSetR"), header = TRUE, sep=";")
upset(movies, nsets = 7, nintersects = 30, mb.ratio = c(0.5, 0.5),
      order.by = c("freq", "degree"), decreasing = c(TRUE,FALSE))

image.png

常规韦恩图使用VennDiagram包。

三元韦恩图

m17 <- read.csv("m17_4g.dsg2.csv")
e28 <- read.csv("e28_4g.dsg2.csv")
m17_e28 <- read.csv("m17_e28_deg.csv",header = TRUE)
m17 <- as.vector(unlist(m17[1]))
e28 <- as.vector(unlist(e28[1]))
m17_e28 <- as.vector(unlist(m17_e28[1]))

#主要是获取对应的差异表达基因,转换成向量。

#veen.diagram中变量名称不能使用-,否则会报错。变量名要求是字母开头。
venn.plot <- venn.diagram(
    x = list(
      Mo17_DY13 = m17,       #对应三个元的,前面是图中显示字符,后面是实际变量
      E28_DY13 = e28,
      Mo17_E28 = m17_e28
    ),
    filename = "DY13.tiff",  #输出的文件名
    col = "transparent",
    fill = c("red", "blue", "green"),  #各个圈圈的颜色
    alpha = 0.5,  #透明度
    label.col = c("darkred", "white", "darkblue", "white",
                  "white", "white", "darkgreen"),
    cex = 2.5,
    fontfamily = "serif",
    fontface = "bold",
    cat.default.pos = "text",  #此处默认是标签在圆内部
    cat.col = c("darkred", "darkblue", "darkgreen"),
    cat.cex = 2.5,
    cat.fontfamily = "serif",
    cat.dist = c(0.06, 0.06, 0.03),
    cat.pos = 0
  )

标签在圆内部的三元韦恩图

标签在圆圈外面的代码

venn.plot <- venn.diagram(
    x = list(
      Mo17_DY13 = m17,
      E28_DY13 = e28,
      Mo17_E28 = m17_e28
    ),
    filename = "DY13.tiff",
    col = "transparent",
    fill = c("red", "blue", "green"),
    alpha = 0.5,
    label.col = c("darkred", "white", "darkblue", "white",
                  "white", "white", "darkgreen"),
    cex = 2.5,#内标签的字体大小
    fontfamily = "serif",
    fontface = "bold",
    cat.default.pos = "outer",#设置标签在圆外面
    #cat.col = c("darkred", "darkblue", "darkgreen"),
    cat.cex = 2,#外标签的字体大小
    cat.fontfamily = "serif",
    cat.dist = c(0.05, 0.05, 0.05),#相对圆圈的位置
    cat.pos = c(-20,20,180)  #相对12点方向旋转的角度
  )

标签在圆外面的三元韦恩图

回到页面顶部