annotate signature_score.R @ 0:bf99be04d098 draft

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