annotate cpm_tpm_rpk.R @ 7:f00c1c34565e draft default tip

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
author artbio
date Wed, 03 Jul 2024 14:39:26 +0000
parents bcff1eb6fdb5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
1 if (length(commandArgs(TRUE)) == 0) {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
2 system("Rscript cpm_tpm_rpk.R -h", intern = FALSE)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
3 q("no")
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
4 }
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
5
1
b74bab5157c4 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents: 0
diff changeset
6
b74bab5157c4 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents: 0
diff changeset
7 # load packages that are provided in the conda env
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
8 options(show.error.messages = FALSE,
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
9 error = function() {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
10 cat(geterrmessage(), file = stderr())
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
11 q("no", 1, FALSE)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
12 }
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
13 )
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
14 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") # nolint⁠
1
b74bab5157c4 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents: 0
diff changeset
15 warnings()
b74bab5157c4 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents: 0
diff changeset
16 library(optparse)
b74bab5157c4 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents: 0
diff changeset
17 library(ggplot2)
b74bab5157c4 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents: 0
diff changeset
18 library(reshape2)
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
19 library(Rtsne) # nolint⁠
2
563337e780ce planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents: 1
diff changeset
20 library(ggfortify)
1
b74bab5157c4 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents: 0
diff changeset
21
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
22
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
23 #Arguments
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
24 option_list <- list(
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
25 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
26 c("-d", "--data"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
27 default = NA,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
28 type = "character",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
29 help = "Input file that contains count values to transform"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
30 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
31 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
32 c("-t", "--type"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
33 default = "cpm",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
34 type = "character",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
35 help = "Transformation type, either cpm, tpm, rpkm or none[default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
36 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
37 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
38 c("-s", "--sep"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
39 default = "\t",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
40 type = "character",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
41 help = "File separator [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
42 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
43 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
44 c("-c", "--colnames"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
45 default = TRUE,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
46 type = "logical",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
47 help = "Consider first line as header ? [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
48 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
49 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
50 c("-f", "--gene"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
51 default = NA,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
52 type = "character",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
53 help = "Two column of gene length file"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
54 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
55 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
56 c("-a", "--gene_sep"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
57 default = "\t",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
58 type = "character",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
59 help = "Gene length file separator [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
60 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
61 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
62 c("-b", "--gene_header"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
63 default = TRUE,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
64 type = "logical",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
65 help = "Consider first line of gene length as header ? [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
66 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
67 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
68 c("-l", "--log"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
69 default = FALSE,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
70 type = "logical",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
71 help = "Should be log transformed as well ? (log2(data +1)) [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
72 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
73 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
74 c("-o", "--out"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
75 default = "res.tab",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
76 type = "character",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
77 help = "Output name [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
78 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
79 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
80 "--visu",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
81 default = FALSE,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
82 type = "logical",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
83 help = "performs T-SNE [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
84 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
85 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
86 "--tsne_labels",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
87 default = FALSE,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
88 type = "logical",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
89 help = "add labels to t-SNE plot [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
90 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
91 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
92 "--seed",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
93 default = 42,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
94 type = "integer",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
95 help = "Seed value for reproducibility [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
96 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
97 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
98 "--perp",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
99 default = 5.0,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
100 type = "numeric",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
101 help = "perplexity [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
102 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
103 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
104 "--theta",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
105 default = 1.0,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
106 type = "numeric",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
107 help = "theta [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
108 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
109 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
110 c("-D", "--tsne_out"),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
111 default = "tsne.pdf",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
112 type = "character",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
113 help = "T-SNE pdf [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
114 ),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
115 make_option(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
116 "--pca_out",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
117 default = "pca.pdf",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
118 type = "character",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
119 help = "PCA pdf [default : '%default' ]"
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
120 )
2
563337e780ce planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents: 1
diff changeset
121
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
122 )
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
123
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
124 opt <- parse_args(OptionParser(option_list = option_list),
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
125 args = commandArgs(trailingOnly = TRUE))
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
126
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
127 if (opt$data == "" && !(opt$help)) {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
128 stop("At least one argument must be supplied (count data).\n",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
129 call. = FALSE)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
130 } else if ((opt$type == "tpm" || opt$type == "rpkm") && opt$gene == "") {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
131 stop("At least two arguments must be supplied (count data and gene length file).\n",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
132 call. = FALSE)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
133 } else if (opt$type != "tpm" && opt$type != "rpkm" && opt$type != "cpm" && opt$type != "none") {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
134 stop("Wrong transformation requested (--type option) must be : cpm, tpm or rpkm.\n",
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
135 call. = FALSE)
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
136 }
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
137
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
138 if (opt$sep == "tab") {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
139 opt$sep <- "\t"
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
140 }
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
141 if (opt$gene_sep == "tab") {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
142 opt$gene_sep <- "\t"
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
143 }
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
144
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
145 cpm <- function(count) {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
146 (count / colSums(count)) * 1000000
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
147 }
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
148
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
149
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
150 rpk <- function(count, length) {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
151 count / (length / 1000)
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
152 }
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
153
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
154 tpm <- function(count, length) {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
155 rpk <- rpk(count, length)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
156 per_million_factor <- colSums(rpk) / 1000000
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
157 tpm <- rpk / per_million_factor
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
158 return(tpm)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
159 }
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
160
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
161 rpkm <- function(count, length) {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
162 rpk <- rpk(count, length)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
163 per_million_factor <- colSums(as.data.frame(count)) / 1000000
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
164 rpkm <- rpk / per_million_factor
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
165 return(rpkm)
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
166 }
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
167
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
168 #### running code ####
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
169
5
bcff1eb6fdb5 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d6ef3d1c1d490967b7b79138573a86a8d5235c43
artbio
parents: 4
diff changeset
170 data <- read.delim(
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
171 opt$data,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
172 check.names = FALSE,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
173 header = opt$colnames,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
174 row.names = 1,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
175 sep = opt$sep
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
176 )
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
177
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
178 if (opt$type == "tpm" || opt$type == "rpkm") {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
179 gene_length <- as.data.frame(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
180 read.delim(
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
181 opt$gene,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
182 header = opt$gene_header,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
183 row.names = 1,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
184 sep = opt$gene_sep
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
185 )
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
186 )
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
187 gene_length <- as.data.frame(gene_length[match(rownames(data), rownames(gene_length)), ], rownames(data))
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
188 }
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
189
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
190
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
191 if (opt$type == "cpm") {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
192 res <- cpm(data)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
193 }
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
194 if (opt$type == "tpm") {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
195 res <- as.data.frame(apply(data, 2, tpm, length = gene_length), row.names = rownames(data))
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
196 }
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
197 if (opt$type == "rpkm") {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
198 res <- as.data.frame(apply(data, 2, rpkm, length = gene_length), row.names = rownames(data))
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
199 }
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
200 if (opt$type == "none") {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
201 res <- data
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
202 }
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
203 colnames(res) <- colnames(data)
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
204
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
205 if (opt$log == TRUE) {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
206 res <- log2(res + 1)
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
207 }
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
208
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
209 if (opt$visu == TRUE) {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
210 df <- res
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
211 # filter and transpose df for tsne and pca
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
212 df <- df[rowSums(df) != 0, ] # remove lines without information (with only 0 counts)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
213 tdf <- t(df)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
214 # make tsne and plot results
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
215 set.seed(opt$seed) ## Sets seed for reproducibility
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
216 tsne_out <- Rtsne(tdf, perplexity = opt$perp, theta = opt$theta)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
217 embedding <- as.data.frame(tsne_out$Y)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
218 embedding$Class <- as.factor(sub("Class_", "", rownames(tdf)))
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
219 gg_legend <- theme(legend.position = "none")
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
220 ggplot(embedding, aes(x = V1, y = V2)) +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
221 geom_point(size = 1, color = "red") +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
222 gg_legend +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
223 xlab("") +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
224 ylab("") +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
225 ggtitle("t-SNE") +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
226 if (opt$tsne_labels == TRUE) {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
227 geom_text(aes(label = Class), hjust = -0.2, vjust = -0.5, size = 2.5, color = "darkblue")
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
228 }
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
229 ggsave(file = opt$tsne_out, device = "pdf")
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
230 # make PCA and plot result with ggfortify (autoplot)
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
231 tdf_pca <- prcomp(tdf, center = TRUE, scale. = TRUE)
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
232 if (opt$tsne_labels == TRUE) {
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
233 autoplot(tdf_pca, shape = FALSE, label = TRUE, label.size = 2.5, label.vjust = 1.2,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
234 label.hjust = 1.2,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
235 colour = "darkblue") +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
236 geom_point(size = 1, color = "red") +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
237 xlab(paste("PC1", summary(tdf_pca)$importance[2, 1] * 100, "%")) +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
238 ylab(paste("PC2", summary(tdf_pca)$importance[2, 2] * 100, "%")) +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
239 ggtitle("PCA")
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
240 ggsave(file = opt$pca_out, device = "pdf")
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
241 } else {
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
242 autoplot(tdf_pca, shape = TRUE, colour = "darkblue") +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
243 geom_point(size = 1, color = "red") +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
244 xlab(paste("PC1", summary(tdf_pca)$importance[2, 1] * 100, "%")) +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
245 ylab(paste("PC2", summary(tdf_pca)$importance[2, 2] * 100, "%")) +
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
246 ggtitle("PCA")
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
247 ggsave(file = opt$pca_out, device = "pdf")
4
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
248 }
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
249 }
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
250
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
251 # at this stage, we select numeric columns and round theirs values to 8 decimals for cleaner output
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
252 is_num <- sapply(res, is.numeric)
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
253 res[is_num] <- lapply(res[is_num], round, 8)
be358a1ebf67 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit a8486c89b7ddabfb1e814c2c42f6c04d3896904c
artbio
parents: 3
diff changeset
254
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
255 write.table(
7
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
256 cbind(Features = rownames(res), res),
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
257 opt$out,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
258 col.names = opt$colnames,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
259 row.names = FALSE,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
260 quote = FALSE,
f00c1c34565e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/cpm_tpm_rpk commit 8cca5f05212cd25113955fb9c11801f4047c12b4
artbio
parents: 5
diff changeset
261 sep = "\t"
0
35d032c46a4e planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff changeset
262 )