comparison edger.R @ 14:070900306913 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
author iuc
date Wed, 11 Oct 2023 11:13:07 +0000
parents 0cb907a2a810
children 5bf899c13979
comparison
equal deleted inserted replaced
13:0cb907a2a810 14:070900306913
6 # outPath", "o", 1, "character" -Path to folder to write all output to 6 # outPath", "o", 1, "character" -Path to folder to write all output to
7 # filesPath", "j", 2, "character" -JSON list object if multiple files input 7 # filesPath", "j", 2, "character" -JSON list object if multiple files input
8 # matrixPath", "m", 2, "character" -Path to count matrix 8 # matrixPath", "m", 2, "character" -Path to count matrix
9 # factFile", "f", 2, "character" -Path to factor information file 9 # factFile", "f", 2, "character" -Path to factor information file
10 # factInput", "i", 2, "character" -String containing factors if manually input 10 # factInput", "i", 2, "character" -String containing factors if manually input
11 # formula", "F", 2, "character". -String containing a formula to override default use of factInput
11 # annoPath", "a", 2, "character" -Path to input containing gene annotations 12 # annoPath", "a", 2, "character" -Path to input containing gene annotations
12 # contrastData", "C", 1, "character" -String containing contrasts of interest 13 # contrastData", "C", 1, "character" -String containing contrasts of interest
13 # cpmReq", "c", 2, "double" -Float specifying cpm requirement 14 # cpmReq", "c", 2, "double" -Float specifying cpm requirement
14 # cntReq", "z", 2, "integer" -Integer specifying minimum total count requirement 15 # cntReq", "z", 2, "integer" -Integer specifying minimum total count requirement
15 # sampleReq", "s", 2, "integer" -Integer specifying cpm requirement 16 # sampleReq", "s", 2, "integer" -Integer specifying cpm requirement
157 "htmlPath", "R", 1, "character", 158 "htmlPath", "R", 1, "character",
158 "outPath", "o", 1, "character", 159 "outPath", "o", 1, "character",
159 "filesPath", "j", 2, "character", 160 "filesPath", "j", 2, "character",
160 "matrixPath", "m", 2, "character", 161 "matrixPath", "m", 2, "character",
161 "factFile", "f", 2, "character", 162 "factFile", "f", 2, "character",
163 "formula", "F", 2, "character",
162 "factInput", "i", 2, "character", 164 "factInput", "i", 2, "character",
163 "annoPath", "a", 2, "character", 165 "annoPath", "a", 2, "character",
164 "contrastData", "C", 1, "character", 166 "contrastData", "C", 1, "character",
165 "cpmReq", "c", 1, "double", 167 "cpmReq", "c", 1, "double",
166 "totReq", "y", 0, "logical", 168 "totReq", "y", 0, "logical",
310 312
311 # Create output directory 313 # Create output directory
312 out_path <- opt$outPath 314 out_path <- opt$outPath
313 dir.create(out_path, showWarnings = FALSE) 315 dir.create(out_path, showWarnings = FALSE)
314 316
315 # Split up contrasts separated by comma into a vector then sanitise 317 # Check if contrastData is a file or not
316 contrast_data <- unlist(strsplit(opt$contrastData, split = ",")) 318 if (file.exists(opt$contrastData)) {
319 contrast_data <- unlist(read.table(opt$contrastData, sep = "\t", header = TRUE)[[1]])
320 } else {
321 # Split up contrasts separated by comma into a vector then sanitise
322 contrast_data <- unlist(strsplit(opt$contrastData, split = ","))
323 }
317 contrast_data <- sanitise_equation(contrast_data) 324 contrast_data <- sanitise_equation(contrast_data)
318 contrast_data <- gsub(" ", ".", contrast_data, fixed = TRUE) 325 contrast_data <- gsub(" ", ".", contrast_data, fixed = TRUE)
319 326
320 bcv_pdf <- make_out("bcvplot.pdf") 327 bcv_pdf <- make_out("bcvplot.pdf")
321 bcv_png <- make_out("bcvplot.png") 328 bcv_png <- make_out("bcvplot.png")
395 colnames(data) <- samplenames 402 colnames(data) <- samplenames
396 data$samples <- factors 403 data$samples <- factors
397 data$genes <- genes 404 data$genes <- genes
398 405
399 406
400 407 if (!is.null(opt$formula)) {
401 formula <- "~0" 408 formula <- opt$formula
402 for (i in seq_along(factor_list)) { 409 # sanitisation can be getting rid of the "~"
403 formula <- paste(formula, factor_list[i], sep = "+") 410 if (!startsWith(formula, "~")) {
411 formula <- paste0("~", formula)
412 }
413 } else {
414 formula <- "~0"
415 for (i in seq_along(factor_list)) {
416 formula <- paste(formula, factor_list[i], sep = "+")
417 }
404 } 418 }
405 419
406 formula <- formula(formula) 420 formula <- formula(formula)
407 design <- model.matrix(formula, factors) 421 design <- model.matrix(formula, factors)
408 422