Mercurial > repos > sblanck > smagexp
diff MetaMA.R @ 9:328f4031e5d3 draft
planemo upload commit f882a5ba78afeb368605beb3986936e86c485cbb-dirty
author | sblanck |
---|---|
date | Wed, 10 May 2017 08:12:48 -0400 |
parents | 93451f832736 |
children | 56267e3293b2 |
line wrap: on
line diff
--- a/MetaMA.R Wed May 10 04:12:26 2017 -0400 +++ b/MetaMA.R Wed May 10 08:12:48 2017 -0400 @@ -1,44 +1,54 @@ -library(metaMA) -library(affy) -library(annaffy) -library(VennDiagram) -library(GEOquery) +#!/usr/bin/env Rscript +# setup R error handling to go to stderr +options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) + +# we need that to not crash galaxy with an UTF8 error on German LC settings. +loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") + +library("optparse") + +##### Read options +option_list=list( + make_option("--input",type="character",default="NULL",help="list of rdata objects containing eset objects"), + make_option("--htmloutput",type="character",default=NULL,help="Output html report"), + make_option("--htmloutputpath",type="character",default="NULL",help="Path of output html report"), + make_option("--htmltemplate",type="character",default=NULL,help="html template)") +); -cargs<-commandArgs() -cargs<-cargs[(which(cargs=="--args")+1):length(cargs)] +opt_parser = OptionParser(option_list=option_list); +opt = parse_args(opt_parser); + +if(is.null(opt$input)){ + print_help(opt_parser) + stop("input required.", call.=FALSE) +} -nbargs=length(cargs) +#loading libraries + +suppressPackageStartupMessages(require(metaMA)) +suppressPackageStartupMessages(require(affy)) +suppressPackageStartupMessages(require(annaffy)) +suppressPackageStartupMessages(require(VennDiagram)) +suppressPackageStartupMessages(require(GEOquery)) + +listInput <- trimws( unlist( strsplit(trimws(opt$input), ",") ) ) + rdataList=list() condition1List=list() condition2List=list() - -for (i in 1:(nbargs-5)) +for (input in listInput) { - Rdata=cargs[[i]] - #condition1=cargs[[i+1]] - #condition2=cargs[[i+2]] - load(Rdata) + load(input) rdataList=c(rdataList,(eset)) - #condition1List=c(condition1List,condition1) - #condition2List=c(condition2List,condition2) condition1List=c(condition1List,saveConditions[1]) condition2List=c(condition2List,saveConditions[2]) } -#tables<-cargs[[1]] -#tech<-cargs[[2]] -result.html<-cargs[[nbargs-4]] -result.path<-cargs[[nbargs-3]] -#result.venn<-cargs[[nbargs-3]] -result.template<-cargs[[nbargs-2]] - -#sink("/dev/null") -#dir.create(temp.files.path,recursive=TRUE) -#file.conn=file(diag.html,open="w") - -#writeLines(c("<html><body bgcolor='lightgray'>"),file.conn) +result.html<-htmloutput +result.path<-htmloutputpath +result.template<-htmltemplate showVenn<-function(res,file) { @@ -51,7 +61,6 @@ dev.off() } - library("org.Hs.eg.db") x <- org.Hs.egUNIGENE mapped_genes <- mappedkeys(x) @@ -107,8 +116,6 @@ } - - filterCondition<-function(gset,condition1, condition2){ selected=c(which((tolower(as.character(pData(gset)["source_name_ch1"][,1]))==condition1)), which(tolower(as.character(pData(gset)["source_name_ch1"][,1]))==condition2))