Mercurial > repos > matces > carpet_toolsuite
comparison carpet-src-1/tools/CARPET/calcolo_p_v4_norm_intron.pl @ 0:cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author | matces |
---|---|
date | Tue, 07 Jun 2011 16:50:41 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cdd489d98766 |
---|---|
1 #! /usr/bin/perl | |
2 | |
3 # Copyright 2009 Matteo Cesaroni, Lucilla Luzi | |
4 # | |
5 # This program is free software; ; you can redistribute it and/or modify | |
6 # it under the terms of the GNU Lesser General Public License as published by | |
7 # the Free Software Foundation; either version 3 of the License, or (at your | |
8 # option) any later version. | |
9 # | |
10 # This program is distributed in the hope that it will be useful, | |
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 # GNU General Public License for more details. | |
14 | |
15 | |
16 | |
17 #prende tutte le probes che mecciano almeno in parte dentro gli esoni | |
18 | |
19 use Statistics::PointEstimation; | |
20 use Statistics::TTest; | |
21 #use Statistics::Test::WilcoxonRankSum; | |
22 use Getopt::Long; | |
23 | |
24 GetOptions ( | |
25 "help" => \$OPT{help}, | |
26 "ann=s" => \$OPT{ann}, | |
27 "wt=s" => \$OPT{wt}, | |
28 "treat=s" => \$OPT{treat}, | |
29 "out=s" => \$OPT{out}, | |
30 "pv=s" => \$OPT{prob}, | |
31 "rc=s" => \$OPT{raw_cut}, | |
32 "fc=s" => \$OPT{fc_cut}, | |
33 "exon=s" => \$OPT{exon}, | |
34 "opt=s" => \$OPT{option}, | |
35 "norm=s" =>\$OPT{norm_q}, | |
36 "sum_met=s" =>\$OPT{sum_met}, | |
37 "fdr=s" =>\$OPT{fdr}, | |
38 "log=s" =>\$OPT{log_t}, | |
39 )|| printusage(); | |
40 | |
41 # opzioni da linea di comando | |
42 my $file_ann=$OPT{ann}; | |
43 my $file_wt=$OPT{wt}; | |
44 my $file_treat=$OPT{treat}; | |
45 my $file_output=$OPT{out}; | |
46 my $pv_cut=$OPT{prob}; | |
47 my $media_cut=$OPT{raw_cut}; | |
48 my $FC_cut=$OPT{fc_cut}; | |
49 my $tipo=$OPT{exon}; | |
50 my $option=$OPT{option}; | |
51 my $normalization_q=$OPT{norm_q}; | |
52 my $sum_meth=$OPT{sum_met}; | |
53 my $corretction=$OPT{fdr}; | |
54 my $data_log=$OPT{log_t}; | |
55 | |
56 $help and printusage(); | |
57 | |
58 | |
59 if($option eq "comp"){ | |
60 if ($sum_meth eq "both"){ | |
61 $header=<<e0c6654; | |
62 \# annotation_file: $file_ann | |
63 \# wt_file: $file_wt | |
64 \# treat_file: $file_treat | |
65 \# p-value cutoff: $pv_cut | |
66 \# raw data cutoff cutoff: $media_cut | |
67 \# summary method: $sum_meth | |
68 \# fold change cutoff: $FC_cut | |
69 \# type of analysis: $tipo | |
70 \# headers: name RefSeq Chr txStart txEnd strand mean_chip1 mean_chip2 FC_mean median_chip1 median_chip2 FC_median num_probes_in_gene p-value FDR(q-value) | |
71 e0c6654 | |
72 | |
73 } | |
74 if ($sum_meth eq "mean"){ | |
75 $header=<<e0c6654; | |
76 \# annotation_file: $file_ann | |
77 \# wt_file: $file_wt | |
78 \# treat_file: $file_treat | |
79 \# p-value cutoff: $pv_cut | |
80 \# raw data cutoff cutoff: $media_cut | |
81 \# summary method: $sum_meth | |
82 \# fold change cutoff: $FC_cut | |
83 \# type of analysis: $tipo | |
84 \# headers: name RefSeq Chr txStart txEnd strand mean_chip1 mean_chip2 FC_mean num_probes_in_gene p-value FDR(q-value) | |
85 e0c6654 | |
86 | |
87 } | |
88 if ($sum_meth eq "median"){ | |
89 $header=<<e0c6654; | |
90 \# annotation_file: $file_ann | |
91 \# wt_file: $file_wt | |
92 \# treat_file: $file_treat | |
93 \# p-value cutoff: $pv_cut | |
94 \# raw data cutoff cutoff: $media_cut | |
95 \# summary method: $sum_meth | |
96 \# fold change cutoff: $FC_cut | |
97 \# type of analysis: $tipo | |
98 \# headers: name RefSeq Chr txStart txEnd strand median_chip1 median_chip2 FC_median num_probes_in_gene p-value FDR(q-value) | |
99 e0c6654 | |
100 | |
101 } | |
102 | |
103 | |
104 | |
105 # "usage" se non ci sono opzioni | |
106 if (!$file_ann || !$file_wt || !$file_treat) { | |
107 &printusage() | |
108 } | |
109 | |
110 #if ($pv_cut == 1){$pv_cut=0.9999;} | |
111 if (!$media_cut){$media_cut=0;} | |
112 if (!$FC_cut){$FC_cut=0;} | |
113 | |
114 my @r1=(); | |
115 my @r2=(); | |
116 | |
117 #my $confident=(1-$pv_cut)*100; | |
118 #inserire nell'ordine: tabella annotazione, tabella valori wt, tabella valori treated, p-value cutoff, raw signal cutoff | |
119 | |
120 | |
121 open (annotation,"<$file_ann") || die "file_ann not open:$!\n"; | |
122 open (wt,"<$file_wt") || die "$file_wt not open:$!\n"; | |
123 open (treated,"<$file_treat") || die "$file_treat not open:$!\n"; | |
124 open (output,">$file_output") || die "bed_$file_wt not open:$!\n"; | |
125 | |
126 print output "$header"; | |
127 | |
128 print "Comparison --> probe_selection=$tipo, Normalization=$normalization_q, summary method=$sum_meth Filters: p-value=$pv_cut, raw value=$media_cut, FC=$FC_cut"; | |
129 | |
130 while (defined (my $line_down = <annotation>)) { | |
131 chomp $line_down; | |
132 my @tmp_down = split("\t", $line_down); | |
133 my @probe_match=split("\,", $tmp_down[9]); | |
134 foreach $probes (@probe_match){ | |
135 my @coord=split("-", $probes); | |
136 $tab_tot{$tmp_down[0]}{"$coord[0]\t$coord[1]"}.="$tmp_down[1]\n$tmp_down[7]\n$tmp_down[0]\n$tmp_down[2]\n$tmp_down[3]\n$tmp_down[4]\n$tmp_down[5]\n$tmp_down[6]\n"; | |
137 push(@ciclo,"$tmp_down[0]\t$coord[0]\t$coord[1]"); | |
138 } | |
139 } | |
140 | |
141 while (defined (my $line_down = <wt>)) { | |
142 chomp $line_down; | |
143 my @tmp_down = split("\t", $line_down); | |
144 chomp $tmp_down[0]; | |
145 $tab_tot_wt{"$tmp_down[0]\t$tmp_down[3]"}=$tmp_down[5]; | |
146 } | |
147 | |
148 | |
149 while (defined (my $line_down = <treated>)) { | |
150 chomp $line_down; | |
151 my @tmp_down = split("\t", $line_down); | |
152 chomp $tmp_down[0]; | |
153 $tab_tot_treat{"$tmp_down[0]\t$tmp_down[3]"}=$tmp_down[5]; | |
154 } | |
155 | |
156 if($normalization_q eq "yes"){ | |
157 | |
158 @sort_wt=sort{$tab_tot_wt{$a} <=> $tab_tot_wt{$b}} keys %tab_tot_wt; | |
159 @sort_treat=sort{$tab_tot_treat{$a} <=> $tab_tot_treat{$b}} (keys %tab_tot_treat); | |
160 | |
161 for($i=0;$i<=$#sort_wt;$i++){ | |
162 $media=($tab_tot_wt{$sort_wt[$i]}+$tab_tot_treat{$sort_treat[$i]})/2; | |
163 $tab_tot_value{$sort_wt[$i]}.="$media\n"; | |
164 } | |
165 | |
166 for($i=0;$i<=$#sort_treat;$i++){ | |
167 $media=($tab_tot_wt{$sort_wt[$i]}+$tab_tot_treat{$sort_treat[$i]})/2; | |
168 $tab_tot_value{$sort_treat[$i]}.="$media\n"; | |
169 } | |
170 | |
171 } | |
172 | |
173 | |
174 foreach $key_value(@ciclo){ | |
175 | |
176 @keys_values=split("\t",$key_value); | |
177 @array1= split("\n",$tab_tot{$keys_values[0]}{"$keys_values[1]\t$keys_values[2]"}); | |
178 if($normalization_q eq "yes"){ | |
179 @array2= split("\n",$tab_tot_value{"$keys_values[1]\t$keys_values[2]"}); | |
180 $value1=$array2[0]; | |
181 $value2=$array2[1]; | |
182 } | |
183 else{ | |
184 $value1=$tab_tot_wt{"$keys_values[1]\t$keys_values[2]"}; | |
185 $value2=$tab_tot_treat{"$keys_values[1]\t$keys_values[2]"}; | |
186 } | |
187 if ($tipo eq "internal_exon"){ | |
188 $prendo = "^exon"; | |
189 } | |
190 if ($tipo eq "all_exon"){ | |
191 $prendo = "exon"; | |
192 } | |
193 if ($tipo eq "last_exon"){ | |
194 $prendo = "exon last"; | |
195 } | |
196 | |
197 if ((!($array1[0] eq "")) && ($array1[1] =~ /$prendo/g)) { | |
198 if ($data_log eq "no_log"){ | |
199 $log1=log($value1)/log(2); | |
200 $log2=log($value2)/log(2); | |
201 } | |
202 if ($data_log eq "log"){ | |
203 $log1=$value1; | |
204 $log2=$value2; | |
205 } | |
206 $tab_gene_wt{"$array1[0]\t$array1[2]\t$array1[3]\t$array1[4]\t$array1[5]\t$array1[6]"}.="$log1\n"; | |
207 $tab_gene_tratted{"$array1[0]\t$array1[2]\t$array1[3]\t$array1[4]\t$array1[5]\t$array1[6]"}.="$log2\n"; | |
208 } | |
209 | |
210 } | |
211 | |
212 foreach $key (keys %tab_gene_wt) { | |
213 @r1=split("\n",$tab_gene_wt{$key}); | |
214 @r2=split("\n",$tab_gene_tratted{$key}); | |
215 | |
216 sort {$a <=> $b} (@r1); | |
217 sort {$a <=> $b} (@r2); | |
218 | |
219 if ($#r1>0){ | |
220 my $ttest = new Statistics::TTest; | |
221 $ttest->set_significance(95); | |
222 $ttest->load_data(\@r1,\@r2); | |
223 my $s1=$ttest->{s1}; | |
224 my $s2=$ttest->{s2}; | |
225 $media1=$s1->{mean}; | |
226 $media2=$s2->{mean}; | |
227 $total_probes=$#r1+1; | |
228 $potenza_a=$media2-$media1; | |
229 $FCa=((2)**$potenza_a); | |
230 if( (@r1 % 2) == 1 ) { | |
231 $median1 = $r1[((@r1+1) / 2)-1]; | |
232 $median2 = $r2[((@r2+1) / 2)-1]; | |
233 } else { | |
234 $median1 = ($r1[(@r1 / 2)-1] + $r1[@r1 / 2]) / 2; | |
235 $median2 = ($r2[(@r2 / 2)-1] + $r2[@r2 / 2]) / 2; | |
236 } | |
237 $potenza_m=$median2-$median1; | |
238 $FCm=((2)**$potenza_m); | |
239 | |
240 | |
241 if ($FCa<1){ | |
242 $FCa=(-(1/$FCa)); | |
243 } | |
244 | |
245 | |
246 if ($FCm<1){ | |
247 $FCm=(-(1/$FCm)); | |
248 } | |
249 if ($sum_meth eq "mean"){ | |
250 if ((($media1<$media_cut) && ($media2<$media_cut)) || ($FC_cut>=abs($FCa))){ | |
251 next; | |
252 } | |
253 $p_value{"$key\t$media1\t$media2\t$FCa\t$total_probes"}=$ttest->{t_prob}; | |
254 | |
255 #print output "$key\t$media1\t$media2\t$FCa\t",$ttest->{t_prob},"\t$total_probes\n"; | |
256 } | |
257 if ($sum_meth eq "median"){ | |
258 if ((($media1<$media_cut) && ($media2<$media_cut)) || ($FC_cut>=abs($FCm))){ | |
259 next; | |
260 } | |
261 #print output "$key\t$median1\t$median2\t$FCm\t",$ttest->{t_prob},"\t$total_probes\n"; | |
262 $p_value{"$key\t$median1\t$median2\t$FCm\t$total_probes"}=$ttest->{t_prob}; | |
263 } | |
264 if ($sum_meth eq "both"){ | |
265 if (($media1<$media_cut) && ($media2<$media_cut)){ | |
266 next; | |
267 } | |
268 #print output "$key\t$media1\t$media2\t$FCa\t$median1\t$median2\t$FCm\t",$ttest->{t_prob},"\t$total_probes\n"; | |
269 $p_value{"$key\t$media1\t$media2\t$FCa\t$median1\t$median2\t$FCm\t$total_probes"}=$ttest->{t_prob}; | |
270 } | |
271 } | |
272 if ($#r1==0){ | |
273 $media1=$r1[0]; | |
274 $media2=$r2[0]; | |
275 $median1=$r1[0]; | |
276 $median2=$r2[0]; | |
277 $potenza=$media2-$media1; | |
278 $FCa=((2)**$potenza); | |
279 $FCm=((2)**$potenza); | |
280 if ($FCa<1){ | |
281 $FCa=(-(1/$FCa)); | |
282 } | |
283 if ($FCm<1){ | |
284 $FCm=(-(1/$FCm)); | |
285 } | |
286 | |
287 if ($sum_meth eq "both"){ | |
288 if (($media1<$media_cut) && ($media2<$media_cut)){ | |
289 next; | |
290 } | |
291 $p_value{"$key\t$media1\t$media2\t$FCa\t$median1\t$median2\t$FCm\t$total_probes"}=1; | |
292 } | |
293 if ($sum_meth eq "mean"){ | |
294 if ((($media1<$media_cut) && ($media2<$media_cut)) || ($FC_cut>=abs($FCa))){ | |
295 next; | |
296 } | |
297 $p_value{"$key\t$media1\t$media2\t$FCa\t$total_probes"}=1; | |
298 } | |
299 if ($sum_meth eq "median"){ | |
300 if ((($media1<$media_cut) && ($media2<$media_cut)) || ($FC_cut>=abs($FCm))){ | |
301 next; | |
302 } | |
303 $p_value{"$key\t$median1\t$median2\t$FCm\t$total_probes"}=1; | |
304 } | |
305 } | |
306 } | |
307 | |
308 @sort_pvalue=sort{$p_value{$a} <=> $p_value{$b}} keys %p_value; | |
309 | |
310 if($corretction eq "yes"){ | |
311 for($i=0;$i<=$#sort_pvalue;$i++){ | |
312 $qvalue=$p_value{$sort_pvalue[$i]}*(($#sort_pvalue+1)/($i+1)); | |
313 push(@QVALUE, $qvalue); | |
314 } | |
315 | |
316 @qvalue_sort = sort {$a <=> $b} @QVALUE; | |
317 | |
318 for($i=0;$i<=$#sort_pvalue;$i++){ | |
319 #$FDR=((($i+1)*0.05)/($#sort_pvalue+1)); | |
320 $qvalue=shift(@qvalue_sort); | |
321 if($qvalue>1){$qvalue=1;} | |
322 if($pv_cut>=$qvalue){ | |
323 print output "$sort_pvalue[$i]\t$p_value{$sort_pvalue[$i]}\t$qvalue\n"; | |
324 } | |
325 } | |
326 } | |
327 if($corretction eq "no"){ | |
328 for($i=0;$i<=$#sort_pvalue;$i++){ | |
329 if($pv_cut>=$qvalue){ | |
330 print output "$sort_pvalue[$i]\t$p_value{$sort_pvalue[$i]}\n"; | |
331 } | |
332 } | |
333 } | |
334 | |
335 | |
336 | |
337 | |
338 | |
339 } | |
340 if($option eq "expr"){ | |
341 if ($sum_meth eq "median"){ | |
342 $header=<<e0c6654; | |
343 \# annotation_file: $file_ann | |
344 \# expression_file: $file_wt | |
345 \# type of analysis: $tipo | |
346 \# summary method: $sum_meth | |
347 \# headers: name RefSeq Chr txStart txEnd strand median_chip num_probes_in_gene | |
348 e0c6654 | |
349 | |
350 } | |
351 if ($sum_meth eq "mean"){ | |
352 $header=<<e0c6654; | |
353 \# annotation_file: $file_ann | |
354 \# expression_file: $file_wt | |
355 \# type of analysis: $tipo | |
356 \# summary method: $sum_meth | |
357 \# headers: name RefSeq Chr txStart txEnd strand mean_chip num_probes_in_gene | |
358 e0c6654 | |
359 | |
360 } | |
361 if ($sum_meth eq "both"){ | |
362 $header=<<e0c6654; | |
363 \# annotation_file: $file_ann | |
364 \# expression_file: $file_wt | |
365 \# type of analysis: $tipo | |
366 \# summary method: $sum_meth | |
367 \# headers: name RefSeq Chr txStart txEnd strand mean_chip median_chip num_probes_in_gene | |
368 e0c6654 | |
369 | |
370 } | |
371 if (!$file_ann || !$file_wt) { | |
372 &printusage() | |
373 } | |
374 my @r1=(); | |
375 my @r2=(); | |
376 | |
377 | |
378 open (annotation,"<$file_ann") || die "file_ann not open:$!\n"; | |
379 open (wt,"<$file_wt") || die "$file_wt not open:$!\n"; | |
380 open (output,">$file_output") || die "bed_$file_wt not open:$!\n"; | |
381 | |
382 print output "$header"; | |
383 | |
384 print "Expression --> probe_selection=$tipo summary method=$sum_meth"; | |
385 | |
386 while (defined (my $line_down = <annotation>)) { | |
387 chomp $line_down; | |
388 my @tmp_down = split("\t", $line_down); | |
389 my @probe_match=split("\,", $tmp_down[9]); | |
390 foreach $probes (@probe_match){ | |
391 my @coord=split("-", $probes); | |
392 $tab_tot{$tmp_down[0]}{"$coord[0]\t$coord[1]"}.="$tmp_down[1]\n$tmp_down[7]\n$tmp_down[0]\n$tmp_down[2]\n$tmp_down[3]\n$tmp_down[4]\n$tmp_down[5]\n$tmp_down[6]\n"; | |
393 push(@ciclo,"$tmp_down[0]\t$coord[0]\t$coord[1]"); | |
394 } | |
395 } | |
396 | |
397 while (defined (my $line_down = <wt>)) { | |
398 chomp $line_down; | |
399 $line_down=~ s/ //g; | |
400 my @tmp_down = split("\t", $line_down); | |
401 chomp $tmp_down[0]; | |
402 $tab_tot_wt{"$tmp_down[0]\t$tmp_down[3]"}=$tmp_down[5]; | |
403 } | |
404 #@sort_wt=sort{$tab_tot_wt{$a} <=> $tab_tot_wt{$b}} keys %tab_tot_wt; | |
405 | |
406 | |
407 #print "ciclo = $ciclo[0]\t$ciclo[1]\n"; | |
408 | |
409 foreach $key_value(@ciclo){ | |
410 | |
411 @keys_values=split("\t",$key_value); | |
412 @array1= split("\n",$tab_tot{$keys_values[0]}{"$keys_values[1]\t$keys_values[2]"}); | |
413 @array2= split("\n",$tab_tot_wt{"$keys_values[1]\t$keys_values[2]"}); | |
414 | |
415 if ($tipo eq "internal_exon"){ | |
416 $prendo = "^exon"; | |
417 } | |
418 if ($tipo eq "all_exon"){ | |
419 $prendo = "exon"; | |
420 } | |
421 if ($tipo eq "last_exon"){ | |
422 $prendo = "exon last"; | |
423 } | |
424 | |
425 if ((!($array1[0] eq "")) && ($array1[1] =~ /$prendo/g)) { | |
426 | |
427 if ($data_log eq "no_log"){ | |
428 $log1=log($array2[0])/log(2); | |
429 } | |
430 if ($data_log eq "log"){ | |
431 $log1=$array2[0]; | |
432 } | |
433 | |
434 $tab_gene_wt{"$array1[0]\t$array1[2]\t$array1[3]\t$array1[4]\t$array1[5]\t$array1[6]"}.="$log1\n"; | |
435 } | |
436 if ((!($array1[0] eq "")) && ($array1[1] =~ /intron/g)) { | |
437 if ($data_log eq "no_log"){ | |
438 $log1=log($array2[0])/log(2); | |
439 } | |
440 if ($data_log eq "log"){ | |
441 $log1=$array2[0]; | |
442 } | |
443 $tab_intron_wt{"$array1[0]\t$array1[2]\t$array1[3]\t$array1[4]\t$array1[5]\t$array1[6]"}.="$log1\n"; | |
444 } | |
445 | |
446 } | |
447 | |
448 | |
449 foreach $key (keys %tab_gene_wt) { | |
450 @r1=split("\n",$tab_gene_wt{$key}); | |
451 if (exists $tab_intron_wt{$key}){ | |
452 @r2=split("\n",$tab_intron_wt{$key}); | |
453 sort {$a <=> $b} (@r2); | |
454 }else{ | |
455 @r2=("no"); | |
456 } | |
457 sort {$a <=> $b} (@r1); | |
458 if ($#r2>0) { | |
459 if ($#r1>0) { | |
460 my $ttest = new Statistics::TTest; | |
461 $ttest->set_significance(95); | |
462 $ttest->load_data(\@r1,\@r2); | |
463 my $s1=$ttest->{s1}; | |
464 my $s2=$ttest->{s2}; | |
465 $media1=$s1->{mean}; | |
466 $media2=$s2->{mean}; | |
467 $total_probes=$#r1+1; | |
468 $total_probes2=$#r2+1; | |
469 if( (@r1 % 2) == 1 ) { | |
470 $median1 = $r1[((@r1+1) / 2)-1]; | |
471 } else { | |
472 $median1 = ($r1[(@r1 / 2)-1] + $r1[@r1 / 2]) / 2; | |
473 } | |
474 if( (@r2 % 2) == 1 ) { | |
475 $median2 = $r2[((@r2+1) / 2)-1]; | |
476 } else { | |
477 $median2 = ($r2[(@r2 / 2)-1] + $r2[@r2 / 2]) / 2; | |
478 } | |
479 if($media1>=$media2){ | |
480 $pvalue=$ttest->{t_prob}; | |
481 } | |
482 if($media1<$media2){ | |
483 $pvalue=1; | |
484 } | |
485 if ($sum_meth eq "mean"){ | |
486 print output "$key\t$media1\t$media2\t$pvalue\t$total_probes\t$total_probes2\n"; | |
487 #print output "$key\t$media1\t$total_probes\n"; | |
488 } | |
489 if ($sum_meth eq "median"){ | |
490 print output "$key\t$median1\t$median2\t$pvalue\t$total_probes\t$total_probes2\n"; | |
491 #print output "$key\t$median1\t$total_probes\n"; | |
492 } | |
493 if ($sum_meth eq "both"){ | |
494 print output "$key\t$media1\t$media2\t$median1\t$median2\t$pvalue\t$total_probes\t$total_probes2\n"; | |
495 #print output "$key\t$media1\t$median1\t$total_probes\n"; | |
496 } | |
497 } | |
498 if ($#r1==0) { | |
499 @r1=@r2; | |
500 my $ttest = new Statistics::TTest; | |
501 $ttest->set_significance(95); | |
502 $ttest->load_data(\@r1,\@r2); | |
503 my $s2=$ttest->{s2}; | |
504 $media2=$s2->{mean}; | |
505 $total_probes=1; | |
506 $total_probes2=$#r2+1; | |
507 $media1=$r1[0]; | |
508 $median1=$r1[0]; | |
509 if( (@r2 % 2) == 1 ) { | |
510 $median2 = $r2[((@r2+1) / 2)-1]; | |
511 } else { | |
512 $median2 = ($r2[(@r2 / 2)-1] + $r2[@r2 / 2]) / 2; | |
513 } | |
514 if ($sum_meth eq "mean"){ | |
515 print output "$key\t$media1\t$media2\tNA\t$total_probes\t$total_probes2\n"; | |
516 #print output "$key\t$media1\t$total_probes\n"; | |
517 } | |
518 if ($sum_meth eq "median"){ | |
519 print output "$key\t$median1\t$median2\tNA\t$total_probes\t$total_probes2\n"; | |
520 #print output "$key\t$median1\t$total_probes\n"; | |
521 } | |
522 if ($sum_meth eq "both"){ | |
523 print output "$key\t$media1\t$media2\t$median1\t$median2\tNA\t$total_probes\t$total_probes2\n"; | |
524 #print output "$key\t$media1\t$median1\t$total_probes\n"; | |
525 } | |
526 } | |
527 | |
528 | |
529 } | |
530 | |
531 if ($r2[0] eq "no") { | |
532 if ($#r1>0) { | |
533 @r2=@r1; | |
534 my $ttest = new Statistics::TTest; | |
535 $ttest->set_significance(95); | |
536 $ttest->load_data(\@r1,\@r2); | |
537 my $s1=$ttest->{s1}; | |
538 $media1=$s1->{mean}; | |
539 $total_probes=$#r1+1; | |
540 if( (@r1 % 2) == 1 ) { | |
541 $median1 = $r1[((@r1+1) / 2)-1]; | |
542 } else { | |
543 $median1 = ($r1[(@r1 / 2)-1] + $r1[@r1 / 2]) / 2; | |
544 } | |
545 } | |
546 if ($#r==0){ | |
547 $media1=$r1[0]; | |
548 $median1=$r1[0]; | |
549 $total_probes=$#r1+1; | |
550 } | |
551 $media2=0; | |
552 $median2=0; | |
553 if ($sum_meth eq "both"){ | |
554 print output "$key\t$media1\t$media2\t$median1\t$median2\tNA\t$total_probes\t0\n"; | |
555 #print output "$key\t$media1\t$median1\t$total_probes\n"; | |
556 } | |
557 if ($sum_meth eq "mean"){ | |
558 print output "$key\t$media1\t$media2\tNA\t$total_probes\t0\n"; | |
559 #print output "$key\t$media1\t$total_probes\n"; | |
560 } | |
561 if ($sum_meth eq "median"){ | |
562 print output "$key\t$median1\t$median2\tNA\t$total_probes\t0\n"; | |
563 #print output "$key\t$median1\t$total_probes\n"; | |
564 } | |
565 } | |
566 if (($#r2 == 0) && ($r2[0] ne "no") && ($#r1==0)){ | |
567 $media1=$r1[0]; | |
568 $media2=$r2[0]; | |
569 $median1=$r1[0]; | |
570 $median2=$r2[0]; | |
571 if ($sum_meth eq "both"){ | |
572 print output "$key\t$media1\t$media2\t$median1\t$median2\tNA\t1\t1\n"; | |
573 #print output "$key\t$media1\t$median1\t1\n"; | |
574 } | |
575 if ($sum_meth eq "mean"){ | |
576 print output "$key\t$media1\t$media2\tNA\t1\t1\n"; | |
577 #print output "$key\t$media1\t1\n"; | |
578 } | |
579 if ($sum_meth eq "median"){ | |
580 print output "$key\t$median1\t$median2\tNA\t1\t1\n"; | |
581 #print output "$key\t$median1\t1\n"; | |
582 } | |
583 } | |
584 } | |
585 | |
586 | |
587 | |
588 | |
589 } | |
590 | |
591 | |
592 | |
593 | |
594 | |
595 #################################################################################################################################### | |
596 | |
597 sub printusage { | |
598 | |
599 print<<eoc22334; | |
600 | |
601 | |
602 | |
603 *************************************************************** | |
604 :: N i m b l e G e n E x p r e s s i o n A n a l y s i s :: | |
605 *************************************************************** | |
606 | |
607 | |
608 USAGE SUMMARY | |
609 --------------------------------------------------------------------------------- | |
610 This program utilizes NimbleGen ratio files in gff format as INPUT FILE and | |
611 provides a table of the computed picks in the same gff file format. | |
612 | |
613 | |
614 --ann annotation file | |
615 --wt wild type file | |
616 --treat treated file | |
617 --pv p-value cut-off | |
618 --rc raw signal cut-off | |
619 --fc fold change cut-toff | |
620 | |
621 ----------------------------------------------------------------------------------------- | |
622 EXAMPLES: | |
623 | |
624 perl program.pl --in 75340_ratio.gff --perc 0.98 --t s --num 3 --dist 250 --w 500 | |
625 OR | |
626 perl program.pl --in 75340_ratio.gff --perc 0.98 --t p --log 5 --num 3 --dist 250 --w 500 | |
627 | |
628 ----------------------------------------------------------------------------------------- | |
629 | |
630 eoc22334 | |
631 exit 0; | |
632 | |
633 } | |
634 | |
635 | |
636 |