Mercurial > repos > bornea > dotplot_runner
comparison Dotplot_Release/Step2_data_filtering.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, as.is=T) | |
6 | |
7 d2 = d | |
8 d2s = d | |
9 | |
10 ss_cutoff <- as.numeric(args[2]) | |
11 ### Here I'm only going to take the preys which appeared in at least 2 baits with >args[2] counts | |
12 id = apply(d, 1, function(x) sum(x>ss_cutoff) >= 2) | |
13 id2 = apply(d, 1, function(x) sum(x>ss_cutoff) < 2) | |
14 d2 = d2[id, ] | |
15 d2s = d2s[id2, 0] | |
16 max.d2 = max(as.numeric(as.matrix(d2))) | |
17 d2 = d2 / max.d2 * 10 | |
18 | |
19 d3 = data.frame(PROT = rownames(d2), d2) | |
20 | |
21 outfile <- paste(c(args[3]), "dat", sep=".") | |
22 | |
23 ### The following file is the outcome of running this step. | |
24 write.table(d3, outfile, sep="\t", quote=F, row.names=F) | |
25 ### This is the final input file for nested cluster algorithm | |
26 | |
27 write.table(d2s, "singletons.txt", quote=F) | |
28 |