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