changeset 1:c403de9adce7 draft

Uploaded
author cs76
date Mon, 07 Dec 2015 06:05:53 -0500
parents 5cd5308cc398
children 77d886658570
files ipo.R
diffstat 1 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipo.R	Mon Dec 07 06:05:53 2015 -0500
@@ -0,0 +1,53 @@
+args<-commandArgs(TRUE)
+
+workingDirectory<-args[3]
+logFile<-paste(workingDirectory,'/run.log', sep='')
+graphsDirectory<-paste(workingDirectory,'/graphs', sep='')
+outputCSV<-paste(workingDirectory,'/IPO_PP.csv', sep='')
+
+dir.create(workingDirectory)
+zz <- file(logFile, open="wt")
+sink(zz)
+sink(zz, type="message")
+
+library("xtable")
+library(IPO)
+#print(args)
+
+peakpickingParameters <- getDefaultXcmsSetStartingParams('centWave')
+#setting levels for min_peakwidth to 10 and 20 (hence 15 is the center point)
+peakpickingParameters$min_peakwidth <- c(10,20) 
+peakpickingParameters$max_peakwidth <- c(26,42)
+#setting only one value for ppm therefore this parameter is not optimized
+peakpickingParameters$ppm <- 20 
+peakpickingParameters$nSlaves <- 4 # as.numeric(args[3])
+type <- "centWave"
+
+resultPP <- optimizeXcmsSet(files=args[1], params=peakpickingParameters, nSlaves=4, subdir=graphsDirectory)
+
+print (resultPP)
+
+graphs<-""
+for(i in 1:(length(resultPP)-1)) 
+{
+	graphs<-paste(graphs,"<img width='100%' src='graphs/rsm_", i ,".jpg'><hr>",sep='')
+}
+
+list <- c(resultPP$best_settings$parameters, as.list(resultPP$best_settings$result), list(type=type))
+table <- print(xtable(t(data.frame(list))), type = "html")
+write.csv(c(resultPP$best_settings$parameters, as.list(resultPP$best_settings$result), list(type=type)),file=outputCSV)
+
+html<-paste('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
+        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
+        <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
+        <meta name="generator" content="Galaxy %s tool output - see http://g2.trac.bx.psu.edu/" /> 
+        <title></title> 
+        </head> 
+        <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='')
+
+fileConn<-file(args[2])
+writeLines(html, fileConn)
+close(fileConn)
+
+sink(type = "message")
+sink()
\ No newline at end of file