Mercurial > repos > iuc > edger
comparison edger.R @ 12:07cc368bf34f draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 4955aeed800ea8e45057b7e8578dc878a07f9cfc
| author | iuc |
|---|---|
| date | Thu, 21 Sep 2023 10:00:53 +0000 |
| parents | 21891a3214b9 |
| children | 838b481dc6f9 |
comparison
equal
deleted
inserted
replaced
| 11:f034bbfb7062 | 12:07cc368bf34f |
|---|---|
| 38 | 38 |
| 39 # Record starting time | 39 # Record starting time |
| 40 time_start <- as.character(Sys.time()) | 40 time_start <- as.character(Sys.time()) |
| 41 | 41 |
| 42 # setup R error handling to go to stderr | 42 # setup R error handling to go to stderr |
| 43 options(show.error.messages = F, error = function() { | 43 options(show.error.messages = FALSE, error = function() { |
| 44 cat(geterrmessage(), file = stderr()) | 44 cat(geterrmessage(), file = stderr()) |
| 45 q("no", 1, F) | 45 q("no", 1, FALSE) |
| 46 }) | 46 }) |
| 47 | 47 |
| 48 # we need that to not crash galaxy with an UTF8 error on German LC settings. | 48 # we need that to not crash galaxy with an UTF8 error on German LC settings. |
| 49 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") | 49 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
| 50 | 50 |
| 103 if (file == "") { | 103 if (file == "") { |
| 104 file <- stdout() | 104 file <- stdout() |
| 105 } else if (substring(file, 1L, 1L) == "|") { | 105 } else if (substring(file, 1L, 1L) == "|") { |
| 106 file <- pipe(substring(file, 2L), "w") | 106 file <- pipe(substring(file, 2L), "w") |
| 107 on.exit(close(file)) | 107 on.exit(close(file)) |
| 108 } | 108 } else { |
| 109 else { | |
| 110 file <- file(file, ifelse(append, "a", "w")) | 109 file <- file(file, ifelse(append, "a", "w")) |
| 111 on.exit(close(file)) | 110 on.exit(close(file)) |
| 112 } | 111 } |
| 113 } | 112 } |
| 114 .Internal(cat(list(...), file, sep, fill, labels, append)) | 113 .Internal(cat(list(...), file, sep, fill, labels, append)) |
| 179 byrow = TRUE, ncol = 4 | 178 byrow = TRUE, ncol = 4 |
| 180 ) | 179 ) |
| 181 opt <- getopt(spec) | 180 opt <- getopt(spec) |
| 182 | 181 |
| 183 | 182 |
| 184 if (is.null(opt$matrixPath) & is.null(opt$filesPath)) { | 183 if (is.null(opt$matrixPath) && is.null(opt$filesPath)) { |
| 185 cat("A counts matrix (or a set of counts files) is required.\n") | 184 cat("A counts matrix (or a set of counts files) is required.\n") |
| 186 q(status = 1) | 185 q(status = 1) |
| 187 } | 186 } |
| 188 | 187 |
| 189 if (is.null(opt$cpmReq)) { | 188 if (is.null(opt$cpmReq)) { |
| 385 postfilter_count <- nrow(data$counts) | 384 postfilter_count <- nrow(data$counts) |
| 386 filtered_count <- prefilter_count - postfilter_count | 385 filtered_count <- prefilter_count - postfilter_count |
| 387 | 386 |
| 388 # Name rows of factors according to their sample | 387 # Name rows of factors according to their sample |
| 389 row.names(factors) <- names(data$counts) | 388 row.names(factors) <- names(data$counts) |
| 390 factor_list <- sapply(names(factors), paste_listname) | 389 factor_list <- names(factors) |
| 391 | 390 |
| 392 # Generating the DGEList object "data" | 391 # Generating the DGEList object "data" |
| 393 samplenames <- colnames(data$counts) | 392 samplenames <- colnames(data$counts) |
| 394 genes <- data$genes | 393 genes <- data$genes |
| 395 data <- DGEList(data$counts) | 394 data <- DGEList(data$counts) |
| 403 for (i in seq_along(factor_list)) { | 402 for (i in seq_along(factor_list)) { |
| 404 formula <- paste(formula, factor_list[i], sep = "+") | 403 formula <- paste(formula, factor_list[i], sep = "+") |
| 405 } | 404 } |
| 406 | 405 |
| 407 formula <- formula(formula) | 406 formula <- formula(formula) |
| 408 design <- model.matrix(formula) | 407 design <- model.matrix(formula, factors) |
| 409 | 408 |
| 410 for (i in seq_along(factor_list)) { | 409 for (i in seq_along(factor_list)) { |
| 411 colnames(design) <- gsub(factor_list[i], "", colnames(design), fixed = TRUE) | 410 colnames(design) <- gsub(factor_list[i], "", colnames(design), fixed = TRUE) |
| 412 } | 411 } |
| 413 | 412 |
