blib/lib/Bio/ViennaNGS/Peak.pm

filter: Statementstmt 16.5% 39 / 236 Branchbran 0.0% 0 / 84 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 56.2% 9 / 16 Podpod 100% 3 / 3 totaltotal 13.8% 51 / 369 CC 54 SCAR 57.9
CC
54
Cov
12%
raw_peaks
506.0
final_peaks
420.0
populate_data
210.0
CRAP 325.9
↑ Summary blib/lib/Bio/ViennaNGS/SpliceJunc.pm »
1 # -*-CPerl-*-
2 # Last changed Time-stamp: <2017-06-10 19:08:23 michl>
3  
4 package Bio::ViennaNGS::Peak;
5  
6 1 ▶use Bio::ViennaNGS;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use List::Util qw(sum sum0 min max first);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Bio::ViennaNGS::Util qw(sortbed);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use version; our $VERSION = version->declare("$Bio::ViennaNGS::VERSION");
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 has 'data' => (
17 is => 'ro',
18 isa => 'HashRef',
19 predicate => 'has_data',
20 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 1 );
22  
23 has 'region' => (
24 is => 'ro',
25 isa => 'HashRef',
26 predicate => 'has_region',
27 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 1 );
29  
30 has 'peaks' => (
31 is => 'ro',
32 isa => 'HashRef',
33 predicate => 'has_peaks',
34 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 1 );
36  
37 1 has 'winsize' => (
38 is => 'ro',
39 isa => 'Int',
40 predicate => 'has_winsize',
41 );
42  
43 1 has 'winsize' => (
44 is => 'ro',
45 isa => 'Int',
46 predicate => 'has_winsize',
47 );
48  
49 1 has 'interval' => (
50 is => 'ro',
51 isa => 'Int',
52 predicate => 'has_interval',
53 );
54  
55 1 has 'mincov' => (
56 is => 'ro',
57 isa => 'Int',
58 predicate => 'has_mincov',
59 );
60  
61 1 has 'length' => (
62 is => 'ro',
63 isa => 'Int',
64 predicate => 'has_length',
65 );
66  
67 1 has 'threshold' => (
68 is => 'ro',
69 isa => 'Value',
70 predicate => 'has_threshold',
71 );
72  
73 sub populate_data {
74 0 ▶ my ($self,$filep,$filen) = @_;
Subroutine populate_data: not called CC=14 SCAR=53.5
Pod documented
75 0 my $this_function = (caller(0))[3];
76 0 my ($i,$element,$chr,$start,$end,$val,$lastend);
77 0 my $have_lastend = 0;
78  
79 # parse [+] strand
80 0 foreach $element (@{$filep->data}){
81 0 ▶ unless (exists ${$self->region}{$element->chromosome}{pos}{start}){
Branch: 1 branch
BranchTrueFalseTotal
unless (exists ${$self->region;}{$element->chromosome}{"pos"}{"start"}) 0 0 0
82 0 ${$self->region}{$element->chromosome}{pos}{start} = $element->start;
83 }
84 0 ▶ if($have_lastend == 1 && $element->start>$lastend){ # fill the gap with 0s
Branch: 1 branch
BranchTrueFalseTotal
if ($have_lastend == 1 and $element->start > $lastend) 0 0 0
Condition0%0/3
$have_lastend == 1 and $element->start > $lastend
!ll&&!rl&&r
000
MC/DC0%0/2
$have_lastend == 1 and $element->start > $lastend
$have_lastend == 1 $element->start > $lastend
Truth table0%0/3
A and B
A= $have_lastend == 1B= $element->start > $lastend
ABresult
0X0
100
111
85 0 ▶ for($i=$lastend;$i<$element->start;$i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $element->start) 0 0 0
86 0 ${$self->data}{$element->chromosome}{pos}[$i] = 0.;
87 }
88 }
89 0 ▶ for ($i=$element->start;$i<$element->end;$i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $element->end) 0 0 0
90 0 ${$self->data}{$element->chromosome}{pos}[$i]=$element->dataValue;
91 }
92 0 $lastend = $element->end;
93 0 $have_lastend = 1;
94 }
95  
96 0 $lastend = 0; # reset lastend before parsing [-] strand
97 0 $have_lastend = 1; # needed to get the values parsed correctly below
98  
99 # parse [-] strand
100 0 foreach $element (@{$filen->data}){
101 0 ▶ if ($element->{dataValue} <= 0){
Branch: 1 branch
BranchTrueFalseTotal
if ($element->{"dataValue"} <= 0) 0 0 0
102 0 $element->{dataValue} *= -1;
103 }
104 0 ▶ unless (exists ${$self->region}{$element->chromosome}{neg}{start}){
Branch: 1 branch
BranchTrueFalseTotal
unless (exists ${$self->region;}{$element->chromosome}{"neg"}{"start"}) 0 0 0
105 0 ${$self->region}{$element->chromosome}{neg}{start} = $element->start;
106 }
107 0 ▶ if($have_lastend == 1 && $element->start>$lastend){ # fill the gap with 0s
Branch: 1 branch
BranchTrueFalseTotal
if ($have_lastend == 1 and $element->start > $lastend) 0 0 0
Condition0%0/3
$have_lastend == 1 and $element->start > $lastend
!ll&&!rl&&r
000
MC/DC0%0/2
$have_lastend == 1 and $element->start > $lastend
$have_lastend == 1 $element->start > $lastend
Truth table0%0/3
A and B
A= $have_lastend == 1B= $element->start > $lastend
ABresult
0X0
100
111
108 0 ▶ for($i=$lastend;$i<$element->start;$i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $element->start) 0 0 0
109 0 ${$self->data}{$element->chromosome}{neg}[$i] = 0.;
110 }
111 }
112 0 ▶ for ($i=$element->start;$i<$element->end;$i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $element->end) 0 0 0
113 0 ${$self->data}{$element->chromosome}{neg}[$i]=$element->dataValue;
114 }
115 0 $lastend = $element->end;
116 0 $have_lastend = 1;
117 }
118 0 return;
119 }
120  
121 sub raw_peaks {
122 0 ▶ my ($self,$dest,$prefix,$log) = @_;
Subroutine raw_peaks: not called CC=22 SCAR=62.3
Pod documented
123 0 my ($fn,$fn_u,$outfile,$maxidx,$have_pstart,$pstart,$pend,$chr);
124 0 my ($winstart, $winend, $winsum, $mean, $lastmax, $from, $to);
125 0 my ($index_of_maxwin);
126 0 my $suffix = "rawpeaks.bed";
127 0 my $this_function = (caller(0))[3];
128 0 my $flex = 10;
129  
130 0 ▶ croak "ERROR [$this_function]: $dest does not exist\n"
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dest 0 0 0
131 unless (-d $dest);
132  
133 0 ▶ if (defined $log){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $log) { } 0 0 0
134 0 ▶ open(LOG, ">", $log) or croak "$!";
Branch: 1 branch
BranchTrueFalseTotal
open LOG, ">", $log or croak("$!") 0 0 0
135 }
136 0 else {croak "ERROR [$this_function] \$log not defined";}
137  
138 0 $fn = $prefix.".".$suffix;
139 0 $fn_u = $prefix.".u.".$suffix;
140 0 $outfile = file($dest,$fn_u);
141  
142 0 ▶ croak "ERROR [$this_function]: $self->data not available\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_data 0 0 0
143 unless ($self->has_data);
144  
145 0 ▶ croak "ERROR [$this_function]: $self->region not available\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_region 0 0 0
146 unless ($self->has_region);
147  
148 0 ▶ open(RAWPEAKS, ">", $fn_u) or croak $!;
Branch: 1 branch
BranchTrueFalseTotal
open RAWPEAKS, ">", $fn_u or croak($!) 0 0 0
149 0 $lastmax = 0;
150 0 foreach $chr (keys (%{$self->data})){
151  
152 # pos strand
153 0 $maxidx = $#{$self->data->{$chr}{pos}} ; # largest index in array
154 0 $have_pstart = 0;
155 0 $pstart = -1;
156 0 $pend = -1;
157 0 print LOG "processing chr $chr [+] strand $maxidx\n";
158 croak "$chr has not been parsed in input data"
159 0 ▶ unless (exists $self->region->{$chr}{pos}{start});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->region->{$chr}{"pos"}{"start"} 0 0 0
160  
161 0 ▶ for ($winstart=$self->region->{$chr}{pos}{start};$winstart<($maxidx-$self->winsize);$winstart+=$self->interval){
Branch: 1 branch
BranchTrueFalseTotal
if ($winstart < $maxidx - $self->winsize) 0 0 0
162 # NOTE: does not handle the last window properly - > ignore this
163 0 $winend = $winstart + $self->winsize - 1;
164 0 $winsum = sum0 @{$self->data->{$chr}{pos}}[$winstart..$winend];
165 0 $mean = $winsum/$self->winsize;
166 #print LOG "**processing $winstart - $winend sum=$winsum mean=$mean lastmax=$lastmax\n";
167  
168 0 ▶ if ($mean > $lastmax){
Branch: 1 branch
BranchTrueFalseTotal
if ($mean > $lastmax) { } 0 0 0
169 0 $lastmax = $mean;
170 0 $index_of_maxwin = $winstart;
171 0 ▶ unless ($have_pstart == 1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($have_pstart == 1) 0 0 0
172 0 $pstart = $winstart;
173 0 $have_pstart = 1;
174 #print LOG "Peak start $chr:$winstart -- ";
175 }
176 }
177 else {
178 0 ▶ if ($mean > 0. && $mean <= $lastmax*$self->threshold ){ # peak stop criterion
Branch: 1 branch
BranchTrueFalseTotal
if ($mean > 0 and $mean <= $lastmax * $self->threshold) 0 0 0
Condition0%0/3
$mean > 0 and $mean <= $lastmax * $self->threshold
!ll&&!rl&&r
000
MC/DC0%0/2
$mean > 0 and $mean <= $lastmax * $self->threshold
$mean > 0 $mean <= $lastmax * $self->threshold
Truth table0%0/3
A and B
A= $mean > 0B= $mean <= $lastmax * $self->threshold
ABresult
0X0
100
111
179 0 $pend = $winend;
180 0 $have_pstart = 0;
181 0 $from = min($pstart,$pend);
182 0 $to = max($pstart, $pend);
183 # now add +- $flex nt to raw peaks, required fro better peak boundary determination below
184 0 ▶ if ($from-$flex > 0){$from = $from - $flex;}
Branch: 1 branch
BranchTrueFalseTotal
if ($from - $flex > 0) 0 0 0
185 0 $to= $to+$flex; # we dont know the chromsize here, hence override it in case
186 #print LOG "$pend end\n";
187 0 my %pk = (
188 chr => $chr,
189 start => $from,
190 end => $to,
191 strand => 'pos',
192 maxindex => $index_of_maxwin,
193 );
194 0 push (@{ $self->peaks->{$chr} }, \%pk);
195 0 print LOG "**PEAK $chr [+] $from-$to max at $index_of_maxwin\n";
196 0 print RAWPEAKS "$chr\t$from\t$to\tRAW\t0\t+\n";
197  
198 # reset parameters
199 0 $lastmax = 0;
200 0 $pstart = -1;
201 0 $pend = -1;
202 }
203 }
204 } # end for
205 0 $lastmax = 0;
206  
207 # neg strand
208 0 $maxidx = $#{$self->data->{$chr}{neg}}; # largest index in array
209 0 $have_pstart = 0;
210 0 $pstart = -1;
211 0 $pend = -1;
212 0 print LOG "processing chr $chr [-] strand $maxidx\n";
213 croak "$chr has not been parsed in input data"
214 0 ▶ unless (exists $self->region->{$chr}{neg}{start});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->region->{$chr}{"neg"}{"start"} 0 0 0
215  
216 0 ▶ for ($winstart=$maxidx;$winstart>($self->region->{$chr}{neg}{start}+$self->winsize);$winstart-=$self->interval){
Branch: 1 branch
BranchTrueFalseTotal
if ($winstart > $self->region->{$chr}{"neg"}{"start"} + $self->winsize) 0 0 0
217 # NOTE: does not handle the last window properly - > ignore this
218 0 $winend = $winstart - $self->winsize + 1;
219 0 $winsum = sum0 @{$self->data->{$chr}{neg}}[$winend..$winstart];
220 0 $mean = $winsum/$self->winsize;
221 #print "processing $winstart - $winend sum=$winsum mean=$mean lastmax=$lastmax\n";
222  
223 0 ▶ if ($mean > $lastmax){
Branch: 1 branch
BranchTrueFalseTotal
if ($mean > $lastmax) { } 0 0 0
224 0 $lastmax = $mean;
225 0 $index_of_maxwin = $winend;
226 0 ▶ unless ($have_pstart == 1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($have_pstart == 1) 0 0 0
227 0 $pstart = $winend;
228 0 $have_pstart = 1;
229 #print "Peak start $chr:$pstart -- ";
230 }
231 }
232 else {
233 0 ▶ if ($mean > 0. && $mean <= $lastmax*$self->threshold ){ # peak stop criterion
Branch: 1 branch
BranchTrueFalseTotal
if ($mean > 0 and $mean <= $lastmax * $self->threshold) 0 0 0
Condition0%0/3
$mean > 0 and $mean <= $lastmax * $self->threshold
!ll&&!rl&&r
000
MC/DC0%0/2
$mean > 0 and $mean <= $lastmax * $self->threshold
$mean > 0 $mean <= $lastmax * $self->threshold
Truth table0%0/3
A and B
A= $mean > 0B= $mean <= $lastmax * $self->threshold
ABresult
0X0
100
111
234 0 $pend = $winstart;
235 0 $have_pstart = 0;
236 0 $from = min($pstart,$pend);
237 0 $to = max($pstart, $pend);
238 # now add +- $flex nt to raw peaks, required fro better peak boundary determination below
239 0 ▶ if ($from-$flex > 0){$from = $from - $flex;}
Branch: 1 branch
BranchTrueFalseTotal
if ($from - $flex > 0) 0 0 0
240 0 $to = $to+$flex; # we dont know the chromsize here, hence override it in case
241 #print "$pend end\n";
242 0 my %pk = (
243 chr => $chr,
244 start => $from,
245 end => $to,
246 strand => 'neg',
247 maxindex => $index_of_maxwin,
248 );
249 0 push (@{ $self->peaks->{$chr} }, \%pk);
250 0 print LOG "**PEAK $chr [-] $from-$to max at $index_of_maxwin\n";
251 0 print RAWPEAKS "$chr\t$from\t$to\tRAW\t0\t-\n";
252  
253 # reset parameters
254 0 $lastmax = 0;
255 0 $pstart = -1;
256 0 $pend = -1;
257 }
258 }
259 } # end for
260  
261 #print LOG Dumper($self->peaks);
262  
263 } # end foreach
264 0 close(RAWPEAKS);
265 0 close(LOG);
266 0 sortbed($fn_u,$dest,$fn,1,$log);
267 }
268  
269 sub final_peaks {
270 0 ▶ my ($self,$dest,$prefix,$log) = @_;
Subroutine final_peaks: not called CC=20 SCAR=60.4
Pod documented
271 0 my ($fn,$fn_u,$outfile,$strand,$max,$idx,$val,$peak,$position,$pleft,$pright,$str);
272 0 my $suffix = "candidatepeaks.bed";
273 0 my $this_function = (caller(0))[3];
274  
275 0 ▶ croak "ERROR [$this_function]: $dest does not exist\n"
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dest 0 0 0
276 unless (-d $dest);
277  
278 0 ▶ if (defined $log){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $log) { } 0 0 0
279 0 ▶ open(LOG, ">>", $log) or croak "$!";
Branch: 1 branch
BranchTrueFalseTotal
open LOG, ">>", $log or croak("$!") 0 0 0
280 }
281 0 else {croak "ERROR [$this_function] \$log not defined";}
282  
283 0 $fn = $prefix.".".$suffix;
284 0 $fn_u = $prefix.".u.".$suffix;
285 0 $outfile = file($dest,$fn_u);
286  
287 0 ▶ croak "ERROR [$this_function]: $self->data not available\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_data 0 0 0
288 unless ($self->has_data);
289  
290 0 ▶ croak "ERROR [$this_function]: $self->peaks not available\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_peaks 0 0 0
291 unless ($self->has_peaks);
292  
293 0 ▶ open(CANDIDATEPEAKS, ">", $fn_u) or croak $!;
Branch: 1 branch
BranchTrueFalseTotal
open CANDIDATEPEAKS, ">", $fn_u or croak($!) 0 0 0
294  
295 0 foreach my $chr (keys (%{$self->peaks})){
296 0 print LOG "filtering candidate peaks in $chr\n";
297  
298 0 foreach $peak ( @{$self->peaks->{$chr}}){
299 0 my $have_pleft = 0; # we have found a proper left end
300 0 my $have_pright = 0; # we have found a proper right end
301 0 $strand = $$peak{strand};
302 0 print LOG ">>processing peak $$peak{start}-$$peak{end} [$strand] ";
303 0 $max = max @{$self->data->{$chr}{$strand}}[$$peak{start}..$$peak{end}]; # max peak elevation
304 0 print LOG "max is $max";
305 0 ▶ if ($max < $self->mincov){print LOG " ..SKIPPING\n";next;}
Branch: 1 branch
BranchTrueFalseTotal
if ($max < $self->mincov) 0 0 0
306 0 ▶ $idx = first { @{$self->data->{$chr}{$strand}}[$_] eq $max } $$peak{start}..$$peak{end}; # coordinate
Subroutine __ANON__: not called CC=1 SCAR=6.9
307 #print LOG Dumper(\$peak);
308 0 print LOG " at $idx ..KEEPING\n";
309  
310 # process regions left/right of the maximum to identify peak boundaries
311 # validity check first
312 die "maximum at $idx is not within peak region"
313 0 ▶ if ( $idx<$$peak{start} || $idx>$$peak{end} );
Branch: 1 branch
BranchTrueFalseTotal
if $idx < $peak->{"start"} or $idx > $peak->{"end"} 0 0 0
Condition0%0/3
$idx < $peak->{"start"} or $idx > $peak->{"end"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$idx < $peak->{"start"} or $idx > $peak->{"end"}
$idx < $peak->{"start"} $idx > $peak->{"end"}
Truth table0%0/3
A or B
A= $idx < $peak->{"start"}B= $idx > $peak->{"end"}
ABresult
1X1
011
000
314  
315 # find left end
316 0 ▶ for ($position = $idx; $position>$$peak{start}; $position--){
Branch: 1 branch
BranchTrueFalseTotal
if ($position > $peak->{"start"}) 0 0 0
317 0 $val = ${$self->data->{$chr}{$strand}}[$position];
318 0 print LOG "** VAL_L at pos $position $val - \$have_pleft=$have_pleft ";
319 0 ▶ if ( $val < $max*$self->threshold){
Branch: 1 branch
BranchTrueFalseTotal
if ($val < $max * $self->threshold) 0 0 0
320 0 $have_pleft = 1;
321 0 print LOG "exiting 'cause $val < ".$max*$self->threshold." - \$have_pleft=$have_pleft\n";
322 0 last;
323 }
324 0 print LOG "\n";
325 }
326 0 $pleft = $position;
327  
328 # find right end
329 0 ▶ for ($position = $idx; $position<=$$peak{end}; $position++){
Branch: 1 branch
BranchTrueFalseTotal
if ($position <= $peak->{"end"}) 0 0 0
330 0 $val = ${$self->data->{$chr}{$strand}}[$position];
331 0 print LOG "** VAL_R at pos $position $val - \$have_pright=$have_pright ";
332 0 ▶ if ( $val < $max*$self->threshold){
Branch: 1 branch
BranchTrueFalseTotal
if ($val < $max * $self->threshold) 0 0 0
333 0 $have_pright = 1;
334 0 print LOG "exiting 'cause $val < ".$max*$self->threshold."- \$have_pright=$have_pright\n";
335 0 last;
336 }
337 0 print LOG "\n";
338 }
339 0 $pright = $position;
340 0 ▶ if ($strand eq "neg"){
Branch: 1 branch
BranchTrueFalseTotal
if ($strand eq 'neg') { } 0 0 0
341 0 $str = '-';
342 }
343 else{
344 0 $str = '+';
345 }
346 0 print LOG "# PEAK characterized at $chr:$pleft-$pright\n";
347  
348 0 ▶ if ($have_pleft == 1 && $have_pright == 1){ # print only if its a proper peak
Branch: 1 branch
BranchTrueFalseTotal
if ($have_pleft == 1 and $have_pright == 1) 0 0 0
Condition0%0/3
$have_pleft == 1 and $have_pright == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$have_pleft == 1 and $have_pright == 1
$have_pleft == 1 $have_pright == 1
Truth table0%0/3
A and B
A= $have_pleft == 1B= $have_pright == 1
ABresult
0X0
100
111
349 0 ▶ if ($pright-$pleft<=$self->length){ # filter peak length
Branch: 1 branch
BranchTrueFalseTotal
if ($pright - $pleft <= $self->length) 0 0 0
350 0 print CANDIDATEPEAKS "$chr\t$pleft\t$pright\tCANDIDATE\t$max\t$str\n";
351 }
352 }
353 } # end foreach $peak
354 } # end foreach $chr
355 0 close(CANDIDATEPEAKS);
356 0 sortbed($fn_u,$dest,$fn,1,$log);
357 }
358 1 __PACKAGE__->meta->make_immutable;
359  
360 1 1;
361 __END__
362  
363  
364 =head1 NAME
365  
366 Bio::ViennaNGS::Peak - An object oriented interface for characterizing
367 peaks in RNA-seq data
368  
369 =head1 SYNOPSIS
370  
371 use Bio::ViennaNGS::Peak;
372  
373 # get an instance of Bio::ViennaNGS::peak
374 my $peaks = Bio::ViennaNGS::Peak->new();
375  
376 # parse coverage for [+] and [-] strand from Bio::ViennaNGS::FeatureIO objects
377 $peaks->populate_data($filep,$filen);
378  
379 # identify regions covered by RNA-seq signal ('raw peaks')
380 $peaks->raw_peaks($dest,$prefix,$log);
381  
382 # characterize final peaks
383 $peaks->final_peaks($dest,$prefix,$log);
384  
385  
386 =head1 DESCRIPTION
387  
388 This module provides a L<Moose> interface for characterization of
389 peaks in RNA-seq coverage data.
390  
391 =head1 METHODS
392  
393 =over
394  
395 =item populate_data
396  
397 Title : populate_data
398  
399 Usage : C<$obj-E<gt>populate_data($filep,$filen);>
400  
401 Function : Parses RNA-seq coverage for positive and negative strand
402 into C<@{$self-E<gt>data}>, a Hash of Arrays data structure.
403  
404 Args : C<$filep> and C<$filen> are instances of L<Bio::ViennaNGS::FeatureIO>.
405  
406 Returns : None.
407  
408 Notes: The memory footprint of this method is rather high. It builds a
409 Hash of Arrays data structure from L<Bio::ViennaNGS::FeatureIO>
410 input objects of roughly the size of the underlying genome
411 (chromosomes are hash keys, and there is an array containing
412 coverage information for every genomic position referenced by
413 hash values).
414  
415 =item raw_peaks
416  
417 Title : raw_peaks
418  
419 Usage : C<$obj-E<gt>raw_peaks($dest,$prefix,$log);>
420  
421 Function : This method identifies genomic regions ('raw peaks')
422 covered by RNA-seq signal by means of a sliding window
423 approach. RNA-seq coverage is read from
424 C<@{$self-E<gt>data}> (which is populated by e.g. the
425 C<populate_data> method). The sliding window approach
426 processes [+] and [-] strand for all chromosomes in 5'
427 -E<gt> 3' direction, whereby the mean value of each window
428 is used as a representative for this window. Thereby both
429 start and end coordinates, as well as position of the
430 maximum elevation are identified. Here the end position of
431 a covered region is defined as the coordinate of the window
432 whose mean is less than a certain value
433 (i.e. C<$self-E<gt>threshold> * peak maximum).
434  
435 Raw peaks are stored in C<%{$self-E<gt>data}-E<gt>{peaks}>.
436  
437 Args : C<$dest> contains the output path for results, C<$prefix> the
438 prefix used for all output file names. C<$log> is the name of a
439 log file, or undef if no logging is reuqired.
440  
441 Returns : None. The output is a position-sorted BED6 file containing
442 all raw peaks.
443  
444 Notes : It is highly recommended to use I<normalized> input data in
445 order to allow for multiple calls of this method with the same
446 set of parameters on different samples.
447  
448 =item final_peaks
449  
450 Title : final_peaks
451  
452 Usage : C<$obj-E<gt>final_peaks($dest,$prefix,$log);>
453  
454 Function : This method characterizes final peaks from RNA-seq coverage
455 found in C<%{$self-E<gt>data}-E<gt>{peaks}>. The latter is
456 supposed to have been populated by C<$self-E<gt>raw_peaks>.
457  
458 The procedure for finding final peaks is as follows: For each raw peak
459 found in C<%{$self-E<gt>data}-E<gt>{peaks}> the window of maximum
460 coverage is retrieved and a (second) sliding window approach is then
461 applied to regions both upstream and downstream of the maximum. Peak
462 boundaries are set at the position where the mean coverage of the
463 respective window is lower than C<$self-E<gt>threshold> * peak
464 maximum).
465  
466 Peaks are reported if their total length (as determined by this
467 routine) is not longer than C<$self-E<gt>length>.
468  
469 Args : C<$dest> contains the output path for results, C<$prefix> the
470 prefix used for all output file names. C<$log> is the name of a
471 log file, or undef if no logging is reuqired.
472  
473 Returns : None. The output is a position-sorted BED6 file containing
474 all candidate peaks.
475  
476 Notes :
477  
478 =back
479  
480 =head1 DEPENDENCIES
481  
482 =over
483  
484 =item L<Moose>
485  
486 =item L<Carp>
487  
488 =item L<Path::Class>
489  
490 =item L<List::Util>
491  
492 =item L<namespace::autoclean>
493  
494 =back
495  
496 =head1 SEE ALSO
497  
498 =over
499  
500 =item L<Bio::ViennaNGS>
501  
502 =item L<Bio::ViennaNGS::Util>
503  
504 =back
505  
506 =head1 AUTHOR
507  
508 Michael T. Wolfinger, E<lt>michael@wolfinger.euE<gt>
509  
510 =head1 COPYRIGHT AND LICENSE
511  
512 Copyright (C) 2015-2017 by Michael T. Wolfinger
513  
514 This library is free software; you can redistribute it and/or modify
515 it under the same terms as Perl itself, either Perl version 5.10.0 or,
516 at your option, any later version of Perl 5 you may have available.
517  
518 This software is distributed in the hope that it will be useful, but
519 WITHOUT ANY WARRANTY; without even the implied warranty of
520 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
521  
522 =cut
↑ Summary blib/lib/Bio/ViennaNGS/SpliceJunc.pm »