annotate mytools/Start_GenometriCorr.R @ 9:87eb5c5ddfe9

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