comparison Dotplot_Release/Step1_data_reformating.R @ 0:dfa3436beb67 draft

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