annotate Start_GenometriCorr.R @ 12:2f4ea569f048

Uploaded
author xuebing
date Sat, 10 Mar 2012 08:10:44 -0500
parents b7f1d9f8f3bc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
1 # Start_GenometriCorr.R
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
2
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
3 ###################################################
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
4 # #
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
5 # command-line interface to GenometriCorr #
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
6 # functions, for use with Galaxy. #
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
7 # #
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
8 ###################################################
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
9
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
10 capture.output <- function (result, pdffile, output_options)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
11 {
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
12 if(output_options != "stats")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
13 {
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
14 pdf(file=pdffile, width=10, height=19, paper="special")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
15
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
16 if (output_options != "vis") #need to do a plot
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
17 {
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
18 mymat <- matrix(ncol=3, nrow=4)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
19 mymat[1,1] <- 1
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
20 mymat[1,2] <- 2
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
21 mymat[1,3] <- 3
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
22 mymat[2,1] <- 4
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
23 mymat[2,2] <- 5
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
24 mymat[2,3] <- 6
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
25 mymat[3,1] <- 7
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
26 mymat[3,2] <- 8
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
27 mymat[3,3] <- 9
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
28 mymat[4,1] <- 10
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
29 mymat[4,2] <- 11
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
30 mymat[4,3] <- 12
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
31
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
32 layout(mymat, heights=c(0.2,0.2,0.2,0.2))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
33 plot(result, pdffile, make.new=FALSE)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
34 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
35 if (output_options != "plot") #need to do the bigger graphic
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
36 {
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
37 mymat <- matrix(ncol=2, nrow=8)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
38 mymat[1,1] <- 2
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
39 mymat[1,2] <- 3
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
40 mymat[2,1] <- 4
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
41 mymat[2,2] <- 4
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
42 mymat[3,1] <- 1
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
43 mymat[3,2] <- 1
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
44 mymat[4,1] <- 5
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
45 mymat[4,2] <- 6
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
46 mymat[5,1] <- 7
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
47 mymat[5,2] <- 7
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
48 mymat[6,1] <- 8
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
49 mymat[6,2] <- 9
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
50 mymat[7,1] <- 10
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
51 mymat[7,2] <- 10
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
52 mymat[8,1] <- 11
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
53 mymat[8,2] <- 12
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
54 layoutresults <- 3
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
55
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
56 layout(mymat, heights=c(0.05,0.05,0.15,0.15,0.15,0.15,0.15,0.15))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
57 visualize(result, pdffile, make.new=FALSE)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
58 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
59 dev.off()
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
60 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
61
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
62 if (output_options == "stats")
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
63 {
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
64 show(result)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
65 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
66 }
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
67
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
68
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
69
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
70 # Reads the command line arguments
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
71 args <- commandArgs(trailingOnly=T)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
72
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
73 suppressPackageStartupMessages(library('GenometriCorr', warn.conflicts=F, verbose=F))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
74 suppressPackageStartupMessages(library('graphics', warn.conflicts=F, verbose=F))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
75 suppressPackageStartupMessages(library('gdata', warn.conflicts=F, verbose=F))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
76 suppressPackageStartupMessages(library('gplots', warn.conflicts=F, verbose=F))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
77 suppressPackageStartupMessages(library('gtools', warn.conflicts=F, verbose=F))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
78 suppressPackageStartupMessages(library('caTools', warn.conflicts=F, verbose=F))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
79 suppressPackageStartupMessages(library('grid', warn.conflicts=F, verbose=F))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
80
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
81
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
82
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
83 # Variables
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
84 query_file <- ""
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
85 reference_file <- ""
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
86 config_file <- ""
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
87 output_options <- ""
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
88
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
89 # Parse the command line arguments
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
90
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
91 config_file <- args[1]
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
92 query_file <- as.character(args[2])
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
93 reference_file <- as.character(args[3])
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
94 output_options <- args[4]
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
95 pdffile <- args[5]
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
96
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
97 conf<-new("GenometriCorrConfig",config_file)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
98
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
99 print('OK')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
100
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
101 result<-suppressWarnings(suppressPackageStartupMessages(GenometriCorr:::run.config(conf,query=query_file,reference=reference_file)))
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
102 print('OK2')
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
103
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
104 hideoutput <- capture.output(result, pdffile=args[5], output_options)
b7f1d9f8f3bc Uploaded
xuebing
parents:
diff changeset
105