annotate bum.R @ 0:e41ec5af7472 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
author iuc
date Thu, 02 Aug 2018 11:57:44 -0400
parents
children 2b80a2596064
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
1 # Author: Cico Zhang
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
2 # Usage: Rscript bum.R --input p-values.txt --output result.txt --verbose TRUE
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
3
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
4 # Set up R error handling to go to stderr
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
5 options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)})
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
6
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
7 # Avoid crashing Galaxy with an UTF8 error on German LC settings
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
8 #loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
9
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
10 # Import required libraries
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
11 suppressPackageStartupMessages({
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
12 library('getopt')
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
13 library('BioNet')
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
14 })
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
15
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
16 # Take in trailing command line arguments
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
17 args <- commandArgs(trailingOnly = TRUE)
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
18
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
19 # Get options using the spec as defined by the enclosed list
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
20 # Read the options from the default: commandArgs(TRUE)
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
21 option_specification <- matrix(c(
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
22 'input', 'i', 2, 'character',
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
23 'output', 'o', 2, 'character'
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
24 ), byrow=TRUE, ncol=4);
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
25
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
26 # Parse options
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
27 options <- getopt(option_specification);
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
28
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
29 pvals <- read.table(options$input)
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
30 bum <- fitBumModel(pvals,plot=FALSE)
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
31 mat <- c(bum$lambda, bum$a)
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
32 #bumtablename <- paste(options$output,sep="\t")
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
33 write.table(x=mat, file=options$output,quote=FALSE, row.names=FALSE, col.names=FALSE)
e41ec5af7472 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
34 message ("Parameters have been estimated successfully!")