annotate dexseq.R @ 7:62adf13b86ea draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
author iuc
date Fri, 19 Mar 2021 09:45:03 +0000
parents 278b189248cd
children df929f257179
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
1 ## Setup R error handling to go to stderr
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
2 options(show.error.messages = F, error = function() {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
3 cat(geterrmessage(), file = stderr()); q("no", 1, F)
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
4 })
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
5 # we need that to not crash galaxy with an UTF8 error on German LC settings.
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
6 Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
7
2
6e8b61c54ff3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 0a56599c36b4968095ec5a3cb589f94fb139466c
iuc
parents: 0
diff changeset
8 suppressPackageStartupMessages({
6e8b61c54ff3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 0a56599c36b4968095ec5a3cb589f94fb139466c
iuc
parents: 0
diff changeset
9 library("DEXSeq")
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
10 library("getopt")
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
11 library("rjson")
2
6e8b61c54ff3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 0a56599c36b4968095ec5a3cb589f94fb139466c
iuc
parents: 0
diff changeset
12 })
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
13
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
14
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
15 options(stringAsfactors = FALSE, useFancyQuotes = FALSE)
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
16 args <- commandArgs(trailingOnly = TRUE)
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
17
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
18 #get options, using the spec as defined by the enclosed list.
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
19 #we read the options from the default: commandArgs(TRUE).
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
20 spec <- matrix(c(
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
21 "verbose", "v", 2, "integer",
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
22 "help", "h", 0, "logical",
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
23 "gtf", "a", 1, "character",
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
24 "outfile", "o", 1, "character",
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
25 "reportdir", "r", 1, "character",
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
26 "rds", "d", 1, "character",
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
27 "factors", "f", 1, "character",
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
28 "threads", "p", 1, "integer",
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
29 "fdr", "c", 1, "double"
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
30 ), byrow = TRUE, ncol = 4);
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
31 opt <- getopt(spec);
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
32
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
33 # if help was asked for print a friendly message
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
34 # and exit with a non-zero error code
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
35 if (!is.null(opt$help)) {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
36 cat(getopt(spec, usage = TRUE));
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
37 q(status = 1);
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
38 }
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
39
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
40 trim <- function(x) gsub("^\\s+|\\s+$", "", x)
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
41 opt$samples <- trim(opt$samples)
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
42 opt$factors <- trim(opt$factors)
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
43
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
44 parser <- newJSONParser()
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
45 parser$addData(opt$factors)
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
46 factors_list <- parser$getObject()
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
47
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
48 sample_table <- data.frame()
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
49 count_files <- c()
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
50 factor_names <- c()
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
51 primary_factor <- ""
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
52 for (factor in factors_list) {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
53 factor_name <- factor[[1]]
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
54 factor_names <- append(factor_names, paste(factor_name, "exon", sep = ":"))
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
55 factor_values_map_list <- factor[[2]]
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
56 c <- length(factor_values_map_list)
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
57 for (factorValuesMap in factor_values_map_list) {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
58 for (files in factorValuesMap) {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
59 for (file in files) {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
60 if (primary_factor == "") {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
61 count_files <- append(count_files, file)
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
62 }
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
63 sample_table[basename(file), factor_name] <- paste(c, names(factorValuesMap), sep = "_")
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
64 }
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
65 }
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
66 c <- c - 1
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
67 }
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
68 if (primary_factor == "") {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
69 primary_factor <- factor_name
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
70 }
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
71 }
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
72
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
73 factor_names <- append(factor_names, "exon")
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
74 factor_names <- append(factor_names, "sample")
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
75 factor_names <- rev(factor_names)
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
76 formula_full_model <- as.formula(paste("", paste(factor_names, collapse = " + "), sep = " ~ "))
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
77 factor_names <- head(factor_names, -1)
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
78 formula_reduced_model <- as.formula(paste("", paste(factor_names, collapse = " + "), sep = " ~ "))
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
79
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
80 sample_table
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
81 formula_full_model
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
82 formula_reduced_model
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
83 primary_factor
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
84 count_files
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
85 opt$reportdir
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
86 opt$threads
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
87 getwd()
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
88
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
89 dxd <- DEXSeqDataSetFromHTSeq(count_files, sampleData = sample_table, design = formula_full_model, flattenedfile = opt$gtf)
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
90
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
91 colData(dxd)
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
92 dxd <- estimateSizeFactors(dxd)
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
93 print("Estimated size factors")
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
94 sizeFactors(dxd)
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
95 bpparam <- MulticoreParam(workers = opt$threads)
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
96 dxd <- estimateDispersions(dxd, formula = formula_full_model, BPPARAM = bpparam)
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
97 print("Estimated dispersions")
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
98 dxd <- testForDEU(dxd, reducedModel = formula_reduced_model, fullModel = formula_full_model, BPPARAM = bpparam)
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
99 print("tested for DEU")
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
100 dxd <- estimateExonFoldChanges(dxd, fitExpToVar = primary_factor, BPPARAM = bpparam)
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
101 print("Estimated fold changes")
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
102 res <- DEXSeqResults(dxd)
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
103 print("Results")
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
104 table(res$padj <= opt$fdr)
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
105 res_sorted <- res[order(res$padj), ]
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
106 head(res_sorted)
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
107
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
108 export_table <- as.data.frame(res_sorted)
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
109 last_column <- ncol(export_table)
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
110 for (i in seq_len(nrow(export_table))) {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
111 export_table[i, last_column] <- paste(export_table[i, last_column][[1]], collapse = ", ")
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
112 }
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
113 write.table(export_table, file = opt$outfile, sep = "\t", quote = FALSE, col.names = FALSE)
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
114 print("Written Results")
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
115
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
116 if (!is.null(opt$rds)) {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
117 saveRDS(res, file = "DEXSeqResults.rds")
5
278b189248cd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit c027cb925607cda29bb1e78fe76716af49a276ca
iuc
parents: 2
diff changeset
118 }
278b189248cd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit c027cb925607cda29bb1e78fe76716af49a276ca
iuc
parents: 2
diff changeset
119
7
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
120 if (!is.null(opt$reportdir)) {
62adf13b86ea "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 06f2c57b523aab7c997d82e1345fd23f178de598"
iuc
parents: 5
diff changeset
121 DEXSeqHTML(res, fitExpToVar = primary_factor, path = opt$reportdir, FDR = opt$fdr, color = c("#B7FEA0", "#FF8F43", "#637EE9", "#FF0000", "#F1E7A1", "#C3EEE7", "#CEAEFF", "#EDC3C5", "#AAA8AA"))
0
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
122 }
4ca0e679f21e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit 876fc32b23d3b9c378ddbfbbba27d37d22576c85
iuc
parents:
diff changeset
123 sessionInfo()