Mercurial > repos > iuc > egsea
annotate egsea.R @ 0:a8a083193440 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
author | iuc |
---|---|
date | Thu, 25 Jan 2018 02:23:23 -0500 |
parents | |
children | 73281fbdf6c1 |
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 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
4 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
5 # 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
|
6 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
|
7 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
8 suppressPackageStartupMessages({ |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
9 library(EGSEA) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
10 library(limma) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
11 library(edgeR) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
12 library(optparse) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
13 }) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
14 |
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 ## Function Declaration |
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 sanitiseEquation <- function(equation) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
19 equation <- gsub(" *[+] *", "+", equation) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
20 equation <- gsub(" *[-] *", "-", equation) |
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("^\\s+|\\s+$", "", equation) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
24 return(equation) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
25 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
26 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
27 # Function to sanitise group information |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
28 sanitiseGroups <- function(string) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
29 string <- gsub(" *[,] *", ",", string) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
30 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
|
31 return(string) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
32 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
33 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
34 # Generating design information |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
35 pasteListName <- function(string) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
36 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
|
37 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
38 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
39 ## Input Processing |
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 option_list <- list( |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
42 make_option(c("-threads", "--threads"), default=2, type="integer", help="Number of threads for egsea"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
43 make_option(c("-filesPath", "--filesPath"), type="character", help="JSON list object if multiple files input"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
44 make_option(c("-matrixPath", "--matrixPath"), type="character", help="Path to count matrix"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
45 make_option(c("-factFile", "--factFile"), type="character", help="Path to factor information file"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
46 make_option(c("-factInput", "--factInput"), type="character", help="String containing factors if manually input"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
47 make_option(c("-contrastData", "--contrastData"), type="character", help="Contrasts of Interest (Groups to compare)"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
48 make_option(c("-genes", "--genes"), type="character", help="Path to genes file"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
49 make_option(c("-species", "--species"), type="character"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
50 make_option(c("-base_methods", "--base_methods"), type="character", help="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
|
51 make_option(c("-msigdb", "--msigdb"), type="character", help="MSigDB Gene Set Collections"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
52 make_option(c("-keggdb", "--keggdb"), type="character", help="KEGG Pathways"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
53 make_option(c("-gsdb", "--gsdb"), type="character", help = "GeneSetDB Gene Sets"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
54 make_option(c("-display_top", "--display_top"), type="integer", help = "Number of top Gene Sets to display"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
55 make_option(c("-min_size", "--min_size"), type="integer", help = "Minimum Size of Gene Set"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
56 make_option(c("-fdr_cutoff", "--fdr_cutoff"), type="double", help = "FDR cutoff"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
57 make_option(c("-combine_method", "--combine_method"), type="character", help="Method to use to combine the p-values"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
58 make_option(c("-sort_method", "--sort_method"), type="character", help="Method to sort the results"), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
59 make_option(c("-rdata", "--rdaOpt"), type="character", help="Output RData file") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
60 ) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
61 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
62 parser <- OptionParser(usage = "%prog [options] file", option_list=option_list) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
63 args = parse_args(parser) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
64 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
65 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
66 ## Read in Files |
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 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
|
69 # 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
|
70 library("rjson") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
71 parser <- newJSONParser() |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
72 parser$addData(args$filesPath) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
73 factorList <- parser$getObject() |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
74 factors <- sapply(factorList, function(x) x[[1]]) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
75 filenamesIn <- unname(unlist(factorList[[1]][[2]])) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
76 sampleTable <- data.frame(sample=basename(filenamesIn), |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
77 filename=filenamesIn, |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
78 row.names=filenamesIn, |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
79 stringsAsFactors=FALSE) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
80 for (factor in factorList) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
81 factorName <- factor[[1]] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
82 sampleTable[[factorName]] <- character(nrow(sampleTable)) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
83 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
|
84 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
|
85 files <- factor[[2]][[i]][[1]] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
86 sampleTable[files,factorName] <- lvls[i] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
87 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
88 sampleTable[[factorName]] <- factor(sampleTable[[factorName]], levels=lvls) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
89 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
90 rownames(sampleTable) <- sampleTable$sample |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
91 rem <- c("sample","filename") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
92 factors <- sampleTable[, !(names(sampleTable) %in% rem), drop=FALSE] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
93 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
94 #read in count files and create single table |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
95 countfiles <- lapply(sampleTable$filename, function(x){read.delim(x, row.names=1)}) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
96 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
|
97 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
98 } else { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
99 # Process the single count matrix |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
100 counts <- read.table(args$matrixPath, header=TRUE, sep="\t", stringsAsFactors=FALSE) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
101 row.names(counts) <- counts[, 1] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
102 counts <- counts[ , -1] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
103 countsRows <- nrow(counts) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
104 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
105 # Process factors |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
106 if (is.null(args$factInput)) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
107 factorData <- read.table(args$factFile, header=TRUE, sep="\t") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
108 factors <- factorData[, -1, drop=FALSE] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
109 } else { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
110 factors <- unlist(strsplit(args$factInput, "|", fixed=TRUE)) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
111 factorData <- list() |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
112 for (fact in factors) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
113 newFact <- unlist(strsplit(fact, split="::")) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
114 factorData <- rbind(factorData, newFact) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
115 } # 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
|
116 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
117 # Set the row names to be the name of the factor and delete first row |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
118 row.names(factorData) <- factorData[, 1] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
119 factorData <- factorData[, -1] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
120 factorData <- sapply(factorData, sanitiseGroups) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
121 factorData <- sapply(factorData, strsplit, split=",") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
122 factorData <- sapply(factorData, make.names) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
123 # Transform factor data into data frame of R factor objects |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
124 factors <- data.frame(factorData) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
125 } |
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 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
128 # 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
|
129 counts <- DGEList(counts) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
130 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
131 # Set group to be the Primary Factor input |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
132 group <- factors[, 1, drop=FALSE] |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
133 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
134 # Split up contrasts separated by comma into a vector then sanitise |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
135 contrastData <- unlist(strsplit(args$contrastData, split=",")) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
136 contrastData <- sanitiseEquation(contrastData) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
137 contrastData <- gsub(" ", ".", contrastData, fixed=TRUE) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
138 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
139 # Creating design |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
140 row.names(factors) <- colnames(counts) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
141 factorList <- sapply(names(factors), pasteListName) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
142 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
143 formula <- "~0" |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
144 for (i in 1:length(factorList)) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
145 formula <- paste(formula, factorList[i], sep="+") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
146 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
147 formula <- formula(formula) |
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 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
|
150 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
151 for (i in 1:length(factorList)) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
152 colnames(design) <- gsub(factorList[i], "", colnames(design), fixed=TRUE) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
153 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
154 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
155 ## Generate Contrasts information |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
156 contrasts <- makeContrasts(contrasts=contrastData, levels=design) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
157 |
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 ## 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
|
160 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
161 genes <- read.table(args$genes, sep='\t', header=TRUE) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
162 |
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 ## 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
|
165 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
166 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
|
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 ## Set Gene Sets |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
170 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
171 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
|
172 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
|
173 } else { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
174 msigdb <- "none" |
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 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
177 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
|
178 keggdb <- unlist(strsplit(args$keggdb, ",")) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
179 kegg_all <- c("Metabolism"="keggmet", "Signaling"="keggsig", "Disease"="keggdis") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
180 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
|
181 } else { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
182 kegg_exclude <- "all" |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
183 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
184 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
185 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
|
186 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
|
187 } else { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
188 gsdb <- "none" |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
189 } |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
190 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
191 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
192 ## Index gene sets |
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 gs.annots <- buildIdx(entrezIDs=rownames(counts), species=args$species, msigdb.gsets=msigdb, gsdb.gsets=gsdb, kegg.exclude=kegg_exclude) |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
195 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
196 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
197 ## Run egsea.cnt |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
198 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
199 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) |
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 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
202 ## Output RData file |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
203 |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
204 if (!is.null(args$rdata)) { |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
205 save.image(file = "EGSEA_analysis.RData") |
a8a083193440
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/egsea commit 7d0c7d850cd56ea3e54d8c03266f719241b20b8b
iuc
parents:
diff
changeset
|
206 } |