annotate signature_score.R @ 4:31da579595c5 draft default tip

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
author artbio
date Sun, 10 Dec 2023 04:11:16 +0000
parents 3351ca630a01
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
1 # Signature score
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
2 # Compute the signature score based on the geometric mean of the target gene expression
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
3 # and split cells in 2 groups (high/low) using this signature score.
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
4
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
5 options(show.error.messages = FALSE,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
6 error = function() {
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
7 cat(geterrmessage(), file = stderr())
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
8 q("no", 1, FALSE)
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
9 }
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
10 )
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
11 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
12 warnings()
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
13
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
14 library(optparse)
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
15 library(psych)
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
16 library(ggplot2)
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
17 library(gridExtra)
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
18
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
19 # Arguments
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
20 option_list <- list(
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
21 make_option(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
22 "--input",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
23 default = NA,
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
24 type = "character",
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
25 help = "Input file that contains log2(CPM +1) values"
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
26 ),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
27 make_option(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
28 "--sep",
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
29 default = "\t",
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
30 type = "character",
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
31 help = "File separator [default : '%default' ]"
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
32 ),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
33 make_option(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
34 "--colnames",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
35 default = TRUE,
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
36 type = "logical",
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
37 help = "Consider first line as header ? [default : '%default' ]"
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
38 ),
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
39 make_option(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
40 "--genes",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
41 default = NA,
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
42 type = "character",
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
43 help = "List of genes comma separated"
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
44 ),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
45 make_option(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
46 "--percentile_threshold",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
47 default = 20,
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
48 type = "integer",
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
49 help = "detection threshold to keep a gene in signature set [default : '%default' ]"
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
50 ),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
51 make_option(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
52 "--output",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
53 default = "./output.tab",
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
54 type = "character",
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
55 help = "Output path [default : '%default' ]"
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
56 ),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
57 make_option(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
58 "--stats",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
59 default = "./statistics.tab",
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
60 type = "character",
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
61 help = "statistics path [default : '%default' ]"
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
62 ),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
63 make_option(
2
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
64 "--correlations",
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
65 default = "./correlations.tab",
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
66 type = "character",
2
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
67 help = "Correlations between signature genes [default : '%default' ]"
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
68 ),
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
69 make_option(
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
70 "--covariances",
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
71 default = "./statistics.tab",
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
72 type = "character",
2
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
73 help = "Covariances between signature genes [default : '%default' ]"
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
74 ),
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
75 make_option(
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
76 "--pdf",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
77 default = "~/output.pdf",
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
78 type = "character",
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
79 help = "pdf path [default : '%default' ]"
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
80 )
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
81 )
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
82
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
83 opt <- parse_args(OptionParser(option_list = option_list),
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
84 args = commandArgs(trailingOnly = TRUE))
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
85
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
86 if (opt$sep == "tab") {
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
87 opt$sep <- "\t"
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
88 }
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
89 if (opt$sep == "comma") {
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
90 opt$sep <- ","
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
91 }
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
92
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
93 # Take input data
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
94 data.counts <- read.table(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
95 opt$input,
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
96 h = opt$colnames,
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
97 row.names = 1,
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
98 sep = opt$sep,
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
99 check.names = FALSE
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
100 )
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
101
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
102 # Get vector of target genes
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
103 genes <- unlist(strsplit(opt$genes, ","))
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
104
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
105 if (length(unique(genes %in% rownames(data.counts))) == 1) {
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
106 if (unique(genes %in% rownames(data.counts)) == FALSE)
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
107 stop("None of these genes are in your dataset: ", opt$genes)
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
108 }
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
109
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
110 logical_genes <- rownames(data.counts) %in% genes
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
111
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
112 # Retrieve target genes in counts data
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
113 signature.counts <- subset(data.counts, logical_genes)
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
114
2
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
115 # compute covariance
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
116 signature.covariances <- as.data.frame(cov(t(signature.counts)))
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
117 signature.covariances <- cbind(gene = rownames(signature.covariances), signature.covariances)
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
118 write.table(signature.covariances,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
119 file = opt$covariances,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
120 quote = FALSE,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
121 row.names = FALSE,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
122 sep = "\t")
2
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
123
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
124 # compute signature.correlations
3
3351ca630a01 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit b2f58ce7826f8d9fe5524a6f2c5688ac816bb559"
artbio
parents: 2
diff changeset
125 signature.correlations <- as.data.frame(cor(t(signature.counts)))
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
126 signature.correlations <- cbind(gene = rownames(signature.correlations), signature.correlations)
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
127 write.table(signature.correlations, file = opt$correlations, quote = FALSE, row.names = FALSE, sep = "\t")
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
128
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
129 ## Descriptive Statistics Function
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
130 descriptive_stats <- function(InputData) {
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
131 SummaryData <- data.frame(
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
132 mean = rowMeans(InputData),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
133 SD = apply(InputData, 1, sd),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
134 Variance = apply(InputData, 1, var),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
135 Percentage_Detection = apply(InputData, 1, function(x, y = InputData) {
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
136 (sum(x != 0) / ncol(y)) * 100
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
137 })
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
138 )
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
139 return(SummaryData)
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
140 }
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
141
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
142 signature_stats <- descriptive_stats(signature.counts)
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
143
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
144 # Find poorly detected genes from the signature
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
145 kept_genes <- signature_stats$Percentage_Detection >= opt$percentile_threshold
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
146
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
147 # Add warnings
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
148 if (length(unique(kept_genes)) > 1) {
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
149 cat(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
150 "WARNINGS ! Following genes were removed from further analysis due to low gene expression :",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
151 paste(paste(rownames(signature.counts)[!kept_genes], round(signature_stats$Percentage_Detection[!kept_genes], 2), sep = " : "), collapse = ", "),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
152 "\n"
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
153 )
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
154 } else {
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
155 if (unique(kept_genes) == FALSE) {
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
156 stop(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
157 "None of these genes are detected in ",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
158 opt$percent,
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
159 "% of your cells: ",
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
160 paste(rownames(signature_stats), collapse = ", "),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
161 ". You can be less stringent thanks to --percent parameter."
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
162 )
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
163 }
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
164 }
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
165
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
166 # Remove genes poorly detected in the dataset
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
167 signature.counts <- signature.counts[kept_genes, ]
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
168
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
169 # Replace 0 by 1 counts
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
170 signature.counts[signature.counts == 0] <- 1
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
171
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
172 # Geometric mean by cell
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
173 score <- apply(signature.counts, 2, geometric.mean) # geometric.mean requires psych
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
174
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
175 # Add results in signature_output
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
176 signature_output <- data.frame(cell = names(score),
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
177 score = score,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
178 rate = ifelse(score > mean(score), "HIGH", "LOW"),
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
179 nGenes = colSums(data.counts != 0),
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
180 total_counts = colSums(data.counts))
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
181
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
182 # statistics of input genes, signature genes first lines
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
183 statistics.counts <- rbind(subset(data.counts, logical_genes),
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
184 subset(data.counts, !logical_genes))
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
185 statistics <- descriptive_stats(statistics.counts)
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
186 statistics <- cbind(gene = rownames(statistics), statistics)
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
187
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
188
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
189
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
190 # Re-arrange score matrix for plots
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
191 score <- data.frame(score = score,
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
192 order = rank(score, ties.method = "first"),
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
193 signature = signature_output$rate,
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
194 stringsAsFactors = FALSE)
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
195
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
196 pdf(file = opt$pdf)
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
197 myplot <- ggplot(signature_output, aes(x = rate, y = score)) +
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
198 geom_violin(aes(fill = rate), alpha = .5, trim = FALSE, show.legend = FALSE, cex = 0.5) +
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
199 geom_abline(slope = 0, intercept = mean(score$score), lwd = 0.5, color = "red") +
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
200 scale_fill_manual(values = c("#ff0000", "#08661e")) +
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
201 geom_jitter(size = 0.2) + labs(y = "Score", x = "Rate") +
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
202 annotate("text", x = 0.55, y = mean(score$score), cex = 3, vjust = 1.5,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
203 color = "black", label = mean(score$score), parse = TRUE) +
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
204 labs(title = "Violin plots of Cell signature scores")
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
205
2
e08419b8ec24 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 987e0ceb55e8de1d2f09d0f2ae48ff7cd3e82051
artbio
parents: 0
diff changeset
206 print(myplot)
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
207 dev.off()
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
208
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
209 # Save file
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
210 write.table(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
211 signature_output,
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
212 opt$output,
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
213 sep = "\t",
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
214 quote = FALSE,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
215 col.names = TRUE,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
216 row.names = FALSE
0
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
217 )
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
218
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
219 write.table(
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
220 statistics,
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
221 opt$stats,
baf7a079bce0 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff changeset
222 sep = "\t",
4
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
223 quote = FALSE,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
224 col.names = TRUE,
31da579595c5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_signature_score commit 84220e72e5d52cc9265b7eec20e6826e04d91f1f
artbio
parents: 3
diff changeset
225 row.names = FALSE
3
3351ca630a01 "planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_signature_score commit b2f58ce7826f8d9fe5524a6f2c5688ac816bb559"
artbio
parents: 2
diff changeset
226 )