annotate signature_score.R @ 5:bd810b6d8a3b draft default tip

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