annotate pathifier.R @ 0:dd01ae279778 draft default tip

"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
author artbio
date Mon, 12 Apr 2021 09:54:52 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
1 ##################################################################################################
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
2 # Running PATHIFIER (Drier et al., 2013)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
3 # Based on the work of Author: Miguel Angel Garcia-Campos - Github: https://github.com/AngelCampos
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
4 ##################################################################################################
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
5
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
6
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
7 options(show.error.messages = F, error = function() {
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
8 cat(geterrmessage(), file = stderr()); q("no", 1, F)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
9 }
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
10 )
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
11 # we need that to not crash galaxy with an UTF8 error on German LC settings.
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
12 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
13
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
14 library(pathifier)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
15 library(optparse)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
16 library(pheatmap)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
17 library(scatterplot3d)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
18 library(circlize)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
19
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
20 option_list <- list(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
21 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
22 "--exp",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
23 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
24 help = "Expression matrix"),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
25 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
26 "--sep",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
27 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
28 default = "\t",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
29 help = "File separator [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
30 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
31 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
32 "--genes",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
33 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
34 help = "Gene sets Pathways : gmt format (one pathway per line : Name, description, genes (one by column), tab separated)"),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
35 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
36 "--is_normal",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
37 default = F,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
38 type = "logical",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
39 help = "Define normals cells in your data"),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
40 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
41 "--normals",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
42 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
43 help = "A vector of sample status : 1 = Healthy, 0 = Tumor. Must be in the same order as in expression data"),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
44 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
45 "--logfile",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
46 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
47 default = "log.txt",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
48 help = "Log file name [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
49 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
50 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
51 "--max_stability",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
52 type = "logical",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
53 default = T,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
54 help = "If true, throw away components leading to low stability of sampling noise [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
55 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
56 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
57 "--attempts",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
58 type = "integer",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
59 default = 10,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
60 help = "Number of runs to determine stability. [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
61 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
62 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
63 "--min_std",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
64 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
65 default = "0.4",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
66 help = "Minimum of standard deviation to filter out low variable genes.
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
67 Use --min.std data, to use the minimum std of your data [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
68 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
69 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
70 "--min_exp",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
71 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
72 default = "4",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
73 help = "Minimum of gene expression to filter out low expressed genes.
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
74 Use --min.exp data, to use the minimum expression of your data [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
75 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
76 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
77 "--pds",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
78 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
79 default = "PDS.tsv",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
80 help = "Output PDS (Pathway deregulation score) of Pathifier in tabular file [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
81 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
82 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
83 "--heatmap_cluster_cells",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
84 type = "logical",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
85 default = TRUE,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
86 help = "Cluster columns (cells) in the heatmap [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
87 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
88 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
89 "--heatmap_cluster_pathways",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
90 type = "logical",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
91 default = TRUE,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
92 help = "Cluster rows (pathways) in the heatmap [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
93 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
94 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
95 "--heatmap_show_cell_labels",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
96 type = "logical",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
97 default = FALSE,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
98 help = "Print column names (cells) on the heatmap [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
99 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
100 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
101 "--heatmap_show_pathway_labels",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
102 type = "logical",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
103 default = FALSE,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
104 help = "Print row names (pathways) on the heatmap [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
105 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
106 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
107 "--plot",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
108 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
109 default = "./plot.pdf",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
110 help = "Pathifier visualization [default : '%default']"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
111 ),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
112 make_option(
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
113 "--rdata",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
114 type = "character",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
115 default = "./results.rdata",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
116 help = "Pathifier object (S4) [default : '%default']"))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
117 parser <- OptionParser(usage = "%prog [options] file", option_list = option_list)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
118 args <- parse_args(parser)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
119 if (args$sep == "tab") {
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
120 args$sep <- "\t"
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
121 }
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
122
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
123
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
124 # set seed for reproducibility
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
125 set.seed(123)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
126
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
127 # Load expression data for PATHIFIER
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
128 exp_matrix <- as.matrix(read.delim(file = args$exp,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
129 as.is = T,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
130 row.names = 1,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
131 sep = args$sep,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
132 check.names = F))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
133
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
134 # Load Genesets annotation
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
135 gene_sets_file <- file(args$genes, open = "r")
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
136 gene_sets <- readLines(gene_sets_file)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
137 close(gene_sets_file)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
138
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
139 # Generate a list that contains genes in genesets
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
140 gs <- strsplit(gene_sets, "\t")
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
141 names(gs) <- lapply(gs, function(x) x[1])
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
142 gs <- lapply(gs, function(x) x[-c(1:2)])
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
143
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
144 # Generate a list that contains the names of the genesets used
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
145 pathwaynames <- names(gs)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
146
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
147 # Prepare data and parameters ##################################################
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
148 # Extract information from binary phenotypes. 1 = Normal, 0 = Tumor
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
149 if (args$is_normal == T) {
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
150 normals <- read.delim(file = args$normals, h = F)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
151 normals <- as.logical(normals[, 2])
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
152 n_exp_matrix <- exp_matrix[, normals]
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
153 } else n_exp_matrix <- exp_matrix
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
154
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
155 # Calculate MIN_STD
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
156 rsd <- apply(n_exp_matrix, 1, sd)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
157 min_std <- quantile(rsd, 0.25)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
158
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
159 # Calculate MIN_EXP
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
160 min_exp <- quantile(as.vector(as.matrix(exp_matrix)),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
161 0.1) # Percentile 10 of data
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
162
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
163 # Filter low value genes. At least 10% of samples with values over min_exp
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
164 # Set expression levels < MIN_EXP to MIN_EXP
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
165 over <- apply(exp_matrix, 1, function(x) x > min_exp)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
166 g_over <- apply(over, 2, mean)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
167 g_over <- names(g_over)[g_over > 0.1]
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
168 exp_matrix_filtered <- exp_matrix[g_over, ]
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
169 exp_matrix_filtered[exp_matrix_filtered < min_exp] <- min_exp
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
170
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
171 # Set maximum 5000 genes with more variance
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
172 variable_genes <- names(sort(apply(exp_matrix_filtered, 1, var), decreasing = T))[1:5000]
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
173 variable_genes <- variable_genes[!is.na(variable_genes)]
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
174 exp_matrix_filtered <- exp_matrix_filtered[variable_genes, ]
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
175 allgenes <- as.vector(rownames(exp_matrix_filtered))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
176
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
177
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
178 if (args$min_std == "data") {
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
179 args$min_std <- min_std
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
180 } else args$min_std <- as.numeric(args$min_std)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
181
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
182 if (args$min_exp == "data") {
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
183 args$min_exp <- min_exp
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
184 } else args$min_exp <- as.numeric(args$min_exp)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
185
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
186
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
187 # Open pdf
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
188 pdf(args$plot)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
189
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
190 # Construct continuous color scale
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
191 col_score_fun <- colorRamp2(c(0, 0.5, 1), c("#4575B4", "#FFFFBF", "#D73027"))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
192
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
193 # Run Pathifier
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
194 if (args$is_normal == T) {
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
195 pds <- quantify_pathways_deregulation(exp_matrix_filtered,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
196 allgenes,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
197 gs,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
198 pathwaynames,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
199 normals,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
200 maximize_stability = args$max_stability,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
201 attempts = args$attempts,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
202 logfile = args$logfile,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
203 min_std = args$min_std,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
204 min_exp = args$min_exp)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
205 for (i in pathwaynames) {
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
206 df <- data.frame(pds$curves[[i]][, 1:3],
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
207 normal = normals,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
208 PDS = as.numeric(pds$scores[[i]]),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
209 curve_order = as.vector(pds$curves_order[[i]]))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
210 ordered <- df[df$curve_order, ]
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
211
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
212
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
213 layout(cbind(1:2, 1:2), heights = c(7, 1))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
214 sc3 <- scatterplot3d(ordered[, 1:3],
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
215 main = paste("Principal curve of", i),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
216 box = F, pch = 19, type = "l")
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
217 sc3$points3d(ordered[, 1:3], box = F, pch = 19,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
218 col = col_score_fun(ordered$PDS))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
219
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
220 # Plot color scale legend
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
221 par(mar = c(5, 3, 0, 3))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
222 plot(seq(min(ordered$PDS), max(ordered$PDS), length = 100), rep(0, 100), pch = 15,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
223 axes = TRUE, yaxt = "n", xlab = "Color scale of PDS", ylab = "", bty = "n",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
224 col = col_score_fun(seq(min(ordered$PDS), max(ordered$PDS), length = 100)))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
225
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
226
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
227 cols_status <- ifelse(ordered$normal, "blue", "red")
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
228 sc3 <- scatterplot3d(ordered[, 1:3],
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
229 main = paste("Principal curve of", i),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
230 box = F, pch = "", type = "l")
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
231 sc3$points3d(ordered[, 1:3], box = F,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
232 pch = ifelse(ordered$normal, 19, 8),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
233 col = ifelse(ordered$normal, "blue", "red"))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
234 legend("topright", pch = c(19, 8), yjust = 0,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
235 legend = c("normal", "cancer"),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
236 col = c("blue", "red"), cex = 1.1)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
237
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
238 ## annotation for heatmap
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
239 sample_status <- data.frame(Status = factor(ifelse(df$normal, "normal", "tumor")))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
240 rownames(sample_status) <- colnames(exp_matrix_filtered)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
241 color_status_heatmap <- list(Status = c(normal = "blue", tumor = "red"))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
242 }
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
243 } else{
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
244 pds <- quantify_pathways_deregulation(exp_matrix_filtered,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
245 allgenes,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
246 gs,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
247 pathwaynames,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
248 maximize_stability = args$max_stability,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
249 attempts = args$attempts,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
250 logfile = args$logfile,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
251 min_std = args$min_std,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
252 min_exp = args$min_exp)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
253 for (i in pathwaynames) {
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
254 df <- data.frame(pds$curves[[i]][, 1:3],
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
255 PDS = as.numeric(pds$scores[[i]]),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
256 curve_order = as.vector(pds$curves_order[[i]]))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
257 ordered <- df[df$curve_order, ]
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
258
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
259 layout(cbind(1:2, 1:2), heights = c(7, 1))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
260 sc3 <- scatterplot3d(ordered[, 1:3],
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
261 main = paste("Principal curve of", i),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
262 box = F, pch = 19, type = "l")
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
263 sc3$points3d(ordered[, 1:3], box = F, pch = 19,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
264 col = col_score_fun(ordered$PDS))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
265
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
266 # Plot color scale legend
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
267 par(mar = c(5, 3, 0, 3))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
268 plot(seq(min(ordered$PDS), max(ordered$PDS), length = 100), rep(0, 100), pch = 15,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
269 axes = TRUE, yaxt = "n", xlab = "Color scale of PDS", ylab = "", bty = "n",
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
270 col = col_score_fun(seq(min(ordered$PDS), max(ordered$PDS), length = 100)))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
271
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
272
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
273 ## annotation for heatmap (for the moment none for this situation)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
274 sample_status <- NA
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
275 color_status_heatmap <- NA
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
276 }
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
277 }
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
278
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
279 ## Create dataframe from Pathifier list and round score to 4 digits
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
280 pds_scores <- mapply(FUN = function(x) cbind(round(x, 4)), pds$scores)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
281 dimnames(pds_scores) <- list(colnames(exp_matrix_filtered), names(pds$scores))
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
282
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
283 ## plot heatmap
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
284 if (ncol(pds_scores) > 1) {
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
285 pheatmap(t(pds_scores),
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
286 main = "Heatmap of Pathway Deregulation Score", # heat map title
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
287 cluster_rows = args$heatmap_cluster_pathways, # apply clustering method
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
288 cluster_cols = args$heatmap_cluster_cells, # apply clustering method
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
289
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
290 #Additional Options
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
291 ## Color labeled columns
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
292 annotation_col = sample_status,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
293 annotation_colors = color_status_heatmap,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
294 show_rownames = args$heatmap_show_pathway_labels,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
295 show_colnames = args$heatmap_show_cell_labels,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
296 border_color = NA,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
297 legend = TRUE)
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
298 }
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
299 dev.off()
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
300
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
301
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
302 ## write table
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
303 write.table(pds_scores,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
304 args$pds,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
305 row.names = T,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
306 col.names = T,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
307 quote = F,
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
308 sep = "\t")
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
309
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
310 ## write S4 pathifier object
dd01ae279778 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/pathifier commit b94cfc7bf8df30aa8e9249b75ea31332ee2bada1"
artbio
parents:
diff changeset
311 save(pds, file = args$rdata)