annotate RnBeadsGalaxy.R @ 9:68db09d2e2a4 draft

Deleted selected files
author pavlo-lutsik
date Thu, 18 Apr 2013 07:38:46 -0400
parents 7bc6e673c8e8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
1 library(RnBeads)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
2 library(getopt)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
3
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
4
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
5
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
6 #all.opts<-names(rnb.options())
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
7 opt.class<-RnBeads:::OPTION.TYPES[-28]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
8 all.opts<-names(opt.class)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
9 #all.opts<-paste("--", all.opts, sep="")
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
10 #all.opts<-gsub("\\.([a-z])", "\\U\\1", all.opts, perl=TRUE)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
11 all.opts<-gsub("\\.","-", all.opts)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
12 #opt.class<-sapply(rnb.options(), class)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
13
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
14 rnb.opt.spec<-data.frame(
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
15 Long=all.opts,
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
16 Short=as.character(1:length(all.opts)),
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
17 Mask=c(1,2)[as.integer((opt.class=="logical"))+1],
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
18 Type=opt.class)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
19
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
20 ### automated xml file preparation
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
21 #xml.strings<-apply(rnb.opt.spec,1, function(row){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
22 #
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
23 # opt.lab<-gsub("-", ".", row[1])
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
24 # opt.def.val<-rnb.getOption(opt.lab)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
25 # opt.name<-gsub("-([0-9a-z])", "\\U\\1", row[1], perl=TRUE)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
26 # tf.opt<-"\t\t\t<option value=\"True\">True</option>\n\t\t\t<option value=\"False\">False</option>"
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
27 # opt.lab<-paste(opt.lab, gsub("\\."," ", row[4]), sep=", ")
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
28 # if(row[4]=="logical"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
29 # opt.type<-'select'
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
30 # if(!is.null(opt.def.val) && opt.def.val)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
31 # opt.def.val<-"1" else
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
32 # opt.def.val<-"0"
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
33 # string<-sprintf("\t\t<param name=\"%s\" type=\"%s\" label=\"%s\" value=\"%s\">\n%s\n\t\t</param>\n", opt.name, opt.type, opt.lab, opt.def.val, tf.opt)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
34 # }else{
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
35 # opt.type<-'text'
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
36 # if(!is.null(opt.def.val) && opt.def.val!="")
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
37 # opt.def.val<-paste(opt.def.val, collapse=",") else
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
38 # opt.def.val<-""
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
39 # string<-sprintf("\t\t<param name=\"%s\" type=\"%s\" label=\"%s\" value=\"%s\"/>\n", opt.name, opt.type, opt.lab, opt.def.val)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
40 # }
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
41 # string
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
42 # })
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
43 #
8
7bc6e673c8e8 Uploaded
pavlo-lutsik
parents: 7
diff changeset
44 #cat(xml.strings, sep="", file="automated.settings.xml.txt")
7
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
45 #
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
46 #opt.def.strings<-apply(rnb.opt.spec,1, function(row){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
47 #
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
48 # opt.name<-gsub("-([0-9a-z])", "\\U\\1", row[1], perl=TRUE)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
49 # opt.long<-row[1]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
50 # opt.short<-row[2]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
51 #
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
52 # if(row[4]=="logical"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
53 # def.string<-sprintf("#if str( $options.%s ) == \"True\"\n\t--%s\n#end if\n", opt.name, opt.long)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
54 # }else{
8
7bc6e673c8e8 Uploaded
pavlo-lutsik
parents: 7
diff changeset
55 # def.string<-sprintf("#if str( $options.%s ) != \"\"\n\t--%s=\"$options.%s\" \n#end if\n", opt.name, opt.long, opt.name)
7
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
56 # }
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
57 # def.string
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
58 #
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
59 # })
8
7bc6e673c8e8 Uploaded
pavlo-lutsik
parents: 7
diff changeset
60 #cat(opt.def.strings, sep="", file="automated.option.assignments.txt")
7
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
61
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
62
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
63 rnb.opt.spec$Type<-gsub("\\.vector", "", rnb.opt.spec$Type)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
64 rnb.opt.spec$Type<-gsub("numeric", "double", rnb.opt.spec$Type)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
65 rnb.opt.spec<-rbind(data.frame(
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
66 Long=c("data-type", "pheno", "idat-dir","idat-files","bed-files", "gs-report", "geo-series", "betas", "pvals","report-dir"),
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
67 Short=c("d","s","a","i","f","g","e","b","p","r"),
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
68 Mask=c(1,2,2,2,2,2,2,2,2,1),
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
69 Type=c("character","character","character","character","character","character","character","character","character","character")),
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
70 rnb.opt.spec)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
71
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
72 opts<-getopt(as.matrix(rnb.opt.spec))
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
73 #opts<-getopt(as.matrix(rnb.opt.spec), opt=list("--data-type=idats","--report-dir=dir", "--idats=file1\tfile2"))
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
74 print(opts)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
75
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
76 if(opts[["data-type"]]=="idatDir"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
77
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
78 data.source<-list()
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
79 data.type<-"idat.dir"
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
80 data.source[["idat.dir"]]<-opts[["idat-dir"]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
81 data.source[["sample.sheet"]]<-opts[["pheno"]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
82
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
83 }else if(opts[["data-type"]]=="idatFiles"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
84
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
85 data.type<-"idat.dir"
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
86 files<-strsplit(opts[["idat-files"]], "\t")[[1]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
87 idat.dir<-mkdir(file.path(opts[["report-dir"]], "idats"))
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
88 file.copy(as.list(files), idat.dir)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
89 data.source<-list()
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
90 data.source[["idat.dir"]]<-idat.dir
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
91 data.source[["sample.sheet"]]<-opts[["pheno"]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
92
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
93
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
94 }else if(opts[["data-type"]]=="GS.report"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
95
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
96 data.type<-"GS.report"
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
97 data.source<-opts[["gs-report"]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
98
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
99 }else if(opts[["data-type"]]=="GEO"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
100
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
101 data.type<-"GEO"
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
102 data.source<-opts[["geo-series"]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
103
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
104
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
105 }else if(opts[["data-type"]]=="data.files"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
106
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
107 data.type<-"GEO"
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
108 data.source<-opts[["geo-series"]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
109
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
110 }else if(opts[["data-type"]]=="data.files"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
111
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
112 data.type<-"data.files"
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
113 data.source<-c(opts[["pheno"]], opts[["betas"]])
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
114 if(!is.null(opts[["pvals"]]))
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
115 data.source<-c(data.source, opts[["pvals"]])
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
116
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
117 }else if(opts[["data-type"]]=="beds"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
118
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
119 data.type<-"idat.dir"
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
120 files<-strsplit(opts[["bed-files"]], "\t")[[1]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
121 bed.dir<-mkdir(file.path(opts[["report-dir"]], "beds"))
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
122 file.copy(as.list(files), bed.dir)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
123 data.source<-list()
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
124 data.source[["bed.dir"]]<-bed.dir
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
125 data.source[["sample.sheet"]]<-opts[["pheno"]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
126
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
127 }
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
128
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
129 dump<-sapply(names(opt.class), function(on){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
130 getoptname<-gsub("\\.","-",on)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
131 if(getoptname %in% names(opts)){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
132 if(opt.class[on]=="logical"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
133 rnb.options(on=TRUE)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
134 }else if(opt.class %in% c("character","character.vector")){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
135 ov<-opts[[getoptname]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
136 ov<-gsub("\"", "", ov)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
137 if(opt.class=="character.vector"){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
138 ov<-as.character(strsplit(ov,","))
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
139 }
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
140 rnb.options(on=ov)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
141 }else if(opt.class %in% c("integer","numeric","integer.vector","numeric.vector")){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
142 ov<-opts[[getoptname]]
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
143 ov<-gsub("\"", "", ov)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
144 if(opt.class %in% c("integer.vector","numeric.vector")){
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
145 ov<-as.character(strsplit(ov,","))
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
146 }
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
147 rnb.options(on=ov)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
148 }
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
149 }
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
150 })
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
151
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
152
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
153 rnb.run.analysis(data.source=data.source, dir.report=opts[["report-dir"]], data.type=data.type)
a1c96ef6c111 Uploaded updated wrapper
pavlo-lutsik
parents:
diff changeset
154