Mercurial > repos > sblanck > smagexp
comparison GEOQuery.R @ 4:2c9e44ff68dc draft
use optparse
author | sblanck |
---|---|
date | Wed, 12 Apr 2017 03:44:54 -0400 |
parents | 93451f832736 |
children |
comparison
equal
deleted
inserted
replaced
3:b01c4f260085 | 4:2c9e44ff68dc |
---|---|
1 #!/usr/bin/env Rscript | |
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 ) } ) | |
1 | 4 |
2 library(GEOquery) | 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") | |
3 | 7 |
8 library("optparse") | |
4 | 9 |
5 cargs<-commandArgs() | 10 ##### Read options |
6 cargs<-cargs[(which(cargs=="--args")+1):length(cargs)] | 11 option_list=list( |
12 make_option("--id",type="character",default=NULL,help="GSE ID from GEO databse (required)"), | |
13 make_option("--transformation",type="character",default=NULL,help="log2 transformation (required)"), | |
14 make_option("--data",type="character",default=NULL,help="A table containing the expression data"), | |
15 make_option("--rdata",type="character",default="NULL",help="rdata object containing eset object"), | |
16 make_option("--conditions",type="character",default=NULL,help="Text file summarizing conditions of the experiment") | |
17 | |
18 ); | |
7 | 19 |
8 GEOQueryID<-cargs[[1]] | 20 opt_parser = OptionParser(option_list=option_list); |
9 GEOQueryData<-cargs[[2]] | 21 opt = parse_args(opt_parser); |
10 GEOQueryRData<-cargs[[3]] | |
11 conditionFile<-cargs[[4]] | |
12 transformation<-cargs[[5]] | |
13 | 22 |
14 data1 = getGEO(GEOQueryID) | 23 if(is.null(opt$id)){ |
24 print_help(opt_parser) | |
25 stop("GEOdata id required.", call.=FALSE) | |
26 } | |
27 | |
28 #loading libraries | |
29 suppressPackageStartupMessages(require(GEOquery)) | |
30 | |
31 GEOQueryID=opt$id | |
32 GEOQueryData=opt$data | |
33 GEOQueryRData=opt$rdata | |
34 conditionFile=opt$conditions | |
35 transformation=opt$transformation | |
36 | |
37 data1=getGEO(GEOQueryID) | |
15 eset=data1[[1]] | 38 eset=data1[[1]] |
16 | 39 |
17 #check if datas are in log2 space | 40 #check if datas are in log2 space |
18 normalization<-function(data){ | 41 normalization<-function(data){ |
19 ex <- exprs(data) | 42 ex <- exprs(data) |