annotate pathifier.R @ 1:0960bd1161fa draft default tip

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