view bum.R @ 1:5f589c91566e draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit a4b0969b33a68a0ea9ba12291f6694aec24f13ed
author iuc
date Tue, 30 Oct 2018 18:57:02 -0400
parents e41ec5af7472
children 2b80a2596064
line wrap: on
line source

# Author: Cico Zhang
# Usage: Rscript bum.R --input p-values.txt --output result.txt --verbose TRUE

# Set up R error handling to go to stderr
options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)})

# Avoid crashing Galaxy with an UTF8 error on German LC settings
#loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")

# Import required libraries
suppressPackageStartupMessages({
  library('getopt')
  library('BioNet')
})

# Take in trailing command line arguments
args <- commandArgs(trailingOnly = TRUE)

# Get options using the spec as defined by the enclosed list
# Read the options from the default: commandArgs(TRUE)
option_specification <- matrix(c(
  'input', 'i', 2, 'character',
  'output', 'o', 2, 'character'
), byrow=TRUE, ncol=4);

# Parse options
options <- getopt(option_specification);

pvals <- read.table(options$input)
bum <- fitBumModel(pvals,plot=FALSE)
mat <- c(bum$lambda, bum$a)
#bumtablename <- paste(options$output,sep="\t")
write.table(x=mat, file=options$output,quote=FALSE, row.names=FALSE, col.names=FALSE)
message ("Parameters have been estimated successfully!")