Mercurial > repos > iuc > multigsea
annotate multiGSEA.R @ 0:28e29a3d0eda draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
author | iuc |
---|---|
date | Wed, 07 Jun 2023 19:48:50 +0000 |
parents | |
children | e48b10ce08b8 |
rev | line source |
---|---|
0
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
1 library(multiGSEA, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
2 quietly = TRUE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
3 warn.conflicts = FALSE) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
4 library(argparse, quietly = TRUE, warn.conflicts = FALSE) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
5 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
6 ################################################################################ |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
7 ### Input Processing |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
8 ################################################################################ |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
9 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
10 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
11 # Collect arguments from command line |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
12 parser <- ArgumentParser(description = "multiGSEA R script") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
13 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
14 parser$add_argument("--transcriptomics", required = FALSE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
15 help = "Transcriptomics data") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
16 parser$add_argument( |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
17 "--transcriptome_ids", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
18 required = FALSE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
19 help = "Transcriptomics ids", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
20 default = "SYMBOL" |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
21 ) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
22 parser$add_argument("--proteomics", required = FALSE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
23 help = "Proteomics data") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
24 parser$add_argument( |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
25 "--proteome_ids", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
26 required = FALSE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
27 help = "Proteomics ids", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
28 default = "SYMBOL" |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
29 ) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
30 parser$add_argument("--metabolomics", required = FALSE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
31 help = "Metabolomics data") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
32 parser$add_argument( |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
33 "--metabolome_ids", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
34 required = FALSE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
35 help = "Metabolomics ids", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
36 default = "HMDB" |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
37 ) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
38 parser$add_argument("--organism", required = TRUE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
39 help = "Organism") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
40 parser$add_argument("--combine_pvalues", required = TRUE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
41 help = "Combine p-values method") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
42 parser$add_argument("--padj_method", required = TRUE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
43 help = "P-adjustment method") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
44 parser$add_argument("--databases", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
45 required = TRUE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
46 help = "Pathway databases") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
47 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
48 args <- parser$parse_args() |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
49 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
50 ## ----Load library------------------------------------------------------------- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
51 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
52 organism_mapping <- c( |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
53 "hsapiens" = "org.Hs.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
54 "mmusculus" = "org.Mm.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
55 "rnorvegicus" = "org.Rn.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
56 "cfamiliaris" = "org.Cf.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
57 "btaurus" = "org.Bt.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
58 "sscrofa" = "org.Ss.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
59 "ggallus" = "org.Gg.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
60 "drerio" = "org.Xl.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
61 "xlaevis" = "org.Dr.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
62 "dmelanogaster" = "org.Dm.eg.db", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
63 "celegans" = "org.Ce.eg.db" |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
64 ) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
65 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
66 library(organism_mapping[args$organism], character.only = TRUE) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
67 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
68 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
69 ## ----Load omics data---------------------------------------------------------- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
70 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
71 layer <- c() |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
72 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
73 if (!is.null(args$transcriptomics)) { |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
74 transcriptome <- read.csv( |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
75 args$transcriptomics, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
76 header = TRUE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
77 sep = "\t", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
78 dec = "." |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
79 ) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
80 layer <- append(layer, "transcriptome") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
81 } |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
82 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
83 if (!is.null(args$proteomics)) { |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
84 proteome <- read.csv(args$proteomics, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
85 header = TRUE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
86 sep = "\t", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
87 dec = ".") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
88 layer <- append(layer, "proteome") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
89 } |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
90 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
91 if (!is.null(args$metabolomics)) { |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
92 metabolome <- read.csv(args$metabolomics, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
93 header = TRUE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
94 sep = "\t", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
95 dec = ".") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
96 layer <- append(layer, "metabolome") |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
97 } |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
98 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
99 ## ----rank_features------------------------------------------------------------ |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
100 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
101 # create data structure |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
102 omics_data <- initOmicsDataStructure(layer) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
103 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
104 ## add transcriptome layer |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
105 if (!is.null(args$transcriptomics)) { |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
106 omics_data$transcriptome <- rankFeatures(transcriptome$logFC, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
107 transcriptome$pValue) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
108 names(omics_data$transcriptome) <- transcriptome$Symbol |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
109 } |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
110 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
111 ## add proteome layer |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
112 if (!is.null(args$proteomics)) { |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
113 omics_data$proteome <- rankFeatures(proteome$logFC, proteome$pValue) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
114 names(omics_data$proteome) <- proteome$Symbol |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
115 } |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
116 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
117 ## add metabolome layer |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
118 ## HMDB features have to be updated to the new HMDB format |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
119 if (!is.null(args$metabolomics)) { |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
120 omics_data$metabolome <- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
121 rankFeatures(metabolome$logFC, metabolome$pValue) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
122 names(omics_data$metabolome) <- metabolome$HMDB |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
123 names(omics_data$metabolome) <- gsub("HMDB", "HMDB00", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
124 names(omics_data$metabolome)) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
125 } |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
126 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
127 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
128 ## remove NA's and sort feature ranks |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
129 omics_data <- lapply(omics_data, function(vec) { |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
130 sort(vec[!is.na(vec)]) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
131 }) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
132 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
133 ## ----Pathway definitions------------------------------------------------------ |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
134 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
135 pathways <- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
136 getMultiOmicsFeatures( |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
137 dbs = unlist(strsplit(args$databases, ",", fixed = TRUE)), |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
138 layer = layer, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
139 returnTranscriptome = args$transcriptome_ids, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
140 returnProteome = args$proteome_ids, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
141 returnMetabolome = args$metabolome_ids, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
142 organism = args$organism, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
143 useLocal = FALSE |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
144 ) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
145 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
146 ## ----calculate enrichment----------------------------------------------------- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
147 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
148 enrichment_scores <- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
149 multiGSEA(pathways, omics_data) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
150 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
151 ## ----combine_pvalues---------------------------------------------------------- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
152 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
153 df <- extractPvalues(enrichmentScores = enrichment_scores, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
154 pathwayNames = names(pathways[[1]])) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
155 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
156 df$combined_pval <- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
157 combinePvalues(df, method = args$combine_pvalues) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
158 df$combined_padj <- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
159 p.adjust(df$combined_pval, method = args$padj_method) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
160 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
161 df <- cbind(data.frame(pathway = names(pathways[[1]])), df) |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
162 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
163 ## ----Write output------------------------------------------------------------- |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
164 |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
165 write.table( |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
166 df, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
167 file = "results.tsv", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
168 quote = FALSE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
169 sep = "\t", |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
170 col.names = TRUE, |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
171 row.names = FALSE |
28e29a3d0eda
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/multigsea commit 5c1b8a2b105a80e236f88e71a743147d79925ac4
iuc
parents:
diff
changeset
|
172 ) |