1
|
1 args<-commandArgs(TRUE)
|
|
2
|
|
3 workingDirectory<-args[3]
|
|
4 logFile<-paste(workingDirectory,'/run.log', sep='')
|
|
5 graphsDirectory<-paste(workingDirectory,'/graphs', sep='')
|
|
6 outputCSV<-paste(workingDirectory,'/IPO_PP.csv', sep='')
|
|
7
|
|
8 dir.create(workingDirectory)
|
|
9 zz <- file(logFile, open="wt")
|
|
10 sink(zz)
|
|
11 sink(zz, type="message")
|
|
12
|
|
13 library("xtable")
|
|
14 library(IPO)
|
|
15 #print(args)
|
|
16
|
|
17 peakpickingParameters <- getDefaultXcmsSetStartingParams('centWave')
|
|
18 #setting levels for min_peakwidth to 10 and 20 (hence 15 is the center point)
|
|
19 peakpickingParameters$min_peakwidth <- c(10,20)
|
|
20 peakpickingParameters$max_peakwidth <- c(26,42)
|
|
21 #setting only one value for ppm therefore this parameter is not optimized
|
|
22 peakpickingParameters$ppm <- 20
|
|
23 peakpickingParameters$nSlaves <- 4 # as.numeric(args[3])
|
|
24 type <- "centWave"
|
|
25
|
|
26 resultPP <- optimizeXcmsSet(files=args[1], params=peakpickingParameters, nSlaves=4, subdir=graphsDirectory)
|
|
27
|
|
28 print (resultPP)
|
|
29
|
|
30 graphs<-""
|
|
31 for(i in 1:(length(resultPP)-1))
|
|
32 {
|
|
33 graphs<-paste(graphs,"<img width='100%' src='graphs/rsm_", i ,".jpg'><hr>",sep='')
|
|
34 }
|
|
35
|
|
36 list <- c(resultPP$best_settings$parameters, as.list(resultPP$best_settings$result), list(type=type))
|
|
37 table <- print(xtable(t(data.frame(list))), type = "html")
|
|
38 write.csv(c(resultPP$best_settings$parameters, as.list(resultPP$best_settings$result), list(type=type)),file=outputCSV)
|
|
39
|
|
40 html<-paste('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
41 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
42 <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
43 <meta name="generator" content="Galaxy %s tool output - see http://g2.trac.bx.psu.edu/" />
|
|
44 <title></title>
|
|
45 </head>
|
|
46 <body> <div class="container-fluid"><h1 class="text-center">IPO optimization - Output</h1><hr>',table,'<br><span class="label label-primary"><a href="IPO_PP.csv">Output</a></span><br><span class="label label-danger"><a href="run.log">Job log</a></span><hr>',graphs,'</div>', sep='')
|
|
47
|
|
48 fileConn<-file(args[2])
|
|
49 writeLines(html, fileConn)
|
|
50 close(fileConn)
|
|
51
|
|
52 sink(type = "message")
|
|
53 sink() |