library(dplyr)
library(stringr)
setwd("D:\workspace\ouyang\七七八八\基因求交集20241116")
data1 <- read.csv("miRDB.汇总.csv",header=T,stringsAsFactors = FALSE)
data2 <- read.csv("Target scan汇总1.csv",header=T,stringsAsFactors = FALSE)
data1 <- read.table("clipboard",header = T,sep="\t" ,stringsAsFactors = F)
data2 <- read.table("clipboard",header = T,sep="\t" ,stringsAsFactors = F)
data1 %>% head()
data2 %>% head()
colnames(data1)[1] <- c("miR.669d.5p")
colnames(data1) <- gsub("\.","-",colnames(data1))
colnames(data1)
colnames(data2)[1] <- "miR.592.5p"
colnames(data2) <- gsub("\.","-",colnames(data2))
colnames(data2)
data2 <- data2[,c("miR-669d-5p", "miR-3057-5p", "miR-26b-3p", "miR-7010-5p",
"miR-592-5p")]
str(data1)
str(data2)
data1 %>% head()
data2 %>% head()
library(VennDiagram)
绘制 Venn 图
for(i in c(1:length(colnames(data1)))){
png(paste0('Venn_plot_', colnames(data1)[i],'.png'),,width =4 ,height = 4, res = 400, units = "in")
pdf(paste0('Venn_plot_', colnames(data1)[i],'.pdf'),width =4 ,height = 4)
venn.plot <-
draw.pairwise.venn(
area1 = length(data1[,i] %>% as.character() %>%
na.omit() %>% unique()%>% #去掉NA
.[. != ""]), #去掉“”空白字符
area2 = length(data2[,i] %>% as.character() %>% na.omit() %>% unique()%>% .[. != ""]),
cross.area = length(intersect(data1[,i] %>% as.character() %>% na.omit() %>% unique() %>% .[. != ""],
data2[,i] %>% as.character() %>% na.omit() %>% unique()%>% .[. != ""])),
category = c(paste0("miRDB.",colnames(data1)[i]), paste0("Target.",colnames(data2)[i])),
fill = c('#FFB6C1', "#E1FFFF"),
alpha = 0.5,
cex = 1.5,
cat.cex = 0.7,
cat.pos = c(0, 0),
cat.dist = c(0.05, 0.05),
scaled = T ,
lwd = 2
)
print(venn.plot)
dev.off()
}