Mercurial > repos > iuc > egsea
annotate egsea.R @ 4:fba1660fb717 draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
author | iuc |
---|---|
date | Mon, 28 Jun 2021 09:45:14 +0000 |
parents | ba2111ae6eb4 |
children |
rev | line source |
---|---|
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
1 # Code based on (and inspired by) the Galaxy limma-voom/edgeR/DESeq2 wrappers |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
2 |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
3 options(show.error.messages = F, error = function() { |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
4 cat(geterrmessage(), file = stderr()); q("no", 1, F) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
5 }) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
6 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
7 # we need that to not crash galaxy with an UTF8 error on German LC settings. |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
8 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
9 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
10 suppressPackageStartupMessages({ |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
11 library(EGSEA) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
12 library(limma) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
13 library(edgeR) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
14 library(optparse) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
15 }) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
16 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
17 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
18 ## Function Declaration |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
19 |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
20 sanitise_equation <- function(equation) { |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
21 equation <- gsub(" *[+] *", "+", equation) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
22 equation <- gsub(" *[-] *", "-", equation) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
23 equation <- gsub(" *[/] *", "/", equation) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
24 equation <- gsub(" *[*] *", "*", equation) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
25 equation <- gsub("^\\s+|\\s+$", "", equation) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
26 return(equation) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
27 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
28 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
29 # Function to sanitise group information |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
30 sanitise_groups <- function(string) { |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
31 string <- gsub(" *[,] *", ",", string) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
32 string <- gsub("^\\s+|\\s+$", "", string) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
33 return(string) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
34 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
35 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
36 # Generating design information |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
37 paste_listname <- function(string) { |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
38 return(paste0("factors$", string)) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
39 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
40 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
41 ## Input Processing |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
42 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
43 option_list <- list( |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
44 make_option("--threads", default = 2, type = "integer", help = "Number of threads for egsea"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
45 make_option("--filesPath", type = "character", help = "JSON list object if multiple files input"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
46 make_option("--matrixPath", type = "character", help = "Path to count matrix"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
47 make_option("--factFile", type = "character", help = "Path to factor information file"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
48 make_option("--factInput", type = "character", help = "String containing factors if manually input"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
49 make_option("--contrastData", type = "character", help = "Contrasts of Interest (Groups to compare)"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
50 make_option("--genes", type = "character", help = "Path to genes file"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
51 make_option("--species", type = "character"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
52 make_option("--base_methods", type = "character", help = "Gene set testing methods"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
53 make_option("--msigdb", type = "character", help = "MSigDB Gene Set Collections"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
54 make_option("--keggdb", type = "character", help = "KEGG Pathways"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
55 make_option("--keggupdated", type = "logical", help = "Use updated KEGG"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
56 make_option("--gsdb", type = "character", help = "GeneSetDB Gene Sets"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
57 make_option("--display_top", type = "integer", help = "Number of top Gene Sets to display"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
58 make_option("--min_size", type = "integer", help = "Minimum Size of Gene Set"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
59 make_option("--fdr_cutoff", type = "double", help = "FDR cutoff"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
60 make_option("--combine_method", type = "character", help = "Method to use to combine the p-values"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
61 make_option("--sort_method", type = "character", help = "Method to sort the results"), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
62 make_option("--rdaOpt", type = "character", help = "Output RData file") |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
63 ) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
64 |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
65 parser <- OptionParser(usage = "%prog [options] file", option_list = option_list) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
66 args <- parse_args(parser) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
67 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
68 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
69 ## Read in Files |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
70 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
71 if (!is.null(args$filesPath)) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
72 # Process the separate count files (adapted from DESeq2 wrapper) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
73 library("rjson") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
74 parser <- newJSONParser() |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
75 parser$addData(args$filesPath) |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
76 factor_list <- parser$getObject() |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
77 factors <- sapply(factor_list, function(x) x[[1]]) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
78 filenames_in <- unname(unlist(factor_list[[1]][[2]])) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
79 sampletable <- data.frame(sample = basename(filenames_in), |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
80 filename = filenames_in, |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
81 row.names = filenames_in, |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
82 stringsAsFactors = FALSE) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
83 for (factor in factor_list) { |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
84 factorname <- factor[[1]] |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
85 sampletable[[factorname]] <- character(nrow(sampletable)) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
86 lvls <- sapply(factor[[2]], function(x) names(x)) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
87 for (i in seq_along(factor[[2]])) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
88 files <- factor[[2]][[i]][[1]] |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
89 sampletable[files, factorname] <- lvls[i] |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
90 } |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
91 sampletable[[factorname]] <- factor(sampletable[[factorname]], levels = lvls) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
92 } |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
93 rownames(sampletable) <- sampletable$sample |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
94 rem <- c("sample", "filename") |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
95 factors <- sampletable[, !(names(sampletable) %in% rem), drop = FALSE] |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
96 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
97 #read in count files and create single table |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
98 countfiles <- lapply(sampletable$filename, function(x) { |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
99 read.delim(x, row.names = 1) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
100 }) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
101 counts <- do.call("cbind", countfiles) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
102 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
103 } else { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
104 # Process the single count matrix |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
105 counts <- read.table(args$matrixPath, header = TRUE, sep = "\t", stringsAsFactors = FALSE, check.names = FALSE) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
106 row.names(counts) <- counts[, 1] |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
107 counts <- counts[, -1] |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
108 countsrows <- nrow(counts) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
109 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
110 # Process factors |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
111 if (is.null(args$factInput)) { |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
112 factordata <- read.table(args$factFile, header = TRUE, sep = "\t", strip.white = TRUE, stringsAsFactors = TRUE) |
2
ba2111ae6eb4
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit ee9b940a5ffa6c52e42a89e55c0f5bdda0a386d5
iuc
parents:
1
diff
changeset
|
113 # check samples names match |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
114 if (!any(factordata[, 1] %in% colnames(counts))) |
2
ba2111ae6eb4
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit ee9b940a5ffa6c52e42a89e55c0f5bdda0a386d5
iuc
parents:
1
diff
changeset
|
115 stop("Sample IDs in factors file and count matrix don't match") |
ba2111ae6eb4
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit ee9b940a5ffa6c52e42a89e55c0f5bdda0a386d5
iuc
parents:
1
diff
changeset
|
116 # order samples as in counts matrix |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
117 factordata <- factordata[match(colnames(counts), factordata[, 1]), ] |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
118 factors <- factordata[, -1, drop = FALSE] |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
119 } else { |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
120 factors <- unlist(strsplit(args$factInput, "|", fixed = TRUE)) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
121 factordata <- list() |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
122 for (fact in factors) { |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
123 newfact <- unlist(strsplit(fact, split = "::")) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
124 factordata <- rbind(factordata, newfact) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
125 } # Factors have the form: FACT_NAME::LEVEL,LEVEL,LEVEL,LEVEL,... The first factor is the Primary Factor. |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
126 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
127 # Set the row names to be the name of the factor and delete first row |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
128 row.names(factordata) <- factordata[, 1] |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
129 factordata <- factordata[, -1] |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
130 factordata <- sapply(factordata, sanitise_groups) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
131 factordata <- sapply(factordata, strsplit, split = ",") |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
132 factordata <- sapply(factordata, make.names) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
133 # Transform factor data into data frame of R factor objects |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
134 factors <- data.frame(factordata, stringsAsFactors = TRUE) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
135 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
136 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
137 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
138 # Create a DGEList object |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
139 counts <- DGEList(counts) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
140 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
141 # Set group to be the Primary Factor input |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
142 group <- factors[, 1, drop = FALSE] |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
143 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
144 # Split up contrasts separated by comma into a vector then sanitise |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
145 contrast_data <- unlist(strsplit(args$contrastData, split = ",")) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
146 contrast_data <- sanitise_equation(contrast_data) |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
147 contrast_data <- gsub(" ", ".", contrast_data, fixed = TRUE) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
148 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
149 # Creating design |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
150 row.names(factors) <- colnames(counts) |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
151 factor_list <- sapply(names(factors), paste_listname) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
152 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
153 formula <- "~0" |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
154 for (i in seq_along(factor_list)) { |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
155 formula <- paste(formula, factor_list[i], sep = "+") |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
156 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
157 formula <- formula(formula) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
158 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
159 design <- model.matrix(formula) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
160 |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
161 for (i in seq_along(factor_list)) { |
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
162 colnames(design) <- gsub(factor_list[i], "", colnames(design), fixed = TRUE) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
163 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
164 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
165 ## Generate Contrasts information |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
166 contrasts <- makeContrasts(contrasts = contrast_data, levels = design) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
167 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
168 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
169 ## Add Gene Symbol information |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
170 |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
171 genes <- read.table(args$genes, sep = "\t", header = TRUE) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
172 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
173 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
174 ## Set Gene Set Testing Methods |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
175 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
176 base_methods <- unlist(strsplit(args$base_methods, ",")) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
177 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
178 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
179 ## Set Gene Sets |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
180 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
181 if (args$msigdb != "None") { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
182 msigdb <- unlist(strsplit(args$msigdb, ",")) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
183 } else { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
184 msigdb <- "none" |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
185 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
186 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
187 if (args$keggdb != "None") { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
188 keggdb <- unlist(strsplit(args$keggdb, ",")) |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
189 kegg_all <- c("Metabolism" = "keggmet", "Signaling" = "keggsig", "Disease" = "keggdis") |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
190 kegg_exclude <- names(kegg_all[!(kegg_all %in% keggdb)]) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
191 } else { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
192 kegg_exclude <- "all" |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
193 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
194 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
195 if (args$gsdb != "None") { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
196 gsdb <- unlist(strsplit(args$gsdb, ",")) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
197 } else { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
198 gsdb <- "none" |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
199 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
200 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
201 ## Index gene sets |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
202 |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
203 gs_annots <- buildIdx(entrezIDs = rownames(counts), species = args$species, msigdb.gsets = msigdb, gsdb.gsets = gsdb, kegg.exclude = kegg_exclude, kegg.updated = args$keggupdated) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
204 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
205 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
206 ## Run egsea.cnt |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
207 |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
208 gsa <- egsea.cnt(counts = counts, group = group, design = design, contrasts = contrasts, gs.annots = gs_annots, symbolsMap = genes, baseGSEAs = base_methods, minSize = args$min_size, display.top = args$display_top, combineMethod = args$combine_method, sort.by = args$sort_method, report.dir = "./report_dir", fdr.cutoff = args$fdr_cutoff, num.threads = args$threads, report = TRUE) |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
209 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
210 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
211 ## Output RData file |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
212 |
1
73281fbdf6c1
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 225518a08941e7ef8e5c402e3696ec5fa6e592a0
iuc
parents:
0
diff
changeset
|
213 if (!is.null(args$rdaOpt)) { |
0
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
214 save.image(file = "EGSEA_analysis.RData") |
4
fba1660fb717
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit c2313b506b3b8ae860bb844b979397d87de4fb44"
iuc
parents:
2
diff
changeset
|
215 } |