Closed ixxmu closed 8 months ago
主要是本文代码还可以出venn图的excel表格,在文末。
大家好,是不是有时候你画韦恩图的网页工具画出来的图特别丑,就像这样,标签都看不到,或者在圆圈里面:
假如我们有三个list,或者向量、数据框也可以,list内容分别是m6a-seq的差异基因,RIP-seq的差异基因和 genecards中的你的目的基因集
gene_cards <- data.frame(`Gene Symbol` = c("BRCA1", "TP53", "EGFR", "ERBB2", "KRAS", "BRAF", "ALK", "RET", "ROS1"),
`Gene Description` = c("Breast cancer 1", "Tumor protein p53", "Epidermal growth factor receptor", "Erb-B2 receptor tyrosine kinase 2", "Kirsten rat sarcoma viral oncogene homolog", "B-Raf proto-oncogene, serine/threonine kinase", "Anaplastic lymphoma receptor tyrosine kinase", "Ret proto-oncogene", "ROS proto-oncogene 1, receptor tyrosine kinase"),
stringsAsFactors = FALSE)
Rip_seq <- c("BRCA1", "TP53", "EGFR", "AKT1", "MTOR", "CCND1", "MYC")
m6A_seq <- c("BRCA1", "TP53", "EGFR", "ERBB2", "KRAS", "BRAF", "AKT1", "MTOR", "CCND1", "MYC")
genecards_intersect_with_m6a_rip <- Reduce(intersect, list(gene_cards$`Gene.Symbol`, Rip_seq, m6A_seq))
print(genecards_intersect_with_m6a_rip)
VennDiagram要求的输入数据就是list
# 韦恩图
library(VennDiagram)
venn_list <- list('Genecards' = gene_cards$`Gene.Symbol`,
'm6A_seq' = m6A_seq, 'Rip_seq' = Rip_seq)
venn_list
venn.diagram(venn_list, filename = 'venn2.png', imagetype = 'png',
fill = c('red', 'blue','green'), alpha = 0.30,
#cat.col = rep('black', 3),
# col = 'black',
cex = 1.5, # 设置文本标签大小
fontfamily = "serif", # 设置文本标签的字体
fontface = "bold", # 设置文本标签的字体加粗
cat.col = c("red", "darkblue", "darkgreen" ), # 设置类别标签的颜色
cat.cex = 1 , # 设置类别标签大小
# cat.pos = 0, # 设置类别标签的位置
cat.pos = c(-60,60,180) , # 设置类别标签的位置 (1,2,3,4,5 numeric Vector giving the position (in degrees) of each category name along the circle, with 0 at 12 o'clock)
margin = 0.08 #调整标签距离最边缘的位置
)
这个excel可以放在你的补充材料里,知道不同集合交集的结果是什么
inter <- get.venn.partitions(venn_list)
for (i in 1:nrow(inter)) inter[i,'values'] <- paste(inter[[i,'..values..']], collapse = ', ')
#write.table(inter[-c(5, 6)] , 'venn_inter.txt', row.names = FALSE, sep = '\t', quote = FALSE)
for (i in 1:nrow(inter)) inter[i,'values'] <- paste(inter[[i,'..values..']], collapse = ', ')
openxlsx::write.xlsx(inter[-c(5, 6)], 'venn_inter.xlsx', row.names = FALSE, sep = ',', quote = FALSE)
https://mp.weixin.qq.com/s/v7HJ0AWW-IEhArJREkSuIw