Mercurial > repos > iuc > dexseq
comparison dexseq.R @ 10:df929f257179 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 2ea27822b171dbf519509dc1da150c8ccee2a140
author | iuc |
---|---|
date | Tue, 04 Apr 2023 08:25:51 +0000 |
parents | 62adf13b86ea |
children | 9a7c5b6d8f1e |
comparison
equal
deleted
inserted
replaced
9:b47c006d90c5 | 10:df929f257179 |
---|---|
1 ## Setup R error handling to go to stderr | 1 ## Setup R error handling to go to stderr |
2 options(show.error.messages = F, error = function() { | 2 options(show.error.messages = FALSE, error = function() { |
3 cat(geterrmessage(), file = stderr()); q("no", 1, F) | 3 cat(geterrmessage(), file = stderr()) |
4 q("no", 1, FALSE) | |
4 }) | 5 }) |
5 # we need that to not crash galaxy with an UTF8 error on German LC settings. | 6 # we need that to not crash galaxy with an UTF8 error on German LC settings. |
6 Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") | 7 Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
7 | 8 |
8 suppressPackageStartupMessages({ | 9 suppressPackageStartupMessages({ |
25 "reportdir", "r", 1, "character", | 26 "reportdir", "r", 1, "character", |
26 "rds", "d", 1, "character", | 27 "rds", "d", 1, "character", |
27 "factors", "f", 1, "character", | 28 "factors", "f", 1, "character", |
28 "threads", "p", 1, "integer", | 29 "threads", "p", 1, "integer", |
29 "fdr", "c", 1, "double" | 30 "fdr", "c", 1, "double" |
30 ), byrow = TRUE, ncol = 4); | 31 ), byrow = TRUE, ncol = 4) |
31 opt <- getopt(spec); | 32 opt <- getopt(spec) |
32 | 33 |
33 # if help was asked for print a friendly message | 34 # if help was asked for print a friendly message |
34 # and exit with a non-zero error code | 35 # and exit with a non-zero error code |
35 if (!is.null(opt$help)) { | 36 if (!is.null(opt$help)) { |
36 cat(getopt(spec, usage = TRUE)); | 37 cat(getopt(spec, usage = TRUE)) |
37 q(status = 1); | 38 q(status = 1) |
38 } | 39 } |
39 | 40 |
40 trim <- function(x) gsub("^\\s+|\\s+$", "", x) | 41 trim <- function(x) gsub("^\\s+|\\s+$", "", x) |
41 opt$samples <- trim(opt$samples) | 42 opt$samples <- trim(opt$samples) |
42 opt$factors <- trim(opt$factors) | 43 opt$factors <- trim(opt$factors) |
108 export_table <- as.data.frame(res_sorted) | 109 export_table <- as.data.frame(res_sorted) |
109 last_column <- ncol(export_table) | 110 last_column <- ncol(export_table) |
110 for (i in seq_len(nrow(export_table))) { | 111 for (i in seq_len(nrow(export_table))) { |
111 export_table[i, last_column] <- paste(export_table[i, last_column][[1]], collapse = ", ") | 112 export_table[i, last_column] <- paste(export_table[i, last_column][[1]], collapse = ", ") |
112 } | 113 } |
113 write.table(export_table, file = opt$outfile, sep = "\t", quote = FALSE, col.names = FALSE) | 114 export_table[, c(last_column)] <- sapply(export_table[, c(last_column)], as.character) |
115 write.table(export_table, file = opt$outfile, sep = "\t", quote = FALSE, row.names = FALSE, col.names = FALSE) | |
114 print("Written Results") | 116 print("Written Results") |
115 | 117 |
116 if (!is.null(opt$rds)) { | 118 if (!is.null(opt$rds)) { |
117 saveRDS(res, file = "DEXSeqResults.rds") | 119 saveRDS(res, file = "DEXSeqResults.rds") |
118 } | 120 } |