-
Notifications
You must be signed in to change notification settings - Fork 0
/
09.venn.R
39 lines (33 loc) · 1.33 KB
/
09.venn.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
library(randomcoloR)
library(venn)
A="LASSO"
B="RandomForest"
C="SVM-REF"
geneList=list()
rt=read.table(paste0(A,".txt"),header=F,sep="\t",check.names=F)
geneNames=as.vector(rt[,1])
geneNames=gsub("^ | $","",geneNames)
uniqGene=unique(geneNames)
geneList[[A]]=uniqGene
uniqLength=length(uniqGene)
print(paste("1",uniqLength,sep=" "))
rt=read.table(paste0(B,".txt"),header=F,sep="\t",check.names=F)
geneNames=as.vector(rt[,1])
geneNames=gsub("^ | $","",geneNames)
uniqGene=unique(geneNames)
geneList[[B]]=uniqGene
uniqLength=length(uniqGene)
print(paste("3",uniqLength,sep=" "))
rt=read.table(paste0(C,".txt"),header=F,sep="\t",check.names=F)
geneNames=as.vector(rt[,1])
geneNames=gsub("^ | $","",geneNames)
uniqGene=unique(geneNames)
geneList[[C]]=uniqGene
uniqLength=length(uniqGene)
print(paste("3",uniqLength,sep=" "))
mycol <- distinctColorPalette(3)
pdf(file="hub.pdf",width=5,height=5)
venn(geneList,col=mycol[1:length(geneList)],zcolor=mycol[1:length(geneList)],box=F)
dev.off()
intersectGenes=Reduce(intersect,geneList)
write.table(file="hub.txt",intersectGenes,sep="\t",quote=F,col.names=F,row.names=F)