Mercurial > repos > artbio > mutational_patterns
annotate mutational_patterns.R @ 15:8182d1625433 draft
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 6ca5597637439c87b61af2dbd6c38089b29eca37"
author | artbio |
---|---|
date | Sun, 03 Oct 2021 09:29:04 +0000 |
parents | 56c8869a231e |
children | 31e7a33ecd71 |
rev | line source |
---|---|
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
1 # load packages that are provided in the conda env |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
2 options(show.error.messages = F, |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
3 error = function() { |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
4 cat(geterrmessage(), file = stderr()); q("no", 1, F) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
5 } |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
6 ) |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
7 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
8 warnings() |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
9 library(optparse) |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
10 library(rjson) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
11 library(grid) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
12 library(gridExtra) |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
13 library(scales) |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
14 library(RColorBrewer) |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
15 |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
16 # Arguments |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
17 option_list <- list( |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
18 make_option( |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
19 "--inputs", |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
20 default = NA, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
21 type = "character", |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
22 help = "json formatted dictionary of datasets and their paths" |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
23 ), |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
24 make_option( |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
25 "--genome", |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
26 default = NA, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
27 type = "character", |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
28 help = "genome name in the BSgenome bioconductor package" |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
29 ), |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
30 make_option( |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
31 "--levels", |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
32 default = NA, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
33 type = "character", |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
34 help = "path to the tab separated file describing the levels in function of datasets" |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
35 ), |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
36 make_option( |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
37 "--cosmic_version", |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
38 default = "v2", |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
39 type = "character", |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
40 help = "Version of the Cosmic Signature set to be used to express mutational patterns" |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
41 ), |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
42 make_option( |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
43 "--signum", |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
44 default = 2, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
45 type = "integer", |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
46 help = "selects the N most significant signatures in samples to express mutational patterns" |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
47 ), |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
48 make_option( |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
49 "--nrun", |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
50 default = 2, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
51 type = "integer", |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
52 help = "Number of runs to fit signatures" |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
53 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
54 make_option( |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
55 "--rank", |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
56 default = 2, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
57 type = "integer", |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
58 help = "number of ranks to display for parameter optimization" |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
59 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
60 make_option( |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
61 "--newsignum", |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
62 default = 2, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
63 type = "integer", |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
64 help = "Number of new signatures to be captured" |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
65 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
66 make_option( |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
67 "--output_spectrum", |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
68 default = NA, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
69 type = "character", |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
70 help = "path to output dataset" |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
71 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
72 make_option( |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
73 "--output_denovo", |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
74 default = NA, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
75 type = "character", |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
76 help = "path to output dataset" |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
77 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
78 make_option( |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
79 "--sigmatrix", |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
80 default = NA, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
81 type = "character", |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
82 help = "path to signature matrix" |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
83 ), |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
84 make_option( |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
85 "--output_cosmic", |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
86 default = NA, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
87 type = "character", |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
88 help = "path to output dataset" |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
89 ), |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
90 make_option( |
11
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
91 "--sig_contrib_matrix", |
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
92 default = NA, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
93 type = "character", |
11
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
94 help = "path to signature contribution matrix" |
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
95 ), |
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
96 make_option( |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
97 c("-r", "--rdata"), |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
98 type = "character", |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
99 default = NULL, |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
100 help = "Path to RData output file") |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
101 ) |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
102 |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
103 opt <- parse_args(OptionParser(option_list = option_list), |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
104 args = commandArgs(trailingOnly = TRUE)) |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
105 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
106 ################ Manage input data #################### |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
107 json_dict <- opt$inputs |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
108 parser <- newJSONParser() |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
109 parser$addData(json_dict) |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
110 fileslist <- parser$getObject() |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
111 vcf_paths <- attr(fileslist, "names") |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
112 element_identifiers <- unname(unlist(fileslist)) |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
113 ref_genome <- opt$genome |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
114 vcf_table <- data.frame(element_identifier = as.character(element_identifiers), path = vcf_paths) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
115 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
116 library(MutationalPatterns) |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
117 library(ref_genome, character.only = TRUE) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
118 library(ggplot2) |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
119 |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
120 # Load the VCF files into a GRangesList: |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
121 vcfs <- read_vcfs_as_granges(vcf_paths, element_identifiers, ref_genome) |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
122 library(plyr) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
123 if (!is.na(opt$levels)[1]) { # manage levels if there are |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
124 levels_table <- read.delim(opt$levels, header = FALSE, |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
125 col.names = c("element_identifier", "level")) |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
126 } else { |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
127 levels_table <- data.frame(element_identifier = vcf_table$element_identifier, |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
128 level = rep("nolabels", length(vcf_table$element_identifier))) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
129 } |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
130 metadata_table <- join(vcf_table, levels_table, by = "element_identifier") |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
131 tissue <- as.vector(metadata_table$level) |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
132 detach(package:plyr) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
133 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
134 ##### This is done for any section ###### |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
135 mut_mat <- mut_matrix(vcf_list = vcfs, ref_genome = ref_genome) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
136 qual_col_pals <- brewer.pal.info[brewer.pal.info$category == "qual", ] |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
137 col_vector <- unique(unlist(mapply(brewer.pal, qual_col_pals$maxcolors, rownames(qual_col_pals)))) |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
138 col_vector <- col_vector[c(-32, -34, -39)] # 67-color palette |
0
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
139 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
140 ###### Section 1 Mutation characteristics and spectrums ############# |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
141 if (!is.na(opt$output_spectrum)[1]) { |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
142 pdf(opt$output_spectrum, paper = "special", width = 11.69, height = 11.69) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
143 type_occurrences <- mut_type_occurrences(vcfs, ref_genome) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
144 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
145 # mutation spectrum, total or by sample |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
146 |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
147 if (length(levels(factor(levels_table$level))) == 1) { |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
148 p1 <- plot_spectrum(type_occurrences, CT = TRUE, legend = TRUE) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
149 plot(p1) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
150 } else { |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
151 p2 <- plot_spectrum(type_occurrences, by = tissue, CT = TRUE) # by levels |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
152 p3 <- plot_spectrum(type_occurrences, CT = TRUE, legend = TRUE) # total |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
153 grid.arrange(p2, p3, ncol = 2, widths = c(4, 2.3), heights = c(4, 1)) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
154 } |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
155 plot_96_profile(mut_mat, condensed = TRUE) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
156 dev.off() |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
157 } |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
158 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
159 ###### Section 2: De novo mutational signature extraction using NMF ####### |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
160 # opt$rank cannot be higher than the number of samples and |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
161 # likewise, opt$signum cannot be higher thant the number of samples |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
162 if (!is.na(opt$output_denovo)[1]) { |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
163 |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
164 if (opt$rank > length(element_identifiers)) { |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
165 opt$rank <- length(element_identifiers) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
166 } |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
167 if (opt$signum > length(element_identifiers)) { |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
168 opt$signum <- length(element_identifiers) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
169 } |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
170 pseudo_mut_mat <- mut_mat + 0.0001 # First add a small pseudocount to the mutation count matrix |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
171 # Use the NMF package to generate an estimate rank plot |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
172 library("NMF") |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
173 estimate <- nmf(pseudo_mut_mat, rank = 1:opt$rank, method = "brunet", nrun = opt$nrun, seed = 123456) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
174 # And plot it |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
175 pdf(opt$output_denovo, paper = "special", width = 11.69, height = 11.69) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
176 p4 <- plot(estimate) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
177 grid.arrange(p4) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
178 # Extract 4 (PARAMETIZE) mutational signatures from the mutation count matrix with extract_signatures |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
179 # (For larger datasets it is wise to perform more iterations by changing the nrun parameter |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
180 # to achieve stability and avoid local minima) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
181 nmf_res <- extract_signatures(pseudo_mut_mat, rank = opt$newsignum, nrun = opt$nrun) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
182 # Assign signature names |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
183 colnames(nmf_res$signatures) <- paste0("NewSig_", 1:opt$newsignum) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
184 rownames(nmf_res$contribution) <- paste0("NewSig_", 1:opt$newsignum) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
185 # Plot the 96-profile of the signatures: |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
186 p5 <- plot_96_profile(nmf_res$signatures, condensed = TRUE) |
15
8182d1625433
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 6ca5597637439c87b61af2dbd6c38089b29eca37"
artbio
parents:
14
diff
changeset
|
187 new_sig_matrix <- reshape2::dcast(p5$data, substitution + context ~ sample, value.var = "freq") |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
188 new_sig_matrix <- format(new_sig_matrix, scientific = TRUE) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
189 write.table(new_sig_matrix, file = opt$sigmatrix, quote = FALSE, row.names = FALSE, sep = "\t") |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
190 grid.arrange(p5) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
191 # Visualize the contribution of the signatures in a barplot |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
192 pc1 <- plot_contribution(nmf_res$contribution, nmf_res$signature, mode = "relative", coord_flip = TRUE) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
193 # Visualize the contribution of the signatures in absolute number of mutations |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
194 pc2 <- plot_contribution(nmf_res$contribution, nmf_res$signature, mode = "absolute", coord_flip = TRUE) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
195 # Combine the two plots: |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
196 grid.arrange(pc1, pc2) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
197 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
198 # The relative contribution of each signature for each sample can also be plotted as a heatmap with |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
199 # plot_contribution_heatmap, which might be easier to interpret and compare than stacked barplots. |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
200 # The samples can be hierarchically clustered based on their euclidean dis- tance. The signatures |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
201 # can be plotted in a user-specified order. |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
202 # Plot signature contribution as a heatmap with sample clustering dendrogram and a specified signature order: |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
203 pch1 <- plot_contribution_heatmap(nmf_res$contribution, |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
204 sig_order = paste0("NewSig_", 1:opt$newsignum)) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
205 # Plot signature contribution as a heatmap without sample clustering: |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
206 pch2 <- plot_contribution_heatmap(nmf_res$contribution, cluster_samples = FALSE) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
207 #Combine the plots into one figure: |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
208 grid.arrange(pch1, pch2, ncol = 2, widths = c(2, 1.6)) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
209 |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
210 # Compare the reconstructed mutational profile with the original mutational profile: |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
211 plot_compare_profiles(pseudo_mut_mat[, 1], |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
212 nmf_res$reconstructed[, 1], |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
213 profile_names = c("Original", "Reconstructed"), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
214 condensed = TRUE) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
215 dev.off() |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
216 } |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
217 ##### Section 3: Find optimal contribution of known signatures: COSMIC mutational signatures #### |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
218 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
219 if (!is.na(opt$output_cosmic)[1]) { |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
220 pdf(opt$output_cosmic, paper = "special", width = 11.69, height = 11.69) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
221 pseudo_mut_mat <- mut_mat + 0.0001 # First add a small psuedocount to the mutation count matrix |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
222 if (opt$cosmic_version == "v2") { |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
223 sp_url <- paste("https://cancer.sanger.ac.uk/cancergenome/assets/", "signatures_probabilities.txt", sep = "") |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
224 cancer_signatures <- read.table(sp_url, sep = "\t", header = TRUE) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
225 new_order <- match(row.names(pseudo_mut_mat), cancer_signatures$Somatic.Mutation.Type) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
226 cancer_signatures <- cancer_signatures[as.vector(new_order), ] |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
227 row.names(cancer_signatures) <- cancer_signatures$Somatic.Mutation.Type |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
228 cancer_signatures <- as.matrix(cancer_signatures[, 4:33]) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
229 colnames(cancer_signatures) <- gsub("Signature.", "", colnames(cancer_signatures)) # shorten signature labels |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
230 cosmic_tag <- "Signatures (Cosmic v2, March 2015)" |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
231 cosmic_colors <- col_vector[1:30] |
15
8182d1625433
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 6ca5597637439c87b61af2dbd6c38089b29eca37"
artbio
parents:
14
diff
changeset
|
232 names(cosmic_colors) <- colnames(cancer_signatures) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
233 } else { |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
234 sp_url <- "https://raw.githubusercontent.com/ARTbio/startbio/master/sigProfiler_SBS_signatures_2019_05_22.tsv" |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
235 cancer_signatures <- read.table(sp_url, sep = "\t", header = TRUE) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
236 new_order <- match(row.names(pseudo_mut_mat), cancer_signatures$Somatic.Mutation.Type) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
237 cancer_signatures <- cancer_signatures[as.vector(new_order), ] |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
238 row.names(cancer_signatures) <- cancer_signatures$Somatic.Mutation.Type |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
239 cancer_signatures <- as.matrix(cancer_signatures[, 4:70]) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
240 colnames(cancer_signatures) <- gsub("SBS", "", colnames(cancer_signatures)) # shorten signature labels |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
241 cosmic_tag <- "Signatures (Cosmic v3, May 2019)" |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
242 cosmic_colors <- col_vector[1:67] |
15
8182d1625433
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 6ca5597637439c87b61af2dbd6c38089b29eca37"
artbio
parents:
14
diff
changeset
|
243 names(cosmic_colors) <- colnames(cancer_signatures) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
244 } |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
245 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
246 # Plot mutational profiles of the COSMIC signatures |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
247 if (opt$cosmic_version == "v2") { |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
248 p6 <- plot_96_profile(cancer_signatures, condensed = TRUE, ymax = 0.3) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
249 grid.arrange(p6, top = textGrob("COSMIC signature profiles", gp = gpar(fontsize = 12, font = 3))) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
250 } else { |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
251 p6 <- plot_96_profile(cancer_signatures[, 1:33], condensed = TRUE, ymax = 0.3) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
252 p6bis <- plot_96_profile(cancer_signatures[, 34:67], condensed = TRUE, ymax = 0.3) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
253 grid.arrange(p6, top = textGrob("COSMIC signature profiles (on two pages)", |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
254 gp = gpar(fontsize = 12, font = 3))) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
255 grid.arrange(p6bis, top = textGrob("COSMIC signature profiles (continued)", |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
256 gp = gpar(fontsize = 12, font = 3))) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
257 } |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
258 |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
259 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
260 # Find optimal contribution of COSMIC signatures to reconstruct 96 mutational profiles |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
261 fit_res <- fit_to_signatures(pseudo_mut_mat, cancer_signatures) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
262 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
263 # Plot contribution barplots |
15
8182d1625433
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 6ca5597637439c87b61af2dbd6c38089b29eca37"
artbio
parents:
14
diff
changeset
|
264 pc3 <- plot_contribution(fit_res$contribution, cancer_signatures, coord_flip = T, mode = "absolute") |
8182d1625433
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 6ca5597637439c87b61af2dbd6c38089b29eca37"
artbio
parents:
14
diff
changeset
|
265 pc4 <- plot_contribution(fit_res$contribution, cancer_signatures, coord_flip = T, mode = "relative") |
8182d1625433
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 6ca5597637439c87b61af2dbd6c38089b29eca37"
artbio
parents:
14
diff
changeset
|
266 if (is.na(opt$levels)[1]) { # if there are NO levels to display in graphs |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
267 pc3_data <- pc3$data |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
268 pc3 <- ggplot(pc3_data, aes(x = Sample, y = Contribution, fill = as.factor(Signature))) + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
269 geom_bar(stat = "identity", position = "stack") + |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
270 coord_flip() + |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
271 scale_fill_manual(name = "Cosmic\nSignatures", values = cosmic_colors) + |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
272 labs(x = "Samples", y = "Absolute contribution") + theme_bw() + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
273 theme(panel.grid.minor.x = element_blank(), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
274 panel.grid.major.x = element_blank(), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
275 legend.position = "right", |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
276 text = element_text(size = 8), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
277 axis.text.x = element_text(angle = 90, hjust = 1)) |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
278 pc4_data <- pc4$data |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
279 pc4 <- ggplot(pc4_data, aes(x = Sample, y = Contribution, fill = as.factor(Signature))) + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
280 geom_bar(stat = "identity", position = "fill") + |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
281 coord_flip() + |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
282 scale_fill_manual(name = "Cosmic\nSignatures", values = cosmic_colors) + |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
283 scale_y_continuous(labels = scales::percent_format(accuracy = 1)) + |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
284 labs(x = "Samples", y = "Relative contribution") + theme_bw() + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
285 theme(panel.grid.minor.x = element_blank(), panel.grid.major.x = element_blank(), legend.position = "right", |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
286 text = element_text(size = 8), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
287 axis.text.x = element_text(angle = 90, hjust = 1)) |
15
8182d1625433
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 6ca5597637439c87b61af2dbd6c38089b29eca37"
artbio
parents:
14
diff
changeset
|
288 } |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
289 ##### |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
290 # ggplot2 alternative |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
291 if (!is.na(opt$levels)[1]) { # if there are levels to display in graphs |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
292 pc3_data <- pc3$data |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
293 pc3_data <- merge(pc3_data, metadata_table[, c(1, 3)], by.x = "Sample", by.y = "element_identifier") |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
294 pc3 <- ggplot(pc3_data, aes(x = Sample, y = Contribution, fill = as.factor(Signature))) + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
295 geom_bar(stat = "identity", position = "stack") + |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
296 scale_fill_manual(name = "Cosmic\nSignatures", values = cosmic_colors) + |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
297 labs(x = "Samples", y = "Absolute contribution") + theme_bw() + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
298 theme(panel.grid.minor.x = element_blank(), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
299 panel.grid.major.x = element_blank(), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
300 legend.position = "right", |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
301 text = element_text(size = 8), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
302 axis.text.x = element_text(angle = 90, hjust = 1)) + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
303 facet_grid(~level, scales = "free_x", space = "free") |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
304 pc4_data <- pc4$data |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
305 pc4_data <- merge(pc4_data, metadata_table[, c(1, 3)], by.x = "Sample", by.y = "element_identifier") |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
306 pc4 <- ggplot(pc4_data, aes(x = Sample, y = Contribution, fill = as.factor(Signature))) + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
307 geom_bar(stat = "identity", position = "fill") + |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
308 scale_fill_manual(name = "Cosmic\nSignatures", values = cosmic_colors) + |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
309 scale_y_continuous(labels = scales::percent_format(accuracy = 1)) + |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
310 labs(x = "Samples", y = "Relative contribution") + theme_bw() + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
311 theme(panel.grid.minor.x = element_blank(), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
312 panel.grid.major.x = element_blank(), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
313 legend.position = "right", |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
314 text = element_text(size = 8), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
315 axis.text.x = element_text(angle = 90, hjust = 1)) + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
316 facet_grid(~level, scales = "free_x", space = "free") |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
317 } |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
318 # Combine the two plots: |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
319 grid.arrange(pc3, pc4, |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
320 top = textGrob("Absolute and Relative Contributions of Cosmic signatures to mutational patterns", |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
321 gp = gpar(fontsize = 12, font = 3))) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
322 |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
323 #### pie charts of comic signatures contributions in samples ### |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
324 library(reshape2) |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
325 library(dplyr) |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
326 if (length(levels(factor(levels_table$level))) < 2) { |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
327 fit_res_contrib <- as.data.frame(fit_res$contribution) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
328 worklist <- cbind(signature = rownames(fit_res$contribution), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
329 level = rep("nolabels", length(fit_res_contrib[, 1])), |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
330 fit_res_contrib, |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
331 sum = rowSums(fit_res_contrib)) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
332 worklist <- worklist[order(worklist[, "sum"], decreasing = T), ] |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
333 worklist <- worklist[1:opt$signum, ] |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
334 worklist <- worklist[, -length(worklist[1, ])] |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
335 worklist <- melt(worklist) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
336 worklist <- worklist[, c(1, 3, 4, 2)] |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
337 } else { |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
338 worklist <- list() |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
339 for (i in levels(factor(levels_table$level))) { |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
340 fit_res$contribution[, levels_table$element_identifier[levels_table$level == i]] -> worklist[[i]] |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
341 sum <- rowSums(as.data.frame(worklist[[i]])) |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
342 worklist[[i]] <- cbind(worklist[[i]], sum) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
343 worklist[[i]] <- worklist[[i]][order(worklist[[i]][, "sum"], decreasing = T), ] |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
344 worklist[[i]] <- worklist[[i]][1:opt$signum, ] |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
345 worklist[[i]] <- worklist[[i]][, -length(as.data.frame(worklist[[i]]))] |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
346 } |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
347 worklist <- as.data.frame(melt(worklist)) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
348 worklist[, 2] <- paste0(worklist[, 4], " - ", worklist[, 2]) |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
349 } |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
350 |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
351 colnames(worklist) <- c("signature", "sample", "value", "level") |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
352 worklist <- as.data.frame(worklist %>% group_by(sample) %>% mutate(value = value / sum(value) * 100)) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
353 worklist$pos <- cumsum(worklist$value) - worklist$value / 2 |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
354 worklist$label <- factor(worklist$signature) |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
355 worklist$signature <- factor(worklist$signature) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
356 p7 <- ggplot(worklist, aes(x = "", y = value, group = signature, fill = signature)) + |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
357 geom_bar(width = 1, stat = "identity") + |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
358 geom_text(aes(label = label), position = position_stack(vjust = 0.5), color = "black", size = 3) + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
359 coord_polar("y", start = 0) + facet_wrap(.~sample) + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
360 labs(x = "", y = "Samples", fill = cosmic_tag) + |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
361 scale_fill_manual(name = paste0(opt$signum, " most contributing\nsignatures\n(in each label/tissue)"), |
15
8182d1625433
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 6ca5597637439c87b61af2dbd6c38089b29eca37"
artbio
parents:
14
diff
changeset
|
362 values = cosmic_colors[levels(worklist$signature)]) + |
8
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
363 theme(axis.text = element_blank(), |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
364 axis.ticks = element_blank(), |
e0dad46148bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 75fd87e806f9bee2f6ff7fcd3834e55eb21d8710"
artbio
parents:
7
diff
changeset
|
365 panel.grid = element_blank()) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
366 grid.arrange(p7) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
367 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
368 # Plot relative contribution of the cancer signatures in each sample as a heatmap with sample clustering |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
369 if (length(vcf_paths) > 1) { |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
370 p8 <- plot_contribution_heatmap(fit_res$contribution, cluster_samples = TRUE, method = "complete") |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
371 grid.arrange(p8) |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
372 } |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
373 |
11
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
374 # export relative contribution matrix |
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
375 if (!is.na(opt$sig_contrib_matrix)) { |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
376 output_table <- t(fit_res$contribution) / rowSums(t(fit_res$contribution)) |
11
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
377 colnames(output_table) <- paste0("s", colnames(output_table)) |
12
7954f0d3517f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 7c990ad7024035342c4abd6e3fa8feb1b2f2ac2c"
artbio
parents:
11
diff
changeset
|
378 if (length(levels(factor(levels_table$level))) > 1) { |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
379 output_table <- data.frame(sample = paste0(metadata_table[metadata_table$element_identifier == colnames(fit_res$contribution), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
380 3], "-", colnames(fit_res$contribution)), |
13
6741b819cc15
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 372eb902f528baa8b5465b83d992a1d146343dfe"
artbio
parents:
12
diff
changeset
|
381 output_table) |
12
7954f0d3517f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 7c990ad7024035342c4abd6e3fa8feb1b2f2ac2c"
artbio
parents:
11
diff
changeset
|
382 } else { |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
383 output_table <- data.frame(sample = rownames(output_table), output_table) |
12
7954f0d3517f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 7c990ad7024035342c4abd6e3fa8feb1b2f2ac2c"
artbio
parents:
11
diff
changeset
|
384 } |
11
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
385 write.table(output_table, file = opt$sig_contrib_matrix, sep = "\t", quote = F, row.names = F) |
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
386 } |
7995a949189f
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
artbio
parents:
10
diff
changeset
|
387 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
388 # calculate all pairwise cosine similarities |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
389 cos_sim_ori_rec <- cos_sim_matrix(pseudo_mut_mat, fit_res$reconstructed) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
390 # extract cosine similarities per sample between original and reconstructed |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
391 cos_sim_ori_rec <- as.data.frame(diag(cos_sim_ori_rec)) |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
392 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
393 # We can use ggplot to make a barplot of the cosine similarities between the original and |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
394 # reconstructed mutational profile of each sample. This clearly shows how well each mutational |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
395 # profile can be reconstructed with the COSMIC mutational signatures. Two identical profiles |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
396 # have a cosine similarity of 1. The lower the cosine similarity between original and |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
397 # reconstructed, the less well the original mutational profile can be reconstructed with |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
398 # the COSMIC signatures. You could use, for example, cosine similarity of 0.95 as a cutoff. |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
399 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
400 # Adjust data frame for plotting with gpplot |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
401 colnames(cos_sim_ori_rec) <- "cos_sim" |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
402 cos_sim_ori_rec$sample <- row.names(cos_sim_ori_rec) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
403 # Make barplot |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
404 p9 <- ggplot(cos_sim_ori_rec, aes(y = cos_sim, x = sample)) + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
405 geom_bar(stat = "identity", fill = "skyblue4") + |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
406 coord_cartesian(ylim = c(0.8, 1)) + |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
407 # coord_flip(ylim=c(0.8,1)) + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
408 ylab("Cosine similarity\n original VS reconstructed") + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
409 xlab("") + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
410 # Reverse order of the samples such that first is up |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
411 # xlim(rev(levels(factor(cos_sim_ori_rec$sample)))) + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
412 theme_bw() + |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
413 theme(panel.grid.minor.y = element_blank(), |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
414 panel.grid.major.y = element_blank()) + |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
415 # Add cut.off line |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
416 geom_hline(aes(yintercept = .95)) |
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
417 grid.arrange(p9, top = textGrob("Similarity between true and reconstructed profiles (with all Cosmic sig.)", gp = gpar(fontsize = 12, font = 3))) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
418 dev.off() |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
419 } |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
420 |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
421 |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
422 # Output RData file |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
423 if (!is.null(opt$rdata)) { |
14
56c8869a231e
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 518fb067e8206ecafbf673a5e4cf375ccead11e3"
artbio
parents:
13
diff
changeset
|
424 save.image(file = opt$rdata) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
425 } |