annotate ipo.R @ 1:c403de9adce7 draft

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