Mercurial > repos > iuc > heinz
annotate bum.R @ 3:2b80a2596064 draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
author | iuc |
---|---|
date | Thu, 11 Jun 2020 07:18:17 -0400 |
parents | e41ec5af7472 |
children |
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 |
3
2b80a2596064
"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() { |
2b80a2596064
"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()); |
2b80a2596064
"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) |
2b80a2596064
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents:
0
diff
changeset
|
8 } |
2b80a2596064
"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
e41ec5af7472
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff
changeset
|
10 |
e41ec5af7472
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff
changeset
|
11 # Import required libraries |
e41ec5af7472
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff
changeset
|
12 suppressPackageStartupMessages({ |
3
2b80a2596064
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit 8007f71281553ddfa45e6f8e1172952d956bb000"
iuc
parents:
0
diff
changeset
|
13 library("getopt") |
2b80a2596064
"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
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 |
e41ec5af7472
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 |
e41ec5af7472
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) |
e41ec5af7472
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/heinz commit b0b2c64a46bdd9beebdfb7fc5312f75346483763
iuc
parents:
diff
changeset
|
19 |
e41ec5af7472
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 |
e41ec5af7472
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
2b80a2596064
"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", |
2b80a2596064
"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" |
2b80a2596064
"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
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) |
3
2b80a2596064
"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
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) |
3
2b80a2596064
"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, |
2b80a2596064
"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) |
2b80a2596064
"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!") |