-
Notifications
You must be signed in to change notification settings - Fork 0
/
venn_venn.diagram.R
47 lines (44 loc) · 1.52 KB
/
venn_venn.diagram.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/Rscript
args <-commandArgs(TRUE)
if(length(args) != 1){
cat("Your input file error...please try below Example\n")
stop("
Example:
Draw_Box_Plot.R infile \n
")
}
library(reshape2)
library(VennDiagram)
#All_fullname_file <- dir('./*',pattern = NULL,all.files = FALSE,full.names = TRUE,recursive = TRUE)
All_fullname_file1<-Sys.glob(file.path(args[1],'*.xls'),dirmark =FALSE)
if(length(All_fullname_file1)>6){
stop('Can not Draw plot out of six dimension')
}
mydata_list<-NULL
samplecor<-NULL
x <- character()
y <- character()
for(i in 1:length(All_fullname_file1)){
cat(paste('basename->',basename(All_fullname_file1[i]),'\n',sep=''))
samplename=sub('[.]DEG[.]final[.]xls','',basename(All_fullname_file1[i]))
if(nchar(samplename)>=5){
x[i]<-samplename
samplename=paste('DEG_',LETTERS[i])
y[i]<-samplename
#samplecor$Plotting_name[i]<-samplename
}
tempdata=read.delim(All_fullname_file1[i],
header=F,sep = '\t',
stringsAsFactors = F,check.names = F,
quote='',skip = 1)
mydata_list[[samplename]]<-tempdata[,1]
}
###write correspondent table
samplecor<-data.frame(DEG_group=x,Plotting_name=y)
write.table(samplecor,file='correspondenc.txt',quote=F,sep='\t',row.names = F,col.names = T)
venn_plot<-venn.diagram(x=mydata_list,main='Venn Draw',
filename = 'venn.tiff',
fill=rainbow(length(mydata_list)),
fontfamily = "serif",
fontface = 1,
alpha=0.1,cex=1,cat.cex=1,margin = 0.5)