annotate Dotplot_Release/Step1_data_reformating.R @ 6:b4bb92033d59 draft default tip

Uploaded
author bornea
date Fri, 29 Jan 2016 10:39:00 -0500
parents dfa3436beb67
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
1 #!/usr/bin/env Rscript
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
2
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
3 args <- commandArgs(trailingOnly = TRUE)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
4
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
5 d = read.delim(args[1], header=T, sep="\t", as.is=T)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
6
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
7 ### Select Prey interactions were at least one Bait > Probability Threshold
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
8
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
9 preylist=unique(c(d$PreyGene[d$BFDR <= as.numeric(args[2])]))
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
10 pid = d$PreyGene %in% preylist
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
11 d = d[pid,]
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
12
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
13 bb = unique(d$Bait)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
14 pp = unique(d$PreyGene)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
15
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
16 nbait = length(bb)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
17 nprey = length(pp)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
18
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
19 ### Reformat the SAINToutput data into a spreadsheet
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
20 mat = matrix(0, nprey, nbait)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
21
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
22 n = nrow(d)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
23 mb = match(d$Bait, bb)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
24 mp = match(d$PreyGene, pp)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
25
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
26 ### Using the AvgSpec for the spectral counts
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
27 for(i in 1:n) {
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
28 mat[mp[i],mb[i]] = d$AvgSpec[i]
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
29 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
30
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
31 rownames(mat) = pp
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
32 colnames(mat) = bb
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
33
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
34 outfile <- paste(c(args[3]), "matrix.txt", sep="_")
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
35 ### The following file is the outcome of running this step.
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
36 write.table(mat, outfile, sep="\t", quote=F)
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
37
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
38
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
39
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
40
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
41