# 目录

#### R语言之可视化⑥R图形系统续

======================================

#### Python数据处理从零开始----第四章（可视化）（5）（韦恩图）

======================================

# 正文

### 第一种：定义数据集后直接画图取交集

``````library(UpSetR)
library(dplyr)
library(tidyr)
rm(list=ls())
``````

``````AA <- subset(diff, splice_type=="AA")
AP <- subset(diff, splice_type=="AP")
AT <- subset(diff, splice_type=="AT")
``````

``````#fromList
AP = AP\$symbol,
AA = AA\$symbol,
AT = AT\$symbol)

library(UpSetR)
# pdf(file='upset.pdf',height = 8,width = 8)
p <- upset(fromList(listinput),nsets = 4, order.by = "freq")
# dev.off()
``````

### 第二种：取交集后在画图

``````setwd("E:\\Rwork")
library(UpSetR)
require(ggplot2);
require(plyr);
require(gridExtra);
require(grid);
input <- c(
'cancer1'=  1578,
'cancer2' =  1284,
'cancer3' = 2488,
'cancer1&cancer2'  =205,
'cancer1&cancer3'  = 828,
'cancer2&cancer3'  =589,
'cancer1&cancer2&cancer3'   =120
)

data <- fromExpression(input)
p1 <- upset(data, nsets = 9,
sets = c('cancer1',
'cancer2' ,
'cancer3'),
keep.order = TRUE,
# number.angles = 30,
point.size = 5,
line.size = 1.3,
mainbar.y.label = "IntersectionSize",
sets.x.label = "",
mb.ratio = c(0.60, 0.40),
text.scale = c(4, 4, 0.5, 0.5,3, 4))

p1
``````