在之前分享的文章中有这样一张图,文章在10X单细胞(10X空间转录组)之细胞通讯软件之间的分析比较,大家可以看看。

我们来复现一下
下载,加载包
install.packages("UpSetR")
library(UpSetR)
一、输入数据
input = list(
set1 = paste(rep("word_" , 10) , sample(c(1:100) , 10 , replace=F) , sep=""),
set2 = paste(rep("word_" , 20) , sample(c(1:100) , 20 , replace=F) , sep=""),
set3 = paste(rep("word_" , 10) , sample(c(1:100) , 10 , replace=F) , sep=""),
set4 = paste(rep("word_" , 40) , sample(c(1:100) , 40 , replace=F) , sep=""),
set5 = paste(rep("word_" , 50) , sample(c(1:100) , 50 , replace=F) , sep=""))

二、集合图-基础
upset(fromList(input))

三、集合图-参数调整
1 修改排序、坐标系、标签等参数
upset(fromList(input),
order.by = "freq", # 主坐标系排序
number.angles = 0, # 柱标倾角
point.size = 3, # 点大小
line.size = 1, # 线粗细
mainbar.y.label = "Count of Intersection", # y 标题
sets.x.label = "Datasets Size", # x 标题
text.scale = c(1.5, 1, 1.5, 1, 1, 1),
# y 标题 大小
# y 刻度标签 大小
# dataset size 标题 大小
# dataset size 刻度标签 大小
# dataset size 分类标签 大小
# 柱数字 大小
)

2 按数据集排序
upset(fromList(input),
order.by = "freq", # 主坐标系排序
number.angles = 0, # 柱标倾角
point.size = 3, # 点大小
line.size = 1, # 线粗细
mainbar.y.label = "Count of Intersection", # y 标题
sets.x.label = "Datasets Size", # x 标题
text.scale = c(1.5, 1, 1.5, 1, 1, 1),
# y 标题 大小
# y 刻度标签 大小
# dataset size 标题 大小
# dataset size 刻度标签 大小
# dataset size 分类标签 大小
# 柱数字 大小
group.by = "sets", # 按dataset排序
)

四、指定交集上色
upset(fromList(input),
order.by = "freq", # 主坐标系排序
number.angles = 0, # 柱标倾角
point.size = 3, # 点大小
line.size = 1, # 线粗细
mainbar.y.label = "Count of Intersection", # y 标题
sets.x.label = "Datasets Size", # x 标题
text.scale = c(1.5, 1, 1.5, 1, 1, 1),
# y 标题 大小
# y 刻度标签 大小
# dataset size 标题 大小
# dataset size 刻度标签 大小
# dataset size 分类标签 大小
# 柱数字 大小
group.by = "sets", # 按dataset排序
queries = list(
list(query=intersects, params=list("set4", "set5"), color="red", active=T),
list(query=intersects, params=list("set2", "set5"), color="blue", active=T))
# active T 柱染色 F 柱上标记
)

网友评论