Mercurial > repos > artbio > cpm_tpm_rpk
annotate cpm_tpm_rpk.R @ 2:563337e780ce draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
author | artbio |
---|---|
date | Wed, 06 Feb 2019 19:31:57 -0500 |
parents | b74bab5157c4 |
children | 8b1020c25f0f |
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) { |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
2 system("Rscript cpm_tpm_rpk.R -h", intern = F) |
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 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
8 options( show.error.messages=F, |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
9 error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
10 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
11 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
|
12 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
|
13 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
|
14 library(reshape2) |
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 library(Rtsne) |
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
|
16 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
|
17 |
0
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
18 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
19 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
20 #Arguments |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
21 option_list = list( |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
22 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
|
23 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
|
24 default = NA, |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
25 type = 'character', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
26 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
|
27 ), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
28 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
|
29 c("-t", "--type"), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
30 default = 'cpm', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
31 type = 'character', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
32 help = "Transformation type, either cpm, tpm or rpk [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
|
33 ), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
34 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
|
35 c("-s", "--sep"), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
36 default = '\t', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
37 type = 'character', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
38 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
|
39 ), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
40 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
|
41 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
|
42 default = TRUE, |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
43 type = 'logical', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
44 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
|
45 ), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
46 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
|
47 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
|
48 default = NA, |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
49 type = 'character', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
50 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
|
51 ), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
52 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
|
53 c("-a", "--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
|
54 default = '\t', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
55 type = 'character', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
56 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
|
57 ), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
58 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
|
59 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
|
60 default = TRUE, |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
61 type = 'logical', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
62 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
|
63 ), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
64 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
|
65 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
|
66 default = FALSE, |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
67 type = 'logical', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
68 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
|
69 ), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
70 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
|
71 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
|
72 default = "res.tab", |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
73 type = 'character', |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
74 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
|
75 ), |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
76 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
|
77 "--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
|
78 default = FALSE, |
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 type = 'logical', |
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 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
|
81 ), |
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 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
|
83 "--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
|
84 default = FALSE, |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
85 type = 'logical', |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
86 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
|
87 ), |
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 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
|
89 "--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
|
90 default = 42, |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
91 type = 'integer', |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
92 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
|
93 ), |
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 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
|
95 "--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
|
96 default = 5.0, |
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 type = 'numeric', |
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 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
|
99 ), |
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 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
|
101 "--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
|
102 default = 1.0, |
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 type = 'numeric', |
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 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
|
105 ), |
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 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
|
107 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
|
108 default = "tsne.pdf", |
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 type = 'character', |
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 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
|
111 ), |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
112 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
|
113 "--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
|
114 default = "pca.pdf", |
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 type = 'character', |
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 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
|
117 ) |
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
|
118 |
0
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
119 ) |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
120 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
121 opt = parse_args(OptionParser(option_list = option_list), |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
122 args = commandArgs(trailingOnly = TRUE)) |
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 if (opt$data == "" & !(opt$help)) { |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
125 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
|
126 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
|
127 } else if ((opt$type == "tpm" | opt$type == "rpk") & opt$gene == "") { |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
128 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
|
129 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
|
130 } else if (opt$type != "tpm" & opt$type != "rpk" & opt$type != "cpm") { |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
131 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
|
132 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
|
133 } |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
134 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
135 if (opt$sep == "tab") {opt$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
|
136 if (opt$gene_sep == "tab") {opt$gene_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
|
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 cpm <- function(count) { |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
139 t(t(count) / colSums(count)) * 1000000 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
140 } |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
141 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
142 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
143 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
|
144 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
|
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 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
147 tpm <- 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
|
148 RPK = rpk(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
|
149 perMillion_factor = colSums(RPK) / 1000000 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
150 TPM = RPK / perMillion_factor |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
151 return(TPM) |
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 data = read.table( |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
155 opt$data, |
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
|
156 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
|
157 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
|
158 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
|
159 ) |
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 if (opt$type == "tpm" | opt$type == "rpk") { |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
162 gene_length = as.data.frame( |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
163 read.table( |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
164 opt$gene, |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
165 h = opt$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
|
166 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
|
167 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
|
168 ) |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
169 ) |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
170 gene_length = as.data.frame(gene_length[match(rownames(data), rownames(gene_length)), ], rownames(data)) |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
171 } |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
172 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
173 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
174 if (opt$type == "cpm") |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
175 res = cpm(data) |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
176 if (opt$type == "tpm") |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
177 res = as.data.frame(apply(data, 2, tpm, length = gene_length), row.names = rownames(data)) |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
178 if (opt$type == "rpk") |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
179 res = as.data.frame(apply(data, 2, rpk, length = gene_length), row.names = rownames(data)) |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
180 colnames(res) = colnames(data) |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
181 |
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 if (opt$log == TRUE) { |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
184 res = log2(res + 1) |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
185 } |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
186 |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
187 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
|
188 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
|
189 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
|
190 col.names = opt$colnames, |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
191 row.names = F, |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
192 quote = F, |
35d032c46a4e
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit cc0fd23c039cc4a39c5e4e320b50666b7d9b6f65
artbio
parents:
diff
changeset
|
193 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
|
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 |
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
|
196 ## |
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
|
197 if (opt$visu == TRUE) { |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
198 df = res |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
199 # filter and transpose df for tsne and pca |
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
|
200 df = df[rowSums(df) != 0,] # remove lines without information (with only 0 counts) |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
201 tdf = t(df) |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
202 # make tsne and plot results |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
203 set.seed(opt$seed) ## Sets seed for reproducibility |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
204 tsne_out <- Rtsne(tdf, perplexity=opt$perp, theta=opt$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
|
205 embedding <- as.data.frame(tsne_out$Y) |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
206 embedding$Class <- as.factor(sub("Class_", "", rownames(tdf))) |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
207 gg_legend = theme(legend.position="none") |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
208 ggplot(embedding, aes(x=V1, y=V2)) + |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
209 geom_point(size=1.25, color='red') + |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
210 gg_legend + |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
211 xlab("") + |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
212 ylab("") + |
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
|
213 ggtitle('t-SNE') + |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
214 if (opt$tsne_labels == TRUE) { |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
215 geom_text(aes(label=Class),hjust=-0.2, vjust=-0.5, size=2.5, color='darkblue') |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
216 } |
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
|
217 ggsave(file=opt$tsne_out, device="pdf") |
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
|
218 # make PCA and plot result with ggfortify |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
219 tdf.pca <- prcomp(tdf, center = TRUE, scale. = T) |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
220 if (opt$tsne_labels == TRUE) { |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
221 autoplot(tdf.pca, shape=F, label=T, label.size=2.5, colour="darkred") + |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
222 xlab(paste("PC1",summary(tdf.pca)$importance[2,1]*100, "%")) + |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
223 ylab(paste("PC2",summary(tdf.pca)$importance[2,2]*100, "%")) + |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
224 ggtitle('PCA') |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
225 ggsave(file=opt$pca_out, device="pdf") |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
226 } else { |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
227 autoplot(tdf.pca, shape=T, colour="red") + |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
228 xlab(paste("PC1",summary(tdf.pca)$importance[2,1]*100, "%")) + |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
229 ylab(paste("PC2",summary(tdf.pca)$importance[2,2]*100, "%")) + |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
230 ggtitle('PCA') |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
231 ggsave(file=opt$pca_out, device="pdf") |
563337e780ce
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 4ade64ddb1b4e2c62cd153bee13c7ce4ff2d249d
artbio
parents:
1
diff
changeset
|
232 } |
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
|
233 } |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
234 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
235 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
236 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
237 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
238 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
239 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
240 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
241 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
242 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
243 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
244 |
b74bab5157c4
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit d46436d5d73356c8803d6d97a110a2754e8a03fb
artbio
parents:
0
diff
changeset
|
245 |