Mercurial > repos > iuc > coverage_report
annotate CoverageReport.pl @ 0:30f8f85e3f98 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
author | iuc |
---|---|
date | Wed, 25 Oct 2017 12:37:35 -0400 |
parents | |
children |
rev | line source |
---|---|
0
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env perl |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
2 # load modules |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
3 use warnings; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
4 use Getopt::Std; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
5 use File::Basename; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
6 use Number::Format; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
7 use Cwd; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
8 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
9 my %opts; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
10 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
11 # number format |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
12 my $de = new Number::Format(-thousands_sep =>',',-decimal_point => '.'); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
13 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
14 ########## |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
15 ## opts ## |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
16 ########## |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
17 ## input files |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
18 # b : path to input (b)am file |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
19 # t : path to input (t)arget regions in BED format |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
20 ## output files |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
21 # o : report pdf (o)utput file |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
22 ## entries in the report |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
23 # r : Coverage per (r)egion (boolean) |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
24 # s : (s)ubregion coverage if average < specified (plots for positions along target region) (boolean) |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
25 # S : (S)ubregion coverage for ALL failed exons => use either s OR S or you will have double plots. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
26 # A : (A)ll exons will be plotted. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
27 # L : (L)ist failed exons instead of plotting |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
28 # m : (m)inimal Coverage threshold |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
29 # f : fraction of average as threshold |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
30 # n : sample (n)ame. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
31 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
32 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
33 getopts('b:t:o:rsSALm:n:f:', \%opts) ; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
34 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
35 my $tmp = getcwd(); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
36 # make output directory in (tmp) working dir |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
37 our $wd = "$tmp/Coverage.".int(rand(1000)); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
38 while (-d $wd) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
39 $wd = "$tmp/Coverage.".int(rand(1000)); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
40 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
41 system("mkdir $wd"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
42 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
43 ## variables |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
44 our %commandsrun = (); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
45 my ($thresh,$frac,$pdffile,$samplename,$totalmapped); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
46 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
47 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
48 if (!exists($opts{'b'}) || !-e $opts{'b'}) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
49 die('Bam File not found'); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
50 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
51 if (!exists($opts{'t'}) || !-e $opts{'t'}) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
52 die('Target File (BED) not found'); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
53 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
54 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
55 if (exists($opts{'m'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
56 $thresh = $opts{'m'}; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
57 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
58 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
59 $thresh = 40; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
60 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
61 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
62 if (exists($opts{'f'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
63 $frac = $opts{'f'}; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
64 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
65 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
66 $frac = 0.2; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
67 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
68 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
69 if (exists($opts{'o'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
70 $pdffile = $opts{'o'}; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
71 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
72 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
73 $pdffile = "$wd/CoverageReport.pdf"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
74 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
75 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
76 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
77 # 1. Global Summary => default |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
78 &GlobalSummary($opts{'b'}, $opts{'t'}); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
79 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
80 # 2. Coverage per position |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
81 &SubRegionCoverage($opts{'b'}, $opts{'t'}); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
82 our %filehash; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
83 if (exists($opts{'s'}) || exists($opts{'S'}) || exists($opts{'A'}) || exists($opts{'L'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
84 system("mkdir $wd/SplitFiles"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
85 ## get position coverages |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
86 ## split input files |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
87 open IN, "$wd/Targets.Position.Coverage"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
88 my $fileidx = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
89 my $currreg = ''; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
90 while (<IN>) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
91 my $line = $_; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
92 chomp($line); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
93 my @p = split(/\t/,$line); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
94 my $reg = $p[0].'-'.$p[1].'-'.$p[2]; #.$p[3]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
95 my $ex = $p[3]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
96 if ($reg ne $currreg) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
97 ## new exon open new outfile |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
98 if ($currreg ne '') { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
99 ## filehandle is open. close it |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
100 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
101 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
102 if (!exists($filehash{$reg})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
103 $fileidx++; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
104 $filehash{$reg}{'idx'} = $fileidx; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
105 $filehash{$reg}{'exon'} = $ex; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
106 open OUT, ">> $wd/SplitFiles/File_$fileidx.txt"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
107 $currreg = $reg; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
108 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
109 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
110 open OUT, ">> $wd/SplitFiles/File_".$filehash{$reg}{'idx'}.".txt"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
111 $currreg = $reg; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
112 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
113 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
114 ## print the line to the open filehandle. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
115 print OUT "$line\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
116 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
117 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
118 close IN; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
119 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
120 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
121 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
122 ## sort output files according to targets file |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
123 if (exists($opts{'r'}) ) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
124 my %hash = (); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
125 open IN, "$wd/Targets.Global.Coverage"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
126 while (<IN>) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
127 chomp; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
128 my @p = split(/\t/,$_) ; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
129 $hash{$p[3]} = $_; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
130 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
131 close IN; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
132 open OUT, ">$wd/Targets.Global.Coverage"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
133 open IN, $opts{'t'}; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
134 while (<IN>) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
135 chomp; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
136 my @p = split(/\t/,$_) ; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
137 print OUT $hash{$p[3]} . "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
138 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
139 close IN; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
140 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
141 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
142 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
143 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
144 #################################### |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
145 ## PROCESS RESULTS & CREATE PLOTS ## |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
146 #################################### |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
147 system("mkdir $wd/Report"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
148 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
149 system("mkdir $wd/Rout"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
150 system("mkdir $wd/Plots"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
151 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
152 $samplename = $opts{'n'}; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
153 $samplename =~ s/_/\\_/g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
154 $samplename =~ s/\..+$//g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
155 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
156 # 0. Preamble |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
157 ## compose preamble |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
158 open OUT, ">$wd/Report/Report.tex"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
159 print OUT '\documentclass[a4paper,10pt]{article}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
160 print OUT '\usepackage[left=2cm,top=1.5cm,right=1.5cm,bottom=2.5cm,nohead]{geometry}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
161 print OUT '\usepackage{longtable}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
162 print OUT '\usepackage{fancyhdr}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
163 print OUT '\usepackage{fontspec}' . "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
164 print OUT '\usepackage{color}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
165 print OUT '\definecolor{grey}{RGB}{160,160,160}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
166 print OUT '\definecolor{darkgrey}{RGB}{100,100,100}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
167 print OUT '\definecolor{red}{RGB}{255,0,0}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
168 print OUT '\definecolor{orange}{RGB}{238,118,0}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
169 print OUT '\setlength\LTleft{0pt}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
170 print OUT '\setlength\LTright{0pt}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
171 print OUT '\begin{document}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
172 print OUT '\pagestyle{fancy}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
173 print OUT '\fancyhead{}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
174 print OUT '\renewcommand{\footrulewidth}{0.4pt}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
175 print OUT '\renewcommand{\headrulewidth}{0pt}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
176 print OUT '\fancyfoot[R]{\today\hspace{2cm}\thepage\ of \pageref{endofdoc}}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
177 print OUT '\fancyfoot[C]{}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
178 print OUT '\fancyfoot[L]{Coverage Report for ``'.$samplename.'"}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
179 print OUT '\let\oldsubsubsection=\subsubsection'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
180 print OUT '\renewcommand{\subsubsection}{%'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
181 print OUT ' \filbreak'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
182 print OUT ' \oldsubsubsection'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
183 print OUT '}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
184 # main title |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
185 print OUT '\section*{Coverage Report for ``'.$samplename.'"}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
186 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
187 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
188 # 1. Summary Report |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
189 # Get samtools flagstat summary of BAM file |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
190 my $flagstat = `samtools flagstat $opts{'b'}`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
191 my @s = split(/\n/,$flagstat); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
192 # Get number of reads mapped in total |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
193 ## updated on 2012-10-1 !! |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
194 $totalmapped = $s[2]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
195 $totalmapped =~ s/^(\d+)(\s.+)/$1/; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
196 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
197 if ( not $totalmapped){ |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
198 exit; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
199 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
200 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
201 # count columns |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
202 my $head = `head -n 1 $wd/Targets.Global.Coverage`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
203 chomp($head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
204 my @cols = split(/\t/,$head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
205 my $nrcols = scalar(@cols); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
206 my $covcol = $nrcols - 3; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
207 # get min/max/median/average coverage => values |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
208 my $covs = `cut -f $covcol $wd/Targets.Global.Coverage`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
209 my @coverages = split(/\n/,$covs); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
210 my ($eavg,$med,$min,$max,$first,$third,$ontarget) = arraystats(@coverages); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
211 my $spec = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
212 $spec=sprintf("%.1f",($ontarget / $totalmapped)*100); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
213 # get min/max/median/average coverage => boxplot in R |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
214 open OUT, ">$wd/Rout/boxplot.R"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
215 print OUT 'coverage <- read.table("../Targets.Global.Coverage",as.is=TRUE,sep="\t",header=FALSE)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
216 print OUT 'coverage <- coverage[,'.$covcol.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
217 print OUT 'png(file="../Plots/CoverageBoxPlot.png", bg="white", width=240, height=480)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
218 print OUT 'boxplot(coverage,range=1.5,main="Target Region Coverage")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
219 print OUT 'graphics.off()'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
220 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
221 system("cd $wd/Rout && Rscript boxplot.R") == 0 || die "Could not run boxplot.R with following error '$!'\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
222 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
223 ## global nt coverage plot |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
224 ## use perl to make histogram (lower memory) |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
225 open IN, "$wd/Targets.Position.Coverage"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
226 my %dens; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
227 my $counter = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
228 my $sum = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
229 my $avg = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
230 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
231 while (<IN>) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
232 chomp(); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
233 my @p = split(/\t/); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
234 $sum += $p[-1]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
235 $counter++; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
236 if (defined($dens{$p[-1]})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
237 $dens{$p[-1]}++; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
238 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
239 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
240 $dens{$p[-1]} = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
241 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
242 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
243 $avg = $sum/$counter; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
244 close IN; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
245 open OUT, ">$wd/Rout/hist.txt"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
246 if (!defined($dens{'0'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
247 $dens{'0'} = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
248 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
249 foreach (keys(%dens)) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
250 print OUT "$_;$dens{$_}\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
251 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
252 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
253 open OUT, ">$wd/Rout/ntplot.R"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
254 # read coverage hist in R to plot |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
255 print OUT 'coverage <- read.table("hist.txt" , as.is = TRUE, header=FALSE,sep=";")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
256 print OUT 'mincov <- '."$thresh \n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
257 print OUT "avg <- round($avg,digits=8)\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
258 print OUT "colnames(coverage) <- c('cov','count')\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
259 print OUT 'coverage$cov <- coverage$cov / avg'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
260 print OUT 'rep <- which(coverage$cov > 1)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
261 print OUT 'coverage[coverage$cov > 1,1] <- 1'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
262 print OUT 'values <- coverage[coverage$cov < 1,]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
263 print OUT 'values <- rbind(values,c(1,sum(coverage[coverage$cov == 1,"count"])))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
264 print OUT 'values <- values[order(values$cov),]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
265 print OUT 'prevcount <- 0'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
266 # make cumulative count data frame |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
267 print OUT 'for (i in rev(values$cov)) {'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
268 print OUT ' values[values$cov == i,"count"] <- prevcount + values[values$cov == i,"count"]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
269 print OUT ' prevcount <- values[values$cov == i,"count"]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
270 print OUT '}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
271 print OUT 'values$count <- values$count / (values[values$cov == 0,"count"] / 100)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
272 # get some values to plot lines. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
273 print OUT 'mincov.x <- mincov/avg'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
274 print OUT 'if (mincov/avg <= 1) {'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
275 print OUT ' ii <- which(values$cov == mincov.x)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
276 print OUT ' if (length(ii) == 1) {'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
277 print OUT ' mincov.y <- values[ii[1],"count"]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
278 print OUT ' } else {'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
279 print OUT ' i1 <- max(which(values$cov < mincov.x))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
280 print OUT ' i2 <- min(which(values$cov > mincov.x))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
281 print OUT ' mincov.y <- ((values[i2,"count"] - values[i1,"count"])/(values[i2,"cov"] - values[i1,"cov"]))*(mincov.x - values[i1,"cov"]) + values[i1,"count"]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
282 print OUT ' }'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
283 print OUT '}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
284 # open output image and create plot |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
285 print OUT 'png(file="../Plots/CoverageNtPlot.png", bg="white", width=540, height=480)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
286 print OUT 'par(xaxs="i",yaxs="i")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
287 print OUT 'plot(values$cov,values$count,ylim=c(0,100),pch=".",main="Cumulative Normalised Base-Coverage Plot",xlab="Normalizalised Coverage",ylab="Cumulative Nr. Of Bases")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
288 print OUT 'lines(values$cov,values$count)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
289 print OUT 'if (mincov.x <= 1) {'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
290 print OUT ' lines(c(mincov.x,mincov.x),c(0,mincov.y),lty=2,col="darkgreen")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
291 print OUT ' lines(c(0,mincov.x),c(mincov.y,mincov.y),lty=2,col="darkgreen")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
292 print OUT ' text(1,(95),pos=2,col="darkgreen",labels="Threshold: '.$thresh.'x")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
293 print OUT ' text(1,(91),pos=2,col="darkgreen",labels=paste("%Bases: ",round(mincov.y,2),"%",sep=""))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
294 print OUT '} else {'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
295 print OUT ' text(1,(95),pos=2,col="darkgreen",labels="Threshold ('.$thresh.'x) > Average")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
296 print OUT ' text(1,(91),pos=2,col="darkgreen",labels="Plotting impossible")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
297 print OUT '}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
298 print OUT 'frac.x <- '."$frac\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
299 print OUT 'ii <- which(values$cov == frac.x)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
300 print OUT 'if (length(ii) == 1) {'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
301 print OUT ' frac.y <- values[ii[1],"count"]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
302 print OUT '} else {'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
303 print OUT ' i1 <- max(which(values$cov < frac.x))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
304 print OUT ' i2 <- min(which(values$cov > frac.x))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
305 print OUT ' frac.y <- ((values[i2,"count"] - values[i1,"count"])/(values[i2,"cov"] - values[i1,"cov"]))*(frac.x - values[i1,"cov"]) + values[i1,"count"]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
306 print OUT '}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
307 print OUT 'lines(c(frac.x,frac.x),c(0,frac.y),lty=2,col="red")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
308 print OUT 'lines(c(0,frac.x),c(frac.y,frac.y),lty=2,col="red")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
309 #iprint OUT 'text((frac.x+0.05),(frac.y - 2),pos=4,col="red",labels=paste(frac.x," x Avg.Cov : ",round(frac.x * avg,2),"x",sep="" ))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
310 #print OUT 'text((frac.x+0.05),(frac.y-5),pos=4,col="red",labels=paste("%Bases: ",round(frac.y,2),"%",sep=""))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
311 print OUT 'text(1,86,pos=2,col="red",labels=paste(frac.x," x Avg.Cov : ",round(frac.x * avg,2),"x",sep="" ))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
312 print OUT 'text(1,82,pos=2,col="red",labels=paste("%Bases: ",round(frac.y,2),"%",sep=""))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
313 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
314 print OUT 'graphics.off()'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
315 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
316 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
317 system("cd $wd/Rout && Rscript ntplot.R") == 0 || die "Could not run ntplot.R with following error '$!'\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
318 ## PRINT TO .TEX FILE |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
319 open OUT, ">>$wd/Report/Report.tex"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
320 # average coverage overviews |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
321 print OUT '\subsection*{Overall Summary}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
322 print OUT '{\small '; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
323 # left : boxplot |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
324 print OUT '\begin{minipage}{0.3\linewidth}\centering'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
325 print OUT '\includegraphics[width=\textwidth,keepaspectratio=true]{../Plots/CoverageBoxPlot.png}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
326 print OUT '\end{minipage}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
327 # right : cum.cov.plot |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
328 print OUT '\hspace{0.6cm}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
329 print OUT '\begin{minipage}{0.65\linewidth}\centering'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
330 print OUT '\includegraphics[width=\textwidth,keepaspectratio=true]{../Plots/CoverageNtPlot.png}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
331 print OUT '\end{minipage} \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
332 ## next line |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
333 print OUT '\begin{minipage}{0.48\linewidth}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
334 print OUT '\vspace{-1.2em}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
335 print OUT '\begin{tabular}{ll}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
336 # bam statistics |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
337 print OUT '\multicolumn{2}{l}{\textbf{\underline{Samtools Flagstat Summary}}} \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
338 foreach (@s) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
339 $_ =~ m/^(\d+)\s(.+)$/; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
340 my $one = $1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
341 my $two = $2; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
342 $two =~ s/\s\+\s0\s//; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
343 $two = ucfirst($two); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
344 $one =~ s/%/\\%/g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
345 # remove '+ 0 ' from front |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
346 $two =~ s/\+\s0\s//; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
347 # remove trailing from end |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
348 $two =~ s/(\s\+.*)|(:.*)/\)/; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
349 $two =~ s/%/\\%/g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
350 $two =~ s/>=/\$\\ge\$/g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
351 $two = ucfirst($two); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
352 print OUT '\textbf{'.$two.'} & '.$one.' \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
353 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
354 print OUT '\end{tabular}\end{minipage}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
355 print OUT '\hspace{1.5cm}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
356 # target coverage statistics |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
357 print OUT '\begin{minipage}{0.4\linewidth}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
358 #print OUT '\vspace{-4.8em}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
359 print OUT '\begin{tabular}{ll}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
360 print OUT '\multicolumn{2}{l}{\textbf{\underline{Target Region Coverage}}} \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
361 print OUT '\textbf{Number of Target Regions} & '.scalar(@coverages).' \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
362 print OUT '\textbf{Minimal Region Coverage} & '.$min.' \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
363 print OUT '\textbf{25\% Region Coverage} & '.$first.' \\\\'. "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
364 print OUT '\textbf{50\% (Median) Region Coverage} & '.$med.' \\\\'. "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
365 print OUT '\textbf{75\% Region Coverage} & '.$third.' \\\\'. "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
366 print OUT '\textbf{Maximal Region Coverage} & '.$max.' \\\\'. "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
367 print OUT '\textbf{Average Region Coverage} & '.int($eavg).' \\\\'. "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
368 print OUT '\textbf{Mapped On Target} & '.$spec.' \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
369 print OUT '\multicolumn{2}{l}{\textbf{\underline{Target Base Coverage }}} \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
370 print OUT '\textbf{Number of Target Bases} & '.$counter.' \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
371 print OUT '\textbf{Average Base Coverage} & '.int($avg).' \\\\'. "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
372 print OUT '\textbf{Non-Covered Bases} & '.$dens{'0'}.' \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
373 #print OUT '\textbf{Bases Covered $ge$ '.$frac.'xAvg.Cov} & '. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
374 print OUT '\end{tabular}\end{minipage}}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
375 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
376 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
377 # 2. GLOBAL COVERAGE OVERVIEW PER GENE |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
378 my @failedexons; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
379 my @allexons; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
380 my @allregions; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
381 my @failedregions; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
382 if (exists($opts{'r'}) || exists($opts{'s'}) || exists($opts{'S'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
383 # count columns |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
384 my $head = `head -n 1 $wd/Targets.Global.Coverage`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
385 chomp($head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
386 my @cols = split(/\t/,$head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
387 my $nrcols = scalar(@cols); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
388 my $covcol = $nrcols - 3; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
389 # Coverage Plots for each gene => barplots in R, table here. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
390 open IN, "$wd/Targets.Global.Coverage"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
391 my $currgroup = ''; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
392 my $startline = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
393 my $stopline = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
394 my $linecounter = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
395 my $nrcol=0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
396 while (<IN>) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
397 $linecounter++; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
398 chomp($_); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
399 my @c = split(/\t/,$_); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
400 push(@allregions,$c[0].'-'.$c[1].'-'.$c[2]); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
401 my $group = $c[3]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
402 ## coverage failure? |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
403 if ($c[$nrcol-1] < 1 || $c[$covcol-1] < $thresh) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
404 push(@failedexons,$group); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
405 push(@failedregions,$c[0].'-'.$c[1].'-'.$c[2]); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
406 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
407 ## store exon |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
408 push(@allexons,$group); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
409 ## extract and check gene |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
410 $group =~ s/^(\S+)[\|\s](.+)/$1/; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
411 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
412 my $scale; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
413 if ($group ne $currgroup ) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
414 if ($currgroup ne '') { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
415 # new gene, make plot. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
416 open OUT, ">$wd/Rout/barplot.R"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
417 print OUT 'coveragetable <- read.table("../Targets.Global.Coverage",as.is=TRUE,sep="\t",header=FALSE)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
418 print OUT 'coverage <- coveragetable[c('.$startline.':'.$stopline.'),'.$covcol.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
419 print OUT 'entries <- coveragetable[c('.$startline.':'.$stopline.'),4]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
420 print OUT 'entries <- sub("\\\\S+\\\\|","",entries,perl=TRUE)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
421 print OUT 'coverage[coverage < 1] <- 1'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
422 print OUT 'colors <- c(rep("grey",length(coverage)))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
423 # coverage not whole target region => orange |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
424 print OUT 'covperc <- coveragetable[c('.$startline.':'.$stopline.'),'.$nrcols.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
425 print OUT 'colors[covperc<1] <- "orange"'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
426 # coverage below threshold => red |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
427 print OUT 'colors[coverage<'.$thresh.'] <- "red"'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
428 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
429 if ($stopline - $startline > 20) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
430 $scale = 2; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
431 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
432 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
433 $scale = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
434 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
435 my $width = 480 * $scale; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
436 my $height = 240 * $scale; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
437 print OUT 'png(file="../Plots/Coverage_'.$currgroup.'.png", bg="white", width='.$width.', height='.$height.')'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
438 print OUT 'ylim = c(0,max(max(log10(coverage),log10('.($thresh+20).'))))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
439 print OUT 'mp <- barplot(log10(coverage),col=colors,main="Exon Coverage for '.$currgroup.'",ylab="Log10(Coverage)",ylim=ylim)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
440 print OUT 'text(mp, log10(coverage) + '.(0.4/$scale).',format(coverage),xpd = TRUE,srt=90)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
441 print OUT 'text(mp,par("usr")[3]-0.05,labels=entries,srt=45,adj=1,xpd=TRUE)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
442 print OUT 'abline(h=log10('.$thresh.'),lwd=4,col=rgb(255,0,0,100,maxColorValue=255))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
443 print OUT 'graphics.off()'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
444 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
445 system("cd $wd/Rout && Rscript barplot.R") == 0 || die "Could not run barplot.R with following error '$!'\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
446 if ($scale == 1) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
447 push(@small,'\includegraphics[width=\textwidth,keepaspectratio=true]{../Plots/Coverage_'.$currgroup.'.png}'); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
448 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
449 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
450 push(@large,'\includegraphics[width=\textwidth,keepaspectratio=true]{../Plots/Coverage_'.$currgroup.'.png}'); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
451 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
452 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
453 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
454 $currgroup = $group; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
455 $startline = $linecounter; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
456 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
457 $stopline = $linecounter; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
458 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
459 close IN; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
460 if ($currgroup ne '') { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
461 # last gene, make plot. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
462 open OUT, ">$wd/Rout/barplot.R"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
463 print OUT 'coveragetable <- read.table("../Targets.Global.Coverage",as.is=TRUE,sep="\t",header=FALSE)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
464 print OUT 'coverage <- coveragetable[c('.$startline.':'.$stopline.'),'.$covcol.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
465 print OUT 'entries <- coveragetable[c('.$startline.':'.$stopline.'),4]'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
466 print OUT 'entries <- sub("\\\\S+\\\\|","",entries,perl=TRUE)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
467 print OUT 'coverage[coverage < 1] <- 1'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
468 print OUT 'colors <- c(rep("grey",length(coverage)))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
469 print OUT 'colors[coverage<'.$thresh.'] <- "red"'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
470 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
471 if ($stopline - $startline > 20) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
472 $scale = 2; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
473 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
474 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
475 $scale = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
476 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
477 my $width = 480 * $scale; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
478 my $height = 240 * $scale; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
479 print OUT 'png(file="../Plots/Coverage_'.$currgroup.'.png", bg="white", width='.$width.', height='.$height.')'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
480 print OUT 'ylim = c(0,max(max(log10(coverage),log10('.($thresh+20).'))))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
481 print OUT 'mp <- barplot(log10(coverage),col=colors,main="Exon Coverage for '.$currgroup.'",ylab="Log10(Coverage)", ylim=ylim)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
482 print OUT 'text(mp, log10(coverage) + log10(2),format(coverage),xpd = TRUE,srt=90)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
483 print OUT 'text(mp,par("usr")[3]-0.1,labels=entries,srt=45,adj=1,xpd=TRUE)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
484 print OUT 'abline(h=log10('.$thresh.'),lwd=4,col=rgb(255,0,0,100,maxColorValue=255))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
485 print OUT 'graphics.off()'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
486 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
487 system("cd $wd/Rout && Rscript barplot.R") == 0 || die "Could not run barplot.R with following error '$!'\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
488 if ($scale == 1) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
489 push(@small,'\includegraphics[width=\textwidth,keepaspectratio=true]{../Plots/Coverage_'.$currgroup.'.png}'); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
490 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
491 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
492 push(@large,'\includegraphics[width=\textwidth,keepaspectratio=true]{../Plots/Coverage_'.$currgroup.'.png}'); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
493 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
494 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
495 ## print to TEX |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
496 open OUT, ">>$wd/Report/Report.tex"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
497 print OUT '\subsection*{Gene Summaries}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
498 print OUT '\underline{Legend:} \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
499 print OUT '{\color{red}\textbf{RED:} Coverage did not reach set threshold of '.$thresh.'} \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
500 print OUT '{\color{orange}\textbf{ORANGE:} Coverage was incomplete for the exon. Overruled by red.} \\\\' ."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
501 my $col = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
502 foreach (@small) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
503 if ($col > 2) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
504 $col = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
505 print OUT "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
506 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
507 print OUT '\begin{minipage}{0.5\linewidth}\centering'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
508 print OUT $_."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
509 print OUT '\end{minipage}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
510 $col++; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
511 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
512 ## new line |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
513 if ($col == 2) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
514 print OUT '\\\\'." \n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
515 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
516 foreach(@large) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
517 print OUT $_."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
518 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
519 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
520 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
521 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
522 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
523 # 3. Detailed overview of failed exons (globally failed) |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
524 if (exists($opts{'s'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
525 # count columns |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
526 my $head = `head -n 1 $wd/Targets.Position.Coverage`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
527 chomp($head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
528 my $subtitle; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
529 my @cols = split(/\t/,$head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
530 my $nrcols = scalar(@cols); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
531 my $covcol = $nrcols; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
532 my $poscol = $nrcols -1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
533 # tex section header |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
534 open TEX, ">>$wd/Report/Report.tex"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
535 print TEX '\subsection*{Failed Exon Plots}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
536 $col = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
537 print TEX '\underline{NOTE:} Only exons with global coverage $<$'.$thresh.' or incomplete coverage were plotted \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
538 foreach(@failedregions) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
539 if ($col > 2) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
540 $col = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
541 print TEX "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
542 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
543 # which exon |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
544 my $region = $_; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
545 my $exon = $filehash{$region}{'exon'}; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
546 # link exon to tmp file |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
547 my $exonfile = "$wd/SplitFiles/File_".$filehash{$region}{'idx'}.".txt"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
548 ## determine transcript orientation and location |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
549 my $firstline = `head -n 1 $exonfile`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
550 my @firstcols = split(/\t/,$firstline); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
551 my $orient = $firstcols[5]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
552 my $genomicchr = $firstcols[0]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
553 my $genomicstart = $firstcols[1]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
554 my $genomicstop = $firstcols[2]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
555 if ($orient eq '+') { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
556 $bps = $genomicstop - $genomicstart + 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
557 $subtitle = "Region 0-$bps: $genomicchr:".$de->format_number($genomicstart)."+".$de->format_number($genomicstop); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
558 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
559 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
560 $bps = $genomicstop - $genomicstart + 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
561 $subtitle = "Region 0-$bps: $genomicchr:".$de->format_number($genomicstart)."-".$de->format_number($genomicstop); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
562 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
563 # print Rscript |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
564 open OUT, ">$wd/Rout/exonplot.R"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
565 print OUT 'coveragetable <- read.table("'.$exonfile.'",as.is=TRUE,sep="\t",header=FALSE)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
566 print OUT 'coverage <- coveragetable[,'.$covcol.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
567 print OUT 'coverage[coverage < 1] <- 1'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
568 print OUT 'positions <- coveragetable[,'.$poscol.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
569 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
570 my $width = 480 ; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
571 my $height = 240 ; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
572 my $exonstr = $exon; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
573 $exonstr =~ s/\s/_/g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
574 $exon =~ s/_/ /g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
575 $exon =~ s/\|/ /g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
576 print OUT 'png(file="../Plots/Coverage_'.$exonstr.'.png", bg="white", width='.$width.', height='.$height.')'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
577 print OUT 'ylim = c(0,log10(max(max(coverage),'.($thresh+10).')))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
578 if ($orient eq '-') { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
579 print OUT 'plot(positions,log10(coverage),type="n",main="Coverage for '.$exon.'",ylab="log10(Coverage)",ylim=ylim,xlab="Position",xlim=rev(range(positions)),sub="(Transcribed from minus strand)")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
580 print OUT 'mtext("'.$subtitle.'")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
581 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
582 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
583 print OUT 'plot(positions,log10(coverage),type="n",main="Coverage for '.$exon.'",ylab="log10(Coverage)",ylim=ylim,xlab="Position",sub="(Transcribed from plus strand)")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
584 print OUT 'mtext("'.$subtitle.'")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
585 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
586 print OUT 'lines(positions,log10(coverage))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
587 print OUT 'abline(h=log10('.$thresh.'),lwd=4,col=rgb(255,0,0,100,maxColorValue=255))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
588 print OUT 'failedpos <- positions[coverage<'.$thresh.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
589 print OUT 'failedcov <- coverage[coverage<'.$thresh.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
590 print OUT 'points(failedpos,log10(failedcov),col="red",pch=19)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
591 print OUT 'graphics.off()'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
592 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
593 # run R script |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
594 system("cd $wd/Rout && Rscript exonplot.R")== 0 || die "Could not run exonplot.R with following error '$!'\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
595 # Add to .TEX |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
596 print TEX '\begin{minipage}{0.5\linewidth}\centering'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
597 print TEX '\includegraphics[width=\textwidth,keepaspectratio=true]{../Plots/Coverage_'.$exonstr.'.png}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
598 print TEX '\end{minipage}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
599 $col++; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
600 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
601 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
602 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
603 ## plot failed (subregion) or all exons |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
604 if (exists($opts{'S'}) || exists($opts{'A'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
605 # count columns |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
606 my $head = `head -n 1 $wd/Targets.Position.Coverage`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
607 chomp($head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
608 my @cols = split(/\t/,$head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
609 my $nrcols = scalar(@cols); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
610 my $covcol = $nrcols; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
611 my $poscol = $nrcols -1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
612 # tex section header |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
613 open TEX, ">>$wd/Report/Report.tex"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
614 print TEX '\subsection*{Failed Exon Plots}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
615 if (exists($opts{'S'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
616 print TEX '\underline{NOTE:} ALL exons were tested for local coverage $<$'.$thresh.' \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
617 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
618 elsif (exists($opts{'A'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
619 print TEX '\underline{NOTE:} ALL exons are plotted, regardless of coverage \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
620 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
621 $col = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
622 foreach(@allregions) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
623 if ($col > 2) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
624 $col = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
625 print TEX "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
626 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
627 # which exon |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
628 my $region = $_; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
629 my $exon = $filehash{$region}{'exon'}; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
630 # grep exon to tmp file |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
631 my $exonfile = "$wd/SplitFiles/File_".$filehash{$region}{'idx'}.".txt"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
632 ## determine transcript orientation. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
633 my $firstline = `head -n 1 $exonfile`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
634 my @firstcols = split(/\t/,$firstline); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
635 my $orient = $firstcols[5]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
636 my $genomicchr = $firstcols[0]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
637 my $genomicstart = $firstcols[1]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
638 my $genomicstop = $firstcols[2]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
639 my $subtitle; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
640 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
641 if ($orient eq '+') { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
642 my $bps = $genomicstop - $genomicstart + 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
643 $subtitle = "Region 0-$bps: $genomicchr:".$de->format_number($genomicstart)."+".$de->format_number($genomicstop); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
644 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
645 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
646 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
647 my $bps = $genomicstop - $genomicstart + 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
648 $subtitle = "Region 0-$bps: $genomicchr:".$de->format_number($genomicstart)."-".$de->format_number($genomicstop); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
649 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
650 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
651 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
652 # check if failed |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
653 if (exists($opts{'S'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
654 my $cs = `cut -f $covcol '$exonfile' `; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
655 my @c = split(/\n/,$cs); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
656 @c = sort { $a <=> $b } @c; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
657 if ($c[0] >= $thresh) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
658 # lowest coverage > threshold => skip |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
659 next; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
660 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
661 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
662 # print Rscript |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
663 open OUT, ">$wd/Rout/exonplot.R"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
664 print OUT 'coveragetable <- read.table("'.$exonfile.'",as.is=TRUE,sep="\t",header=FALSE)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
665 print OUT 'coverage <- coveragetable[,'.$covcol.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
666 print OUT 'coverage[coverage < 1] <- 1'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
667 print OUT 'positions <- coveragetable[,'.$poscol.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
668 my $width = 480 ; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
669 my $height = 240 ; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
670 my $exonstr = $exon; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
671 $exonstr =~ s/\s/_/g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
672 $exon =~ s/_/ /g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
673 $exon =~ s/\|/ /g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
674 print OUT 'png(file="../Plots/Coverage_'.$exonstr.'.png", bg="white", width='.$width.', height='.$height.')'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
675 print OUT 'ylim = c(0,log10(max(max(coverage),'.($thresh+10).')))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
676 if ($orient eq '-') { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
677 print OUT 'plot(positions,log10(coverage),type="n",main="Coverage for '.$exon.'",ylab="log10(Coverage)",ylim=ylim,xlab="Position",xlim=rev(range(positions)),sub="(Transcribed from minus strand)")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
678 print OUT 'mtext("'.$subtitle.'")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
679 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
680 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
681 print OUT 'plot(positions,log10(coverage),type="n",main="Coverage for '.$exon.'",ylab="log10(Coverage)",ylim=ylim,xlab="Position",sub="(Transcribed from plus strand)")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
682 print OUT 'mtext("'.$subtitle.'")'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
683 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
684 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
685 print OUT 'lines(positions,log10(coverage))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
686 print OUT 'abline(h=log10('.$thresh.'),lwd=4,col=rgb(255,0,0,100,maxColorValue=255))'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
687 print OUT 'failedpos <- positions[coverage<'.$thresh.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
688 print OUT 'failedcov <- coverage[coverage<'.$thresh.']'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
689 print OUT 'points(failedpos,log10(failedcov),col="red",pch=19)'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
690 print OUT 'graphics.off()'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
691 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
692 # run R script |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
693 system("cd $wd/Rout && Rscript exonplot.R") == 0 || die "Could not run exonplot.R with following error '$!'\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
694 # Add to .TEX |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
695 print TEX '\begin{minipage}{0.5\linewidth}\centering'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
696 print TEX '\includegraphics[width=\textwidth,keepaspectratio=true]{../Plots/Coverage_'.$exonstr.'.png}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
697 print TEX '\end{minipage}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
698 $col++; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
699 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
700 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
701 ## list failed exons |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
702 if (exists($opts{'L'})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
703 # count columns |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
704 my $subtitle; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
705 my $head = `head -n 1 $wd/Targets.Position.Coverage`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
706 chomp($head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
707 my @cols = split(/\t/,$head); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
708 my $nrcols = scalar(@cols); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
709 my $covcol = $nrcols; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
710 my $poscol = $nrcols -1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
711 ## hash to print |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
712 # tex section header |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
713 open TEX, ">>$wd/Report/Report.tex"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
714 print TEX '\subsection*{List of Failed Exons}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
715 print TEX '\underline{NOTE:} ALL exons were tested for local coverage $<$'.$thresh.' \\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
716 print TEX '{\footnotesize\begin{longtable}[l]{@{\extracolsep{\fill}}llll}'."\n".'\hline'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
717 print TEX '\textbf{Target Name} & \textbf{Genomic Position} & \textbf{Avg.Coverage} & \textbf{Min.Coverage} \\\\'."\n".'\hline'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
718 print TEX '\endhead'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
719 print TEX '\hline '."\n".'\multicolumn{4}{r}{{\textsl{\footnotesize Continued on next page}}} \\\\ '."\n".'\hline' ."\n". '\endfoot' . "\n". '\endlastfoot' . "\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
720 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
721 $col = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
722 open IN, "$wd/Targets.Global.Coverage"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
723 while (<IN>) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
724 chomp($_); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
725 my @p = split(/\t/,$_); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
726 my $region = $p[0].'-'.$p[1].'-'.$p[2]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
727 my $exon = $filehash{$region}{'exon'}; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
728 # grep exon to tmp file |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
729 my $exonfile = "$wd/SplitFiles/File_".$filehash{$region}{'idx'}.".txt"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
730 ## determine transcript orientation. |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
731 my $firstline = `head -n 1 $exonfile`; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
732 my @firstcols = split(/\t/,$firstline); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
733 my $orient = $firstcols[5]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
734 my $genomicchr = $firstcols[0]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
735 my $genomicstart = $firstcols[1]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
736 my $genomicstop = $firstcols[2]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
737 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
738 if ($orient eq '+') { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
739 my $bps = $genomicstop - $genomicstart + 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
740 $subtitle = "$genomicchr:".$de->format_number($genomicstart)."+".$de->format_number($genomicstop); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
741 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
742 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
743 else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
744 my $bps = $genomicstop - $genomicstart + 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
745 $subtitle = "$genomicchr:".$de->format_number($genomicstart)."-".$de->format_number($genomicstop); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
746 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
747 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
748 # check if failed |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
749 my $cs = `cut -f $covcol '$exonfile' `; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
750 my @c = split(/\n/,$cs); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
751 my ($avg,$med,$min,$max,$first,$third,$ontarget) = arraystats(@c); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
752 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
753 if ($min >= $thresh) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
754 # lowest coverage > threshold => skip |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
755 next; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
756 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
757 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
758 # print to .tex table |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
759 if (length($exon) > 30) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
760 $exon = substr($exon,0,27) . '...'; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
761 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
762 $exon =~ s/_/ /g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
763 $exon =~ s/\|/ /g; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
764 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
765 print TEX "$exon & $subtitle & ".int($avg)." & $min ".'\\\\'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
766 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
767 close IN; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
768 print TEX '\hline'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
769 print TEX '\end{longtable}}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
770 close TEX; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
771 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
772 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
773 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
774 ## Close document |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
775 open OUT, ">>$wd/Report/Report.tex"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
776 print OUT '\label{endofdoc}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
777 print OUT '\end{document}'."\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
778 close OUT; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
779 system("cd $wd/Report && tectonic Report.tex") == 0 || die "Could not run tectonic with following error '$!'\n"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
780 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
781 ## mv report to output file |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
782 system("cp -f $wd/Report/Report.pdf '$pdffile'"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
783 ##create tar.gz file |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
784 system("mkdir $wd/Results"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
785 system("cp -Rf $wd/Plots $wd/Results/"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
786 system("cp -Rf $wd/Report/ $wd/Results/"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
787 if (-e "$wd/Targets.Global.Coverage") { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
788 system("cp -Rf $wd/Targets.Global.Coverage $wd/Results/"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
789 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
790 if (-e "$wd/Targets.Position.Coverage") { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
791 system("cp -Rf $wd/Targets.Position.Coverage $wd/Results/"); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
792 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
793 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
794 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
795 exit; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
796 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
797 ############### |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
798 ## FUNCTIONS ## |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
799 ############### |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
800 sub arraystats{ |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
801 my @array = @_; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
802 my $count = scalar(@array); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
803 @array = sort { $a <=> $b } @array; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
804 # median |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
805 my $median = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
806 if ($count % 2) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
807 $median = $array[int($count/2)]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
808 } else { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
809 $median = ($array[$count/2] + $array[$count/2 - 1]) / 2; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
810 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
811 # average |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
812 my $sum = 0; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
813 foreach (@array) { $sum += $_; } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
814 my $average = $sum / $count; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
815 # quantiles (rounded) |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
816 my $quart = int($count/4) ; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
817 my $first = $array[$quart]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
818 my $third = $array[($quart*3)]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
819 my $min = $array[0]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
820 my $max = $array[($count-1)]; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
821 return ($average,$median,$min,$max,$first,$third,$sum); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
822 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
823 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
824 sub GlobalSummary { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
825 my ($bam,$targets) = @_; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
826 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
827 my $command = "cd $wd && coverageBed -abam $bam -b $targets > $wd/Targets.Global.Coverage"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
828 if (exists($commandsrun{$command})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
829 return; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
830 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
831 system($command); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
832 $commandsrun{$command} = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
833 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
834 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
835 sub CoveragePerRegion { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
836 my ($bam,$targets) = @_; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
837 my $command = "cd $wd && coverageBed -abam $bam -b $targets > $wd/Targets.Global.Coverage"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
838 if (exists($commandsrun{$command})) { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
839 return; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
840 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
841 system($command); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
842 $commandsrun{$command} = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
843 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
844 |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
845 sub SubRegionCoverage { |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
846 my ($bam,$targets) = @_; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
847 my $command = "cd $wd && coverageBed -abam $bam -b $targets -d > $wd/Targets.Position.Coverage"; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
848 system($command); |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
849 $commandsrun{$command} = 1; |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
850 } |
30f8f85e3f98
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/coverage_report commit 1b647bb088f62c1369d963f030caecaa9ee003c7
iuc
parents:
diff
changeset
|
851 |