R语言编程
20231005_利用 UpSetR 包进行高效的交集数据可视化
Song Wei
2023年10月5日 22:31
352
UpSetR 是一个 R 语言的包,用于创建 UpSet 图,这是一种用于可视化交集的创新图形。传统的维恩图(Venn图)在处理超过5个集合的交集时会变得复杂且难以阅读。相比之下,UpSetR 通过垂直的条形图来表示交集的大小,可以更好地处理大量的集合交集。
BiocManager::install("UpSetR")
#载入UpSetR包
library(UpSetR)
data <- read.table("final_result_for_upset_plot-ok-2.txt", header=TRUE, sep="\t",row.names = 1 )
head(data)
> head(data)
circbase circpedia riboCIRC transcirc
chr1_24737_24891 1 0 0 0
chr1_324438_324686 1 0 0 0
chr1_586820_586955 0 1 0 0
chr1_632324_632413 0 1 0 0
chr1_667396_667587 1 0 0 0
chr1_667396_675566 1 0 0 0
upset(data, sets = colnames(data), order.by = "freq")
bar_colors = c("red", "black", "black", "red")
upset(data, sets = colnames(data), order.by = "freq",sets.bar.color = bar_colors)
queries = list(
list(
query = intersects,
params = list("circbase","circpedia","riboCIRC","transcirc"),
color = "orange",
active = T
)
)
upset(data,
sets = colnames(data),
order.by = "freq",
sets.bar.color = bar_colors,
queries = queries)
queries = list(
list(
query = intersects,
params = list("circbase","circpedia","riboCIRC","transcirc"),
color = "orange",
active = T
),
list(
query=intersects,
params=c("riboCIRC","transcirc"),
color = "orange",
active = T
)
)
upset(data,
sets = colnames(data),
order.by = "freq",
sets.bar.color = bar_colors,
queries = queries)
upset(data, sets = colnames(data), order.by = "freq", sets.bar.color = bar_colors, queries = queries, point.size = 4, line.size = 1, text.scale = c(1.3, 1.3, 1.3, 1.3, 1.3, 1.5) ,mb.ratio = c(0.65, 0.35) )
# 开始PDF设备
pdf("my_upset_plot.pdf", width = 12, height = 8)
upset(data, sets = colnames(data), order.by = "freq", sets.bar.color = bar_colors, queries = queries, point.size = 4, line.size = 1, text.scale = c(1.3, 1.3, 1.3, 1.3, 1.3, 1.5) ,mb.ratio = c(0.65, 0.35) )
# 关闭PDF设备
dev.off()
标签:
rstudio
北京 天气
晴
0℃