annotate fingerprint.r @ 0:0cebe436a553 draft default tip

Initial upload.
author hackdna
date Fri, 17 May 2013 14:29:33 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
1 #!/usr/bin/env Rscript
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
2
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
3 #sink(file("/dev/null", "w"), type = "message");
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
4
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
5 library(affy)
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
6 library(GEOquery);
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
7 library(pathprint);
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
8
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
9 # Figure out the relative path to the galaxy-pathprint.r library.
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
10 script.args <- commandArgs(trailingOnly = FALSE);
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
11 script.name <- sub("--file=", "", script.args[grep("--file=", script.args)])
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
12 script.base <- dirname(script.name)
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
13 library.path <- file.path(script.base, "galaxy-pathprint.r");
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
14 source(library.path)
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
15
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
16 data(GEO.metadata.matrix);
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
17
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
18 usage <- function() {
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
19 sink(stderr(), type = "message");
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
20 stop("Usage: fingerprint.r [ARGS]", call. = FALSE)
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
21 }
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
22
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
23 ## Get the command line arguments.
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
24 args <- commandArgs(trailingOnly = TRUE)
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
25
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
26 type <- ifelse(! is.na(args[1]), args[1], usage())
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
27
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
28 if (type == "geo") {
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
29 geoID <- ifelse(! is.na(args[2]), args[2], usage());
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
30 output <- ifelse(! is.na(args[3]), args[3], usage());
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
31
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
32 fingerprint <- generateFingerprint(geoID);
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
33 } else if (type == "cel") {
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
34 input <- ifelse(! is.na(args[2]), args[2], usage());
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
35 output <- ifelse(! is.na(args[3]), args[3], usage());
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
36
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
37 fingerprint <- loadFingerprintFromCELFile(input);
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
38 } else if (type == "expr") {
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
39 input <- ifelse(! is.na(args[2]), args[2], usage());
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
40 platform <- ifelse(! is.na(args[3]), args[3], usage());
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
41 output <- ifelse(! is.na(args[4]), args[4], usage());
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
42
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
43 fingerprint <- loadFingerprintFromExprsFile(input, platform);
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
44 } else {
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
45 usage();
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
46 };
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
47
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
48 saveFingerprint(fingerprint, output);
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
49
0cebe436a553 Initial upload.
hackdna
parents:
diff changeset
50 quit("no", 0)