-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestingAssociations.r
79 lines (76 loc) · 2.97 KB
/
testingAssociations.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
## First is for repeats.
readFilesRepeast <- function(){
effectorClosest<<-list()
secretedClosest<<-list()
noEffClosest<<-list()
noSecClosest<<-list()
fileArray <<- c()
noeffFiles <- list.files(pattern = "*noEffectors.closest")
effectorFiles <- list.files(pattern = "*effectors.closest")
nosecFiles <- list.files(pattern = "*noSecreted.closest")
secretedFiles <- list.files(pattern = "*secreted.closest")
for (i in 1:length(secretedFiles)){
fileArray[i] <<- secretedFiles[i]
print(paste("Processing file: ", secretedFiles[i]))
secreted <- read.table(secretedFiles[i], header=F)
secretedClosest[[i]] <<- secreted
noSec <- read.table(nosecFiles[i], header=F)
noSec <- sample(noSec$V1, length(secreted$V1))
noSecClosest[[i]] <<- noSec
}
for (i in 1:length(effectorFiles)){
print(paste("Processing file: ", effectorFiles[i]))
effectors <- read.table(effectorFiles[i], header=F)
effectorClosest[[i]] <<- effectors
noEff <- read.table(noeffFiles[i], header=F)
noEff <- sample(noEff$V1, length(effectors$V1))
noEffClosest[[i]] <<- noEff
}
}
## Second is for RIPs.
readFilesRIPs <- function(){
effectorClosest<<-list()
secretedClosest<<-list()
noEffClosest<<-list()
noSecClosest<<-list()
fileArray <<- c()
noeffFiles <- list.files(pattern = "*noEffectors.rips.closest")
effectorFiles <- list.files(pattern = "*effectors.rips.closest")
nosecFiles <- list.files(pattern = "*noSecreted.rips.closest")
secretedFiles <- list.files(pattern = "*secreted.rips.closest")
for (i in 1:length(secretedFiles)){
fileArray[i] <<- secretedFiles[i]
print(paste("Processing file: ", secretedFiles[i]))
secreted <- read.table(secretedFiles[i], header=F)
secretedClosest[[i]] <<- secreted
noSec <- read.table(nosecFiles[i], header=F)
noSec <- sample(noSec$V1, length(secreted$V1))
noSecClosest[[i]] <<- noSec
}
for (i in 1:length(effectorFiles)){
print(paste("Processing file: ", effectorFiles[i]))
effectors <- read.table(effectorFiles[i], header=F)
effectorClosest[[i]] <<- effectors
noEff <- read.table(noeffFiles[i], header=F)
noEff <- sample(noEff$V1, length(effectors$V1))
noEffClosest[[i]] <<- noEff
}
}
require("ggplot2")
##Plot data using ggplot2.
plotData<-function(number){
nosec<-data.frame(unlist(noSecClosest[[number]]),
rep("Non-secreted",length(unlist(noSecClosest[[number]]))))
sec<-data.frame(unlist(secretedClosest[[number]]),
rep("Secreted",length(unlist(secretedClosest[[number]]))))
noef<-data.frame(unlist(noEffClosest[[number]]),
rep("Non-effector",length(unlist(noEffClosest[[number]]))))
ef<-data.frame(unlist(effectorClosest[[number]]),
rep("Effector",length(unlist(effectorClosest[[number]]))))
colnames(nosec)<-c("a","b")
colnames(sec)<-c("a","b")
colnames(noef)<-c("a","b")
colnames(ef)<-c("a","b")
datagg<<-rbind(nosec,sec,noef,ef)
ggplot(datagg,aes(b,a)) + xlab("Gene type") + ylab("Distance from nearest repeat") + geom_violin()
}