R学习

韦恩图

2020-02-24  本文已影响0人  生信编程日常

1.VennDiagram做韦恩图

library(VennDiagram)
venn_list <- list(geneset1, geneset2,geneset3,geneset4)
names(venn_list) <- c('RNAseq_up','RNAseq_down','scRNAseq_up','scRNAseq_down')
venn.diagram(venn_list, filename = 'venn.png', imagetype = 'png', margin = 0.2, 
    fill = c('red', 'blue','yellow','green'), alpha = 0.30, col = 'black', cex = 1, fontfamily = 'serif', cat.cex = 1, cat.fontfamily = 'serif')

46891581143372_.pic_hd.jpg

常用参数
col :边框颜色
lwd :边框线宽度
fill :填充颜色
alpha:透明度
cex :标签字体大小
cat.cex :字体大小
margin:边际距离

韦恩图不支持pdf格式,想导出pdf的话:

venn<-venn.diagram(venn_list, margin = 0.2, filename = NULL,
    fill = c("#F8766D", "#00BFC4","#C77CFF","#7CAE00"), alpha = 0.50, col = 'black', cex = 1, fontfamily = 'serif', cat.cex = 1, cat.fontfamily = 'serif')
pdf(file="venn_plot.pdf")
grid.draw(venn)
dev.off()

2.UpSetR做韦恩图

library(UpSetR)
listInput <- list(one = c(1, 2, 3, 5, 7, 8, 11, 12, 13), two = c(1, 2, 4, 5, 
    10), three = c(1, 5, 6, 7, 8, 9, 10, 12, 13))
upset(fromList(listInput), order.by = "freq", sets.bar.color = "grey")
image.png

3.venn做韦恩图

venn(x, snames = "", counts, ilabels = FALSE, ellipse = FALSE,
zcolor = "bw", opacity = 0.3, plotsize = 15, ilcs = 0.6, sncs = 0.85,
borders = TRUE, box = TRUE, par = TRUE, ggplot = FALSE, ...)

主要参数:
x:输入的list
snames :每个集合的名称
ilabels :显示交集的标签
ellipse:将形状改为椭圆
zcolor:颜色
opacity :不透明度
cexil :字体大小
cexsn :集合名称标签的字体大小

install.packages("venn") #安装
library(venn) #导入
venn(listInput, zcolor = "style", cexil = 1, cexsn = 0.8) 
# zcolor = "style设置默认的颜色风格, cexil = 1把交集区域数值标签字体改大到1,cexsn集合名称标签字体大小
image.png

设置ellipse = TRUE,将形状强制为椭圆。

venn(listInput, ellipse = TRUE, zcolor = "style", cexil = 1, cexsn = 1)
image.png

欢迎关注~


公众号二维码.jpg

参考:

https://github.com/hms-dbmi/UpSetR
https://nachtzug.xyz/2019/01/19/venn-diagram-with-R-venn-package/

上一篇下一篇

猜你喜欢

热点阅读