Mercurial > repos > artbio > mutational_patterns
annotate mutational_patterns.R @ 7:34626b2b9907 draft
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit a9c23b9c740ae50087777e336b4775e1f8035261"
author | artbio |
---|---|
date | Fri, 16 Oct 2020 10:00:41 +0000 |
parents | 2c1d58f5c296 |
children | e0dad46148bf |
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 |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
2 options( show.error.messages=F, |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
3 error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
4 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
|
5 warnings() |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
6 library(optparse) |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
7 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
|
8 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
|
9 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
|
10 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
|
11 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
|
12 |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
13 # Arguments |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
14 option_list = list( |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
15 make_option( |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
16 "--inputs", |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
17 default = NA, |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
18 type = 'character', |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
19 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
|
20 ), |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
21 make_option( |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
22 "--genome", |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
23 default = NA, |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
24 type = 'character', |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
25 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
|
26 ), |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
27 make_option( |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
28 "--levels", |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
29 default = NA, |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
30 type = 'character', |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
31 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
|
32 ), |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
33 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
|
34 "--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
|
35 default = "v2", |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
36 type = 'character', |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
37 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
|
38 ), |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
39 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
|
40 "--signum", |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
41 default = 2, |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
42 type = 'integer', |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
43 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
|
44 ), |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
45 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
|
46 "--nrun", |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
47 default = 2, |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
48 type = 'integer', |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
49 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
|
50 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
51 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
|
52 "--rank", |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
53 default = 2, |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
54 type = 'integer', |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
55 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
|
56 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
57 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
|
58 "--newsignum", |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
59 default = 2, |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
60 type = 'integer', |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
61 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
|
62 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
63 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
|
64 "--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
|
65 default = NA, |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
66 type = 'character', |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
67 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
|
68 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
69 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
|
70 "--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
|
71 default = NA, |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
72 type = 'character', |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
73 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
|
74 ), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
75 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
|
76 "--sigmatrix", |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
77 default = NA, |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
78 type = 'character', |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
79 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
|
80 ), |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
81 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
|
82 "--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
|
83 default = NA, |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
84 type = 'character', |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
85 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
|
86 ), |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
87 make_option( |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
88 c("-r", "--rdata"), |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
89 type="character", |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
90 default=NULL, |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
91 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
|
92 ) |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
93 |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
94 opt = parse_args(OptionParser(option_list = option_list), |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
95 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
|
96 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
97 ################ 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
|
98 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
|
99 parser <- newJSONParser() |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 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
|
104 ref_genome <- opt$genome |
5
fe31d059a482
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 8726066cfb70109de05cbdb7aa7c08ee11b957e9"
artbio
parents:
4
diff
changeset
|
105 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
|
106 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
107 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
|
108 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
|
109 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
|
110 |
924c527fb379
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e1f3ca871f13569401f41a5af9d0e281bf372540"
artbio
parents:
diff
changeset
|
111 # 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
|
112 vcfs <- read_vcfs_as_granges(vcf_paths, element_identifiers, ref_genome) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
113 if (!is.na(opt$levels)[1]) { # manage levels if there are |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
114 levels_table <- read.delim(opt$levels, header=FALSE, col.names=c("element_identifier","level")) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
115 library(plyr) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
116 metadata_table <- join(vcf_table, levels_table, by = "element_identifier") |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
117 tissue <- as.vector(metadata_table$level) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
118 } |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
119 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
120 ##### 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
|
121 mut_mat <- mut_matrix(vcf_list = vcfs, ref_genome = ref_genome) |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
122 qual_col_pals = brewer.pal.info[brewer.pal.info$category == 'qual',] |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
123 col_vector = unique(unlist(mapply(brewer.pal, qual_col_pals$maxcolors, rownames(qual_col_pals)))) |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
124 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
|
125 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
126 ###### 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
|
127 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
|
128 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
|
129 type_occurrences <- mut_type_occurrences(vcfs, ref_genome) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
130 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
131 # mutation spectrum, total or by sample |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
132 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
133 if (is.na(opt$levels)[1]) { |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
134 p1 <- plot_spectrum(type_occurrences, CT = TRUE, legend=TRUE) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
135 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
|
136 } else { |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
137 p2 <- plot_spectrum(type_occurrences, by = tissue, CT=TRUE) # by levels |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
138 p3 <- plot_spectrum(type_occurrences, CT=TRUE, legend=TRUE) # total |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
139 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
|
140 } |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
141 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
|
142 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
|
143 } |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
144 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
145 ###### Section 2: De novo mutational signature extraction using NMF ####### |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
146 if (!is.na(opt$output_denovo)[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
|
147 # opt$rank cannot be higher than the number of samples |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
148 if (opt$rank > length(element_identifiers)) {opt$rank <-length(element_identifiers)} |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
149 # likewise, opt$signum cannot be higher thant the number of samples |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
150 if (opt$signum > length(element_identifiers)) {opt$signum <-length(element_identifiers)} |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
151 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
|
152 # 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
|
153 library("NMF") |
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 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
|
155 # 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
|
156 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
|
157 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
|
158 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
|
159 # 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
|
160 # (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
|
161 # to achieve stability and avoid local minima) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
162 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
|
163 # 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
|
164 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
|
165 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
|
166 # 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
|
167 p5 <- plot_96_profile(nmf_res$signatures, condensed = TRUE) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
168 new_sig_matrix <- reshape2::dcast(p5$data, substitution + context ~ variable, value.var = "value") |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
169 new_sig_matrix = format(new_sig_matrix, scientific=TRUE) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
170 write.table(new_sig_matrix, file=opt$sigmatrix, quote = FALSE, row.names = FALSE, sep="\t") |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
171 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
|
172 # Visualize the contribution of the signatures in a barplot |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
173 pc1 <- plot_contribution(nmf_res$contribution, nmf_res$signature, mode="relative", coord_flip = TRUE) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
174 # Visualize the contribution of the signatures in absolute number of mutations |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
175 pc2 <- plot_contribution(nmf_res$contribution, nmf_res$signature, mode="absolute", coord_flip = TRUE) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
176 # 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
|
177 grid.arrange(pc1, pc2) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
178 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
179 # 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
|
180 # 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
|
181 # 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
|
182 # 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
|
183 # 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
|
184 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
|
185 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
|
186 # Plot signature contribution as a heatmap without sample clustering: |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
187 pch2 <- plot_contribution_heatmap(nmf_res$contribution, cluster_samples=FALSE) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
188 #Combine the plots into one figure: |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
189 grid.arrange(pch1, pch2, ncol = 2, widths = c(2,1.6)) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
190 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
191 # Compare the reconstructed mutational profile with the original mutational profile: |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
192 plot_compare_profiles(pseudo_mut_mat[,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
|
193 nmf_res$reconstructed[,1], |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
194 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
|
195 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
|
196 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
|
197 } |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
198 ##### 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
|
199 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
200 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
|
201 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
|
202 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
|
203 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
|
204 sp_url <- paste("https://cancer.sanger.ac.uk/cancergenome/assets/", "signatures_probabilities.txt", sep = "") |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
205 cancer_signatures = read.table(sp_url, sep = "\t", header = TRUE) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
206 new_order = match(row.names(pseudo_mut_mat), cancer_signatures$Somatic.Mutation.Type) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
207 cancer_signatures = cancer_signatures[as.vector(new_order),] |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
208 row.names(cancer_signatures) = cancer_signatures$Somatic.Mutation.Type |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
209 cancer_signatures = as.matrix(cancer_signatures[,4:33]) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
210 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
|
211 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
|
212 cosmic_colors <- col_vector[1:30] |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
213 } else { |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
214 sp_url <- "https://raw.githubusercontent.com/ARTbio/startbio/master/sigProfiler_SBS_signatures_2019_05_22.tsv" |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
215 cancer_signatures = read.table(sp_url, sep = "\t", header = TRUE) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
216 new_order = match(row.names(pseudo_mut_mat), cancer_signatures$Somatic.Mutation.Type) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
217 cancer_signatures = cancer_signatures[as.vector(new_order),] |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
218 row.names(cancer_signatures) = cancer_signatures$Somatic.Mutation.Type |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
219 cancer_signatures = as.matrix(cancer_signatures[,4:70]) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
220 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
|
221 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
|
222 cosmic_colors <- col_vector[1:67] |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
223 } |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
224 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
225 # 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
|
226 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
|
227 p6 <- plot_96_profile(cancer_signatures, condensed = TRUE, ymax = 0.3) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
228 grid.arrange(p6, top = textGrob("COSMIC signature profiles",gp=gpar(fontsize=12,font=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 } else { |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
230 p6 <- plot_96_profile(cancer_signatures[,1:33], condensed = TRUE, ymax = 0.3) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
231 p6bis <- plot_96_profile(cancer_signatures[,34:67], condensed = TRUE, ymax = 0.3) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
232 grid.arrange(p6, top = textGrob("COSMIC signature profiles (on two pages)",gp=gpar(fontsize=12,font=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 grid.arrange(p6bis, top = textGrob("COSMIC signature profiles (continued)",gp=gpar(fontsize=12,font=3))) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
234 } |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
235 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
236 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
237 # 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
|
238 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
|
239 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
240 # Plot contribution barplots |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
241 pc3 <- plot_contribution(fit_res$contribution, cancer_signatures, coord_flip = T, mode = "absolute") |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
242 pc4 <- plot_contribution(fit_res$contribution, cancer_signatures, coord_flip = T, mode = "relative") |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
243 pc3_data <- pc3$data |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
244 pc3 <- ggplot(pc3_data, aes(x=Sample, y=Contribution, fill=as.factor(Signature))) + |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
245 geom_bar(stat="identity", position='stack') + |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
246 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
|
247 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
|
248 labs(x = "Samples", y = "Absolute contribution") + theme_bw() + |
6
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
249 theme(panel.grid.minor.x = element_blank(), panel.grid.major.x = element_blank(), legend.position="right", |
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
250 text = element_text(size=8), |
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
251 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
|
252 pc4_data <- pc4$data |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
253 pc4 <- ggplot(pc4_data, aes(x=Sample, y=Contribution, fill=as.factor(Signature))) + |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
254 geom_bar(stat="identity", position='fill') + |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
255 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
|
256 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
|
257 scale_y_continuous(labels = scales::percent_format(accuracy = 1)) + |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
258 labs(x = "Samples", y = "Relative contribution") + theme_bw() + |
6
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
259 theme(panel.grid.minor.x = element_blank(), panel.grid.major.x = element_blank(), legend.position="right", |
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
260 text = element_text(size=8), |
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
261 axis.text.x = element_text(angle=90, hjust=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
|
262 ##### |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
263 # 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
|
264 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
|
265 pc3_data <- pc3$data |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
266 pc3_data <- merge (pc3_data, metadata_table[,c(1,3)], by.x="Sample", by.y="element_identifier") |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
267 pc3 <- ggplot(pc3_data, aes(x=Sample, y=Contribution, fill=as.factor(Signature))) + |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
268 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
|
269 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
|
270 labs(x = "Samples", y = "Absolute contribution") + theme_bw() + |
6
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
271 theme(panel.grid.minor.x = element_blank(), panel.grid.major.x = element_blank(), legend.position="right", |
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
272 text = element_text(size=8), |
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
273 axis.text.x = element_text(angle=90, hjust=1)) + |
7
34626b2b9907
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit a9c23b9c740ae50087777e336b4775e1f8035261"
artbio
parents:
6
diff
changeset
|
274 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
|
275 pc4_data <- pc4$data |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
276 pc4_data <- merge (pc4_data, metadata_table[,c(1,3)], by.x="Sample", by.y="element_identifier") |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
277 pc4 <- ggplot(pc4_data, aes(x=Sample, y=Contribution, fill=as.factor(Signature))) + |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
278 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
|
279 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
|
280 scale_y_continuous(labels = scales::percent_format(accuracy = 1)) + |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
281 labs(x = "Samples", y = "Relative contribution") + theme_bw() + |
6
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
282 theme(panel.grid.minor.x = element_blank(), panel.grid.major.x = element_blank(), legend.position="right", |
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
283 text = element_text(size=8), |
2c1d58f5c296
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 93dc5ba0403cb447a78e466f568234bd1be9e31a"
artbio
parents:
5
diff
changeset
|
284 axis.text.x = element_text(angle=90, hjust=1)) + |
7
34626b2b9907
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit a9c23b9c740ae50087777e336b4775e1f8035261"
artbio
parents:
6
diff
changeset
|
285 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
|
286 } |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
287 # Combine the two plots: |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
288 grid.arrange(pc3, pc4, top = textGrob("Absolute and Relative Contributions of Cosmic signatures to mutational patterns",gp=gpar(fontsize=12,font=3))) |
4
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
289 |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
290 # Select signatures with some contribution (above a threshold) |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
291 threshold <- tail(sort(unlist(rowSums(fit_res$contribution), use.names = FALSE)), opt$signum)[1] |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
292 select <- which(rowSums(fit_res$contribution) >= threshold) # ensure opt$signum best signatures in samples are retained, the others discarded |
7ba08c826888
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit e2d6ed12516e1bd24071962a0dfe0220cc348f3c"
artbio
parents:
3
diff
changeset
|
293 |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
294 ## pie charts of comic signatures contributions in samples |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
295 sig_data_pie <- as.data.frame(t(head(fit_res$contribution[select,]))) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
296 colnames(sig_data_pie) <- gsub("nature", "", colnames(sig_data_pie)) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
297 sig_data_pie_percents <- sig_data_pie / (apply(sig_data_pie,1,sum)) * 100 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
298 sig_data_pie_percents$sample <- rownames(sig_data_pie_percents) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
299 library(reshape2) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
300 melted_sig_data_pie_percents <-melt(data=sig_data_pie_percents) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
301 melted_sig_data_pie_percents$label <- sub("Sig.", "", melted_sig_data_pie_percents$variable) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
302 melted_sig_data_pie_percents$pos <- cumsum(melted_sig_data_pie_percents$value) - melted_sig_data_pie_percents$value/2 |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
303 p7 <- ggplot(melted_sig_data_pie_percents, aes(x="", y=value, group=variable, fill=variable)) + |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
304 geom_bar(width = 1, stat = "identity") + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
305 geom_text(aes(label = label), position = position_stack(vjust = 0.5), color="black", size=3) + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
306 coord_polar("y", start=0) + facet_wrap(~ sample) + |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
307 labs(x="", y="Samples", fill = cosmic_tag) + |
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 = paste0(length(select), " most contributing\nSignatures"), values = cosmic_colors[select]) |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
309 theme(axis.text = element_blank(), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
310 axis.ticks = element_blank(), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
311 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
|
312 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
|
313 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
314 # 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
|
315 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
|
316 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
|
317 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
|
318 } |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
319 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
320 # 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
|
321 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
|
322 # 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
|
323 cos_sim_ori_rec <- as.data.frame(diag(cos_sim_ori_rec)) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
324 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
325 # 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
|
326 # 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
|
327 # 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
|
328 # 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
|
329 # 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
|
330 # the COSMIC signatures. You could use, for example, cosine similarity of 0.95 as a cutoff. |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
331 |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
332 # Adjust data frame for plotting with gpplot |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
333 colnames(cos_sim_ori_rec) = "cos_sim" |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
334 cos_sim_ori_rec$sample = row.names(cos_sim_ori_rec) |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
335 # Make barplot |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
336 p9 <- ggplot(cos_sim_ori_rec, aes(y=cos_sim, x=sample)) + |
2
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
337 geom_bar(stat="identity", fill = "skyblue4") + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
338 coord_cartesian(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
|
339 # 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
|
340 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
|
341 xlab("") + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
342 # 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
|
343 # 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
|
344 theme_bw() + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
345 theme(panel.grid.minor.y=element_blank(), |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
346 panel.grid.major.y=element_blank()) + |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
347 # Add cut.off line |
aea952be68cb
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit cd8f633245d53cf47eaf860a4e0ae8d806c34419"
artbio
parents:
0
diff
changeset
|
348 geom_hline(aes(yintercept=.95)) |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
349 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
|
350 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
|
351 } |
3
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
352 |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
353 |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
354 # 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
|
355 if (!is.null(opt$rdata)) { |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
356 save.image(file=opt$rdata) |
e332cf9dfa06
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 0f7593f703ba0dfd12aea1c0460e371f08b57d2f"
artbio
parents:
2
diff
changeset
|
357 } |