annotate bum.R @ 4:e520fbedf79b draft default tip

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit e0d4688a59e6eeba33adcfe803ac43d0bc2863e7"
author iuc
date Tue, 31 Aug 2021 08:38:20 +0000
parents 95ceb6d735d6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
1 # Author: Cico Zhang
a365150d73c0 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
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
3
a365150d73c0 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
3
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
5 err_foo <- function() {
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
6 cat(geterrmessage(), file = stderr());
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
7 q("no", 1, F)
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
8 }
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
9 options(show.error.messages = F, error = err_foo)
0
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
10
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
11 # Import required libraries
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
12 suppressPackageStartupMessages({
3
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
13 library("getopt")
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
14 library("BioNet")
0
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
15 })
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
16
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
17 # Take in trailing command line arguments
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
18 args <- commandArgs(trailingOnly = TRUE)
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
19
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
20 # Get options using the spec as defined by the enclosed list
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
21 # Read the options from the default: commandArgs(TRUE)
3
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
22 option_specification <- matrix(c("input", "i", 2, "character",
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
23 "output", "o", 2, "character"
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
24 ), byrow = TRUE, ncol = 4);
0
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
25
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
26 # Parse options
a365150d73c0 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);
a365150d73c0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff changeset
28
a365150d73c0 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)
3
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
30 bum <- fitBumModel(pvals, plot = FALSE)
0
a365150d73c0 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)
3
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
32 write.table(x = mat, file = options$output, quote = FALSE,
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
33 row.names = FALSE, col.names = FALSE)
95ceb6d735d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents: 0
diff changeset
34 message("Parameters have been estimated successfully!")