comparison preprocess.R @ 4:3fcbb8030fcc draft

"planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 40eda5ea3551e8b3bae32d0a8f405fe90ef22646-dirty"
author sblanck
date Mon, 12 Apr 2021 14:47:09 +0000
parents 4d539083cf7f
children
comparison
equal deleted inserted replaced
3:94fc6ed13946 4:3fcbb8030fcc
1 #!/usr/bin/env Rscript 1 #!/usr/bin/env Rscript
2 # setup R error handling to go to stderr 2 # setup R error handling to go to stderr
3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) 3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
4 4
5 # we need that to not crash galaxy with an UTF8 error on German LC settings. 5 # we need that to not crash galaxy with an UTF8 error on German LC settings.
6 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") 6 #loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
7 7
8 library("optparse") 8 library("optparse")
9 9
10 ##### Read options 10 ##### Read options
11 option_list=list( 11 option_list=list(
22 make_option("--inputacs",type="character",default=NULL, dest="inputacs"), 22 make_option("--inputacs",type="character",default=NULL, dest="inputacs"),
23 make_option("--tumorcsv",type="character",default=NULL, dest="tumorcsv"), 23 make_option("--tumorcsv",type="character",default=NULL, dest="tumorcsv"),
24 make_option("--settingsType",type="character",default=NULL, dest="settingsType"), 24 make_option("--settingsType",type="character",default=NULL, dest="settingsType"),
25 make_option("--outputgraph",type="character",default=NULL, dest="outputgraph"), 25 make_option("--outputgraph",type="character",default=NULL, dest="outputgraph"),
26 make_option("--zipfigures",type="character",default=NULL, dest="zipfigures"), 26 make_option("--zipfigures",type="character",default=NULL, dest="zipfigures"),
27 make_option("--zipresults",type="character",default=NULL, dest="zipresults"),
27 make_option("--outputlog",type="character",default=NULL, dest="outputlog"), 28 make_option("--outputlog",type="character",default=NULL, dest="outputlog"),
28 make_option("--log",type="character",default=NULL, dest="log"), 29 make_option("--log",type="character",default=NULL, dest="log"),
29 make_option("--user_id",type="character",default=NULL, dest="user_id"), 30 make_option("--user_id",type="character",default=NULL, dest="user_id"),
30 make_option("--input",type="character",default=NULL, dest="input") 31 make_option("--input",type="character",default=NULL, dest="input")
31 ); 32 );
53 inputACS=opt$inputacs 54 inputACS=opt$inputacs
54 tumorcsv=opt$tumorcsv 55 tumorcsv=opt$tumorcsv
55 settingsType=opt$settingsType 56 settingsType=opt$settingsType
56 outputGraph=opt$outputgraph 57 outputGraph=opt$outputgraph
57 zipfigures=opt$zipfigures 58 zipfigures=opt$zipfigures
59 zipresults=opt$zipresults
58 outputlog=opt$outputlog 60 outputlog=opt$outputlog
59 log=opt$log 61 log=opt$log
60 userId=opt$user_id 62 userId=opt$user_id
61 63
62 destinationPath=file.path(newFilePath, userId, dataSetName) 64 destinationPath=file.path(newFilePath, userId, dataSetName)
127 tumor=tumorcsv 129 tumor=tumorcsv
128 outputgraph=type.convert(outputGraph) 130 outputgraph=type.convert(outputGraph)
129 131
130 132
131 library(MPAgenomics) 133 library(MPAgenomics)
134 library(R.utils)
135 library(aroma.affymetrix)
136
132 setwd(workdir) 137 setwd(workdir)
133 138
134 if (outputlog){ 139 if (outputlog){
135 sinklog <- file(log, open = "wt") 140 sinklog <- file(log, open = "wt")
136 sink(sinklog ,type = "output") 141 sink(sinklog ,type = "output")
141 { 146 {
142 signalPreProcess(dataSetName=dataset, chipType=chip, dataSetPath=celPath,chipFilesPath=chipPath, path=workdir,createArchitecture=createArchitecture, savePlot=outputgraph, tags=tag) 147 signalPreProcess(dataSetName=dataset, chipType=chip, dataSetPath=celPath,chipFilesPath=chipPath, path=workdir,createArchitecture=createArchitecture, savePlot=outputgraph, tags=tag)
143 } else { 148 } else {
144 signalPreProcess(dataSetName=dataset, chipType=chip, dataSetPath=celPath,chipFilesPath=chipPath, normalTumorArray=tumor, path=workdir,createArchitecture=createArchitecture, savePlot=outputgraph, tags=tag) 149 signalPreProcess(dataSetName=dataset, chipType=chip, dataSetPath=celPath,chipFilesPath=chipPath, normalTumorArray=tumor, path=workdir,createArchitecture=createArchitecture, savePlot=outputgraph, tags=tag)
145 } 150 }
151 setwd(mpagenomicsDir)
152 library(zip)
153 zipr(zipresults,files=".")
146 setwd(abs_fig_dir) 154 setwd(abs_fig_dir)
155 #abs_fig_dir
147 files2zip <- dir(abs_fig_dir) 156 files2zip <- dir(abs_fig_dir)
148 zip(zipfile = "figures.zip", files = files2zip) 157 zipr(zipfigures, files = files2zip)
149 file.rename("figures.zip",zipfigures) 158
150 summarydf=data.frame(celFileNameList,rep(dataSetName,length(celFileNameList)),rep(chipType,length(celFileNameList))) 159 summarydf=data.frame(celFileNameList,rep(dataSetName,length(celFileNameList)),rep(chipType,length(celFileNameList)))
151 write.table(summarydf,file=summary,quote=FALSE,row.names=FALSE,col.names=FALSE,sep="\t") 160 write.table(summarydf,file=summary,quote=FALSE,row.names=FALSE,col.names=FALSE,sep="\t")
161
162 if (dir.exists(mpagenomicsDir)) {
163 system(paste0("rm -r ", mpagenomicsDir))
164 dir.create(mpagenomicsDir, showWarnings = TRUE, recursive = TRUE)
165 }
166
167 if (dir.exists(dataDir)) {
168 system(paste0("rm -r ", dataDir))
169 dir.create(dataDir, showWarnings = TRUE, recursive = TRUE)
170 }
152 171
153 if (outputlog){ 172 if (outputlog){
154 sink(type="output") 173 sink(type="output")
155 sink(type="message") 174 sink(type="message")
156 close(sinklog) 175 close(sinklog)