Mercurial > repos > sblanck > smagexp
comparison AffyQCnormalization.R @ 8:7f74250a083d draft
planemo upload
author | sblanck |
---|---|
date | Wed, 10 May 2017 04:12:26 -0400 |
parents | 93451f832736 |
children | ef7d98f9eb51 |
comparison
equal
deleted
inserted
replaced
7:f3c021bdc000 | 8:7f74250a083d |
---|---|
1 library(Biobase) | 1 #!/usr/bin/env Rscript |
2 library(GEOquery) | 2 # setup R error handling to go to stderr |
3 library(GEOmetadb) | 3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
4 library(limma) | |
5 library(jsonlite) | |
6 library(affy) | |
7 library(affyPLM) | |
8 library(dplyr) | |
9 | 4 |
10 cargs<-commandArgs() | 5 # we need that to not crash galaxy with an UTF8 error on German LC settings. |
11 cargs<-cargs[(which(cargs=="--args")+1):length(cargs)] | 6 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
12 nbargs=length(cargs) | 7 |
8 library("optparse") | |
9 | |
10 ##### Read options | |
11 option_list=list( | |
12 make_option("--input",type="character",default="NULL",help="rdata object containing eset object"), | |
13 make_option("--normalization",type="character",default=NULL,help="normalization method"), | |
14 make_option("--nbresult",type="character",default=NULL,help="number of result displayed results"), | |
15 make_option("--rdataoutput",type="character",default="NULL",help="output rdata object containing eset object"), | |
16 make_option("--htmloutput",type="character",default=NULL,help="Output html report"), | |
17 make_option("--htmloutputpath",type="character",default="NULL",help="Path of output html report"), | |
18 make_option("--htmltemplate",type="character",default=NULL,help="html template)") | |
19 ); | |
20 | |
21 opt_parser = OptionParser(option_list=option_list); | |
22 opt = parse_args(opt_parser); | |
23 | |
24 if(is.null(opt$input)){ | |
25 print_help(opt_parser) | |
26 stop("input required.", call.=FALSE) | |
27 } | |
28 | |
29 #loading libraries | |
30 | |
31 suppressPackageStartupMessages(require(Biobase)) | |
32 suppressPackageStartupMessages(require(GEOquery)) | |
33 suppressPackageStartupMessages(require(GEOmetadb)) | |
34 suppressPackageStartupMessages(require(limma)) | |
35 suppressPackageStartupMessages(require(jsonlite)) | |
36 suppressPackageStartupMessages(require(affy)) | |
37 suppressPackageStartupMessages(library(affyPLM)) | |
38 suppressPackageStartupMessages(require(dplyr)) | |
39 | |
40 listInput <- trimws( unlist( strsplit(trimws(opt$input), ",") ) ) | |
41 | |
13 celList=vector() | 42 celList=vector() |
14 celFileNameList=vector() | 43 celFileNameList=vector() |
15 for (i in seq(1,nbargs-7,2)) | 44 |
45 for (i in 1:length(listInput)) | |
16 { | 46 { |
17 celList=c(celList,cargs[[i]]) | 47 inputFileInfo <- unlist( strsplit( listInput[i], ';' ) ) |
18 celFileNameList=c(celFileNameList,cargs[[i+1]]) | 48 celList=c(celList,inputFileInfo[1]) |
49 celFileNameList=c(celFileNameList,inputFileInfo[2]) | |
19 } | 50 } |
20 | 51 |
21 | 52 |
22 normalization=cargs[[nbargs-6]] | 53 normalization=opt$normalization |
23 result_export_eset=cargs[[nbargs-5]] | 54 result_export_eset=opt$rdataoutput |
24 result=cargs[[nbargs-4]] | 55 result=opt$htmloutput |
25 result.path=cargs[[nbargs-3]] | 56 result.path=opt$htmloutputpath |
26 result.template=cargs[[nbargs-2]] | 57 result.template=opt$htmltemplate |
27 | 58 |
28 dir.create(result.path, showWarnings = TRUE, recursive = TRUE) | 59 dir.create(result.path, showWarnings = TRUE, recursive = TRUE) |
29 for(i in 1:length(celList)) | 60 for(i in 1:length(celList)) |
30 { | 61 { |
31 file.copy(celList[i],paste0("./",celFileNameList[i])) | 62 file.copy(celList[i],paste0("./",celFileNameList[i])) |
90 #} | 121 #} |
91 | 122 |
92 dev.off() | 123 dev.off() |
93 htmlfile=gsub(x=htmlfile,pattern = "###PLOTMANORM###",replacement = plotMAnorm, fixed = TRUE) | 124 htmlfile=gsub(x=htmlfile,pattern = "###PLOTMANORM###",replacement = plotMAnorm, fixed = TRUE) |
94 file.copy(plotMAnorm,result.path) | 125 file.copy(plotMAnorm,result.path) |
95 #write.table(tolower(c(condition1Name,condition2Name)),quote = FALSE,col.names = FALSE, row.names=FALSE,file=result_export_conditions) | |
96 #saveConditions=c(condition1Name,condition2Name) | |
97 save(eset,file=result_export_eset) | 126 save(eset,file=result_export_eset) |
98 write(htmlfile,result) | 127 write(htmlfile,result) |
99 | 128 |
100 #l=list() | |
101 #for(i in 1:length(esets)) | |
102 #{ | |
103 # l[[paste("study",i,sep="")]]<-res[[i]] | |
104 #} | |
105 #l[["Meta"]]=res[[length(res)-1]] | |
106 #showVenn(res,file.path(temp.files.path,"venn.png")) | |
107 #writeLines(c("<h2>Venn diagram</h2>"),file.conn) | |
108 #writeLines(c("<img src='venn.png'><br/><br/>"),file.conn) | |
109 #writeLines(c("</body></html>"),file.conn) | |
110 #close(file.conn) |