comparison html_siRNA.pl @ 0:87fe81de0931 draft default tip

Uploaded
author bigrna
date Sun, 04 Jan 2015 02:47:25 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:87fe81de0931
1 #!/usr/bin/perl -w
2 #Filename:
3 #Author: Tian Dongmei
4 #Email: tiandm@big.ac.cn
5 #Date: 2014-5-29
6 #Modified:
7 #Description:
8 my $version=1.00;
9
10 use strict;
11 use Getopt::Long;
12 use File::Basename;
13
14 my %opts;
15 GetOptions(\%opts,"i=s","format=s","o=s","h");
16 if (!(defined $opts{o} and defined $opts{format} and defined $opts{i} ) || defined $opts{h}) { #necessary arguments
17 &usage;
18 }
19 my ($config,$prepath,$rfampath,$genomepath,$clusterpath,$annotatepath,$plotpath,$degpath);
20 my ($predir,$rfamdir,$genomedir,$clusterdir,$annotatedir,$plotdir,$degdir);
21 open IN,"<$opts{i}";
22 $config=<IN>; chomp $config;
23 $prepath=<IN>; chomp $prepath;
24 $rfampath=<IN>;chomp $rfampath;
25 $genomepath=<IN>; chomp $genomepath;
26 $clusterpath=<IN>; chomp $clusterpath;
27 $annotatepath=<IN>; chomp $annotatepath;
28 $plotpath=<IN>; chomp $plotpath;
29 my $deg_tag=1;
30 if(eof){$deg_tag=0;}
31 else{
32 $degpath=<IN>; chomp $degpath;
33 }
34 close IN;
35 my @tmp=split/\//,$prepath;
36 $predir=$tmp[-1];
37 @tmp=split/\//,$rfampath;
38 $rfamdir=$tmp[-1];
39 @tmp=split/\//,$genomepath;
40 $genomedir=$tmp[-1];
41 @tmp=split/\//,$clusterpath;
42 $clusterdir=$tmp[-1];
43 @tmp=split/\//,$annotatepath;
44 $annotatedir=$tmp[-1];
45 @tmp=split/\//,$plotpath;
46 $plotdir=$tmp[-1];
47
48 my $dir=dirname($opts{'o'});
49
50 open OUT ,">$opts{'o'}";
51 print OUT "<HTML>\n <HEAD>\n <TITLE> Analysis Report </TITLE>\n </HEAD>
52 <BODY bgcolor=\"lightgray\">\n <h1 align=\"center\">\n <font face=\"ºÚÌå\">\n <b>Small RNA Analysis Report</b>\n </font>\n </h1>
53 <h2>1. Sequence No. and quality</h2>
54 <h3>1.1 Sequece No.</h3>
55 ";
56
57 ### raw data no
58 open IN,"<$config";
59 my @files;my @marks; my @rawNo;
60 while (my $aline=<IN>) {
61 chomp $aline;
62 my @tmp=split/\t/,$aline;
63 push @files,$tmp[0];
64
65 my $no=`less $tmp[0] |wc -l `;
66 chomp $no;
67 if ($opts{'format'} eq "fq" || $opts{'format'} eq "fastq") {
68 $no=$no/4;
69 }
70 else{
71 $no=$no/2;
72 }
73 push @rawNo,$no;
74
75 push @marks,$tmp[1];
76 }
77 close IN;
78
79 ### preprocess
80 unless ($prepath=~/\/$/) {
81 $prepath .="/";
82 }
83
84 my @trimNo;my @collapse;
85 my $collapsefile=$prepath."collapse_reads.fa";
86 open IN,"<$collapsefile";
87 while (my $aline=<IN>) {
88 chomp $aline;
89 <IN>;
90 $aline=~/:([\d|_]+)_x(\d+)$/;
91 my @lng=split/_/,$1;
92 for (my $i=0;$i<@lng;$i++) {
93 if ($lng[$i]>0) {
94 $trimNo[$i] +=$lng[$i];
95 $collapse[$i] ++;
96 }
97 }
98 }
99 close IN;
100
101 my @cleanR;my @cleanT;
102 my $clean=$prepath."collapse_reads_18-40.fa";
103 open IN,"<$clean";
104 while (my $aline=<IN>) {
105 chomp $aline;
106 <IN>;
107 $aline=~/:([\d|_]+)_x(\d+)$/;
108 my @lng=split/_/,$1;
109 for (my $i=0;$i<@lng;$i++) {
110 if ($lng[$i]>0) {
111 $cleanR[$i] +=$lng[$i];
112 $cleanT[$i] ++;
113 }
114 }
115 }
116 close IN;
117
118 my @filterR;my @filterT;
119 my $filter=$prepath."collapse_reads_out.fa";
120 open IN,"<$filter";
121 while (my $aline=<IN>) {
122 chomp $aline;
123 <IN>;
124 $aline=~/:([\d|_]+)_x(\d+)$/;
125 my @lng=split/_/,$1;
126 for (my $i=0;$i<@lng;$i++) {
127 if ($lng[$i]>0) {
128 $filterR[$i] +=$lng[$i];
129 $filterT[$i] ++;
130 }
131 }
132 }
133 close IN;
134
135
136 print OUT "<table border=\"1\">
137 <tr align=\"center\">
138 <th>&nbsp;</th>
139 ";
140 foreach (@marks) {
141 print OUT "<th> $_ </th>\n";
142 }
143 print OUT "</tr>
144 <tr align=\"center\">
145 <th align=\"left\">Raw Reads No. </th>
146 ";
147 foreach (@rawNo) {
148 print OUT "<td> $_ </td>\n";
149 }
150 print OUT "</tr>
151 <tr align=\"center\">
152 <th align=\"left\">Reads No. After Trimed 3\' adapter </th>
153 ";
154 foreach (@trimNo) {
155 print OUT "<td> $_ </td>\n";
156 }
157 print OUT "</tr>
158 <tr align=\"center\">
159 <th align=\"left\">Unique Tags No. </th>
160 ";
161 foreach (@collapse) {
162 print OUT "<td> $_ </td>\n";
163 }
164 print OUT "</tr>
165 <tr align=\"center\">
166 <th align=\"left\">Clean Reads No. </th>
167 ";
168 foreach (@cleanR) {
169 print OUT "<td> $_ </td>\n";
170 }
171 print OUT "</tr>
172 <tr align=\"center\">
173 <th align=\"left\">Clean Tags No. </th>
174 ";
175 foreach (@cleanT) {
176 print OUT "<td> $_ </td>\n";
177 }
178 print OUT "</tr>
179 <tr align=\"center\">
180 <th align=\"left\">Filter Reads No. \(reads count \>3\) </th>
181 ";
182 foreach (@filterR) {
183 print OUT "<td> $_ </td>\n";
184 }
185 print OUT "</tr>
186 <tr align=\"center\">
187 <th align=\"left\">Filter Tags No. \(reads count \>3\) </th>
188 ";
189 foreach (@filterT) {
190 print OUT "<td> $_ </td>\n";
191 }
192 print OUT "</tr>\n</table>";
193 print OUT "<p>
194 Note:<br />
195 The raw data file path is: <b>$files[0]</b><br />
196 ";
197 for (my $i=1;$i<@files;$i++) {
198 print OUT "&nbsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<b>$files[$i]</b><br />";
199 }
200 print OUT "The collapsed file path is: <b>$collapsefile</b><br />
201 The clean data file path is: <b>$clean</b><br />
202 The filter (remain total reads>3) data file path is: <b>$filter</b><br />
203 </p>
204 <h2> 1. Sequence length count</h2>
205 ";
206 print OUT "\n";
207
208 my $length=$prepath."length.html";
209 open IN,"<$length";
210 while (my $aline=<IN>) {
211 chomp $aline;
212 print OUT "$aline\n";
213 }
214 close IN;
215
216 print OUT "<p> Note:<br />The sequence length data: <a href=\"./$predir/reads_length_distribution_after_count_filter.txt\"> length file</a>
217 </p>
218 ";
219
220 #### rfam
221 unless ($rfampath=~/\/$/) {
222 $rfampath .="/";
223 }
224 unless ($genomepath=~/\/$/) {
225 $genomepath .="/";
226 }
227 print OUT "<h2>2. Rfam non-miRNA annotation</h2>
228 <h3>2.1 Reads count</h3>
229 <table border=\"1\">
230 <tr align=\"center\">
231 ";
232
233 my @rfamR; my @rfamT;
234 my $tag=1;
235 open IN,"<$dir/rfam_match/rfam_non-miRNA_annotation.txt";
236 while (my $aline=<IN>) {
237 chomp $aline;
238 $tag=0 if($aline=~/tags\s+number/);
239 next if($aline=~/^\#/);
240 next if($aline=~/^\s*$/);
241 my @tmp=split/\s+/,$aline;
242 if($tag == 1){push @rfamR,[@tmp];}
243 else{push @rfamT,[@tmp];}
244 }
245 close IN;
246
247
248 print OUT "<th>RNA Name</th>\n";
249 foreach (@marks) {
250 print OUT "<th> $_ </th>\n";
251 }
252 for (my $i=0;$i<@rfamR;$i++) {
253 print OUT "</tr>
254 <tr align=\"center\">
255 <th align=\"left\">$rfamR[$i][0]</th>
256 ";
257 for (my $j=1;$j<@{$rfamR[$i]} ;$j++) {
258 print OUT "<td> $rfamR[$i][$j]</td>\n";
259 }
260 }
261
262 print OUT "</tr>\n</table>
263 <h3>2.2 Tags count</h3>
264 <table border=\"1\">
265 <tr align=\"center\">
266 <th>RNA Name</th>\n";
267 foreach (@marks) {
268 print OUT "<th> $_ </th>\n";
269 }
270 for (my $i=0;$i<@rfamT;$i++) {
271 print OUT "</tr>
272 <tr align=\"center\">
273 <th align=\"left\">$rfamT[$i][0]</th>
274 ";
275 for (my $j=1;$j<@{$rfamT[$i]} ;$j++) {
276 print OUT "<td> $rfamT[$i][$j]</td>\n";
277 }
278 }
279 print OUT "</tr>\n</table>
280 <p>Note:<br />The rfam mapping results is: <b>$rfampath</b>";
281 print OUT "<b>rfam_mapped.bwt</b></p>";
282
283 open IN,"<$dir/genome_match/genome_mapped.bwt";
284 my @genome_r_u;
285 my @genome_r_m;
286 my @genome_t_u;
287 my @genome_t_m;
288 my $tags_map_number=0;
289 while (my $aline=<IN>) {
290 chomp $aline;
291 my @temp=split/\t/,$aline;
292 if ($temp[6]==0) {
293 $aline=~/:([\d|_]+)_x(\d+)/;
294 my @lng=split/_/,$1;
295 for (my $i=0;$i<@lng;$i++) {
296 if ($lng[$i]>0) {
297 $genome_r_u[$i] +=$lng[$i];
298 $genome_t_u[$i] ++;
299 }
300 }
301 $tags_map_number++;
302 }
303 if ($temp[6]>0) {
304 $aline=~/:([\d|_]+)_x(\d+)/;
305 my @lng=split/_/,$1;
306 for (my $i=0;$i<@lng;$i++) {
307 if ($lng[$i]>0) {
308 $genome_r_m[$i] +=$lng[$i];
309 $genome_t_m[$i] ++;
310 }
311 }
312 for (my $i=0;$i<$temp[6] ;$i++) {
313 my $next=<IN>;
314 }
315 $tags_map_number++;
316 }
317 }
318 close IN;
319 #<h3>3.1 Reads count</h3>
320 #<table border=\"1\">
321 #<tr align=\"center\">
322 print OUT "<h2>3. genome mapping result</h2>
323 <table border=\"1\">
324 <tr align=\"center\">
325 <th align=\"left\">Map</th>\n
326 ";
327 foreach (@marks) {
328 print OUT "<th> $_ </th>\n";
329 }
330 print OUT "</tr>
331 <tr align=\"center\">
332 <th align=\"left\">Uniq Map Reads No.</th>
333 ";
334 for (my $i=0;$i<@genome_r_u ;$i++) {
335 print OUT "<td> $genome_r_u[$i]</td>\n";
336 }
337
338 print OUT "</tr>
339 <tr align=\"center\">
340 <th align=\"left\">Uniq Map Tags No.</th>
341 ";
342 for (my $i=0;$i<@genome_t_u ;$i++) {
343 print OUT "<td> $genome_t_u[$i]</td>\n";
344 }
345
346 print OUT "</tr>
347 <tr align=\"center\">
348 <th align=\"left\">Multiple Map Reads No.</th>
349 ";
350 for (my $i=0;$i<@genome_r_m ;$i++) {
351 print OUT "<td> $genome_r_m[$i]</td>\n";
352 }
353
354 print OUT "</tr>
355 <tr align=\"center\">
356 <th align=\"left\">Multiple Map Tags No.</th>
357 ";
358 for (my $i=0;$i<@genome_t_m ;$i++) {
359 print OUT "<td> $genome_t_m[$i]</td>\n";
360 }
361
362 print OUT "</tr>\n</table>
363 <p>Note:<br />The genome mapping results is: <b>$genomepath</b>";
364 print OUT "<b>genome_mapped.bwt</b></p>";
365
366 my $cluster="$clusterpath/sample_reads.cluster";
367 my $cluster_number=`less $cluster |wc -l `;
368 $cluster_number=$cluster_number-1;
369 my (%cluster_length,@exp,@rpkm);
370 my @exp_range=qw(0 \(0--10] \(10--100] \(100--1000] \(1000--10000] \(10000--100000] \(100000--**\));
371 my @rpkm_range=qw(0 \(0--0.25] \(0.25--0.5] \(0.5--1] \(1.0-5.0] \(5--10] \(10--50] \(50--100] \(100--500] \(500--1000] \(1000--**]);
372
373 open IN,"<$cluster";
374 while (my $aline=<IN>) {
375 next if($aline=~/^\"/);
376 chomp $aline;
377 my @temp=split/\t/,$aline;
378 my @id=split/:|-/,$temp[0];
379 $cluster_length{$id[2]-$id[1]+1}++;
380 for (my $i=0;$i<@marks ;$i++) {
381 if ($temp[$i+3] == 0) {$exp[0][$i]++;}
382 elsif ($temp[$i+3]>0 && $temp[$i+3]<= 10 ){$exp[1][$i]++;}
383 elsif ($temp[$i+3]>10 && $temp[$i+3]<=100){$exp[2][$i]++;}
384 elsif ($temp[$i+3]>100 && $temp[$i+3]<=1000){$exp[3][$i]++;}
385 elsif ($temp[$i+3]>1000 && $temp[$i+3]<=10000){$exp[4][$i]++;}
386 elsif ($temp[$i+3]>10000 && $temp[$i+3]<=100000){$exp[5][$i]++;}
387 elsif ($temp[$i+3]>100000){$exp[6][$i]++;}
388 }
389 }
390 close IN;
391
392 my $cluster_rpkm="$clusterpath/sample_rpkm.cluster";
393 open IN,"<$cluster_rpkm";
394 while (my $aline=<IN>) {
395 next if($aline=~/^\#/);
396 chomp $aline;
397 my @temp=split/\t/,$aline;
398 for (my $i=0;$i<@marks ;$i++) {
399 if ($temp[$i+3]==0) {$rpkm[0][$i]++;}
400 elsif($temp[$i+3]>0 && $temp[$i+3]<=0.25){$rpkm[1][$i]++;}
401 elsif($temp[$i+3]>0.25 && $temp[$i+3]<=0.5){$rpkm[2][$i]++;}
402 elsif($temp[$i+3]>0.5 && $temp[$i+3]<=1){$rpkm[3][$i]++;}
403 elsif($temp[$i+3]>1 && $temp[$i+3]<=5){$rpkm[4][$i]++;}
404 elsif($temp[$i+3]>5 && $temp[$i+3]<=10){$rpkm[5][$i]++;}
405 elsif($temp[$i+3]>10 && $temp[$i+3]<=50){$rpkm[6][$i]++;}
406 elsif($temp[$i+3]>50 && $temp[$i+3]<=100){$rpkm[7][$i]++;}
407 elsif($temp[$i+3]>100 && $temp[$i+3]<=500){$rpkm[8][$i]++;}
408 elsif($temp[$i+3]>500 && $temp[$i+3]<=1000){$rpkm[9][$i]++;}
409 else{$rpkm[10][$i]++;}
410 }
411 }
412
413 close IN;
414
415 my $cluster_length_file="$clusterpath/cluster_length.txt";
416 open LEN,">$cluster_length_file";
417 print LEN "\#length\tcluster_number\n";
418 foreach my $key (sort keys %cluster_length) {
419 print LEN "$key\t$cluster_length{$key}\n";
420 }
421 close LEN;
422 print OUT "<h2>4. cluster result</h2>
423 <h3>4.1 Cluster count</h3>
424 <table border=\"1\">
425 <tr align=\"center\">
426 <th align=\"left\"> </th>
427 <td>Merged samples</td></tr>
428 <tr align=\"center\">
429 <th align=\"left\">Tags number</th>
430 <td>$tags_map_number</td></tr>
431 <tr align=\"center\">
432 <th align=\"left\">Cluster number</th>
433 <td>$cluster_number</td></tr>\n</table>
434 ";
435
436 print OUT "<h3>4.2 Cluster length</h3>
437 <p> Note:<br />The clusters length data: <a href=\"./$clusterdir/cluster_length.txt\"> length file</a>
438 </p>
439 ";
440 print OUT "<h3>4.3 Quantify</h3>
441 <table border=\"1\">
442 <tr align=\"center\">
443 <th align=\"left\">Reads Range</th>\n
444 ";
445 foreach (@marks) {
446 print OUT "<th> $_ </th>\n";
447 }
448 for (my $i=0;$i<@exp_range;$i++) {
449 print OUT "</tr>
450 <tr align=\"center\">
451 <th align=\"left\">$exp_range[$i]</th>
452 ";
453 for (my $j=0;$j<@marks ;$j++) {
454 if (!(defined($exp[$i][$j]))) {
455 print OUT "<td> 0</td>\n";
456 }
457 else{print OUT "<td> $exp[$i][$j]</td>\n";}
458 }
459 }
460 print OUT "</tr>\n</table>";
461
462 print OUT "\n<table border=\"1\">
463 <tr align=\"center\">
464 <th align=\"left\">RPKM Range</th>\n
465 ";
466 foreach (@marks) {
467 print OUT "<th> $_ </th>\n";
468 }
469 for (my $i=0;$i<@rpkm_range;$i++) {
470 print OUT "</tr>
471 <tr align=\"center\">
472 <th align=\"left\">$rpkm_range[$i]</th>
473 ";
474 for (my $j=0;$j<@marks ;$j++) {
475 if (!(defined($rpkm[$i][$j]))) {
476 print OUT "<td> 0</td>\n";
477 }
478 else{print OUT "<td> $rpkm[$i][$j]</td>\n";}
479 }
480 }
481 print OUT "</tr>\n</table>";
482
483 my $annotate="$annotatepath/sample_c_p.anno";
484 my (%posit,%repeat,%nat1,%nat2);
485 my (@phase,@long,@repeat,@nat);
486 for (my $j=0;$j<@marks ;$j++) {
487 $phase[$j]=0;
488 $long[$j]=0;
489 $repeat[$j]=0;
490 $nat[$j]=0;
491 }
492
493 my $class_anno=1;
494 open ANNO,"<$annotate";
495 while (my $aline=<ANNO>) {
496 chomp $aline;
497 my @temp=split/\t/,$aline;
498 if($aline=~/^\#/){
499 if (@temp != 10+@marks) {
500 $class_anno=0;
501 }
502 next;
503 }
504 for (my $i=3+@marks+$class_anno;$i<@temp;$i++) {
505 my @posit=split/\;/,$temp[$i];
506 for (my $j=0;$j<@marks ;$j++) {
507 if ($temp[3+$j]>0) {
508 $posit{$posit[0]}[$j]++;
509 }
510 else{
511 if (!(defined($posit{$posit[0]}[$j]))) {
512 $posit{$posit[0]}[$j]=0;
513 }
514 }
515 }
516 }
517 if ($class_anno) {
518 for (my $j=0;$j<@marks ;$j++) {
519 if ($temp[3+$j]>0) {
520 if ($temp[6] eq "phase") {
521 $phase[$j]++;
522 }
523 if ($temp[7] eq "long") {
524 $long[$j]++;
525 }
526 if ($temp[8] ne "\/") {
527 $repeat[$j]++;
528 my @rr=split/\;/,$temp[8];
529 foreach (@rr) {
530 $repeat{$_}[$j]++;
531 }
532 }
533 if ($temp[9] ne "\/") {
534 $nat[$j]++;
535 my @nn1=split/\;/,$temp[9];
536 my @nn2=split/\;/,$temp[10];
537 for (my $k=0;$k<@nn1 ;$k++) {
538 $nat1{$nn1[$k]}[$j]++;
539 $nat2{$nn2[$k]}[$j]++;
540 }
541 }
542 }
543 }
544 }
545 }
546 close ANNO;
547
548 print OUT "<h2>5. Cluster Annotate</h2>
549 <h3>5.1 Cluster genome position annotate</h3>
550 <table border=\"1\">
551 <tr align=\"center\">
552 <th align=\"left\">clusters number</th>\n
553 ";
554
555 foreach (@marks) {
556 print OUT "<th> $_ </th>\n";
557 }
558 foreach my $key (sort keys %posit) {
559 print OUT "</tr>
560 <tr align=\"center\">
561 <th align=\"left\">$key</th>
562 ";
563 foreach (@{$posit{$key}}) {
564 print OUT "<td> $_</td>\n";
565 }
566 }
567 print OUT "</tr>\n</table>";
568 print OUT "<p>
569 Note:<br />
570 One cluster mybe annotate to multiple genes<br />
571 ";
572
573 if ($class_anno) {
574 print OUT "<h3>5.2 Cluster source mechanism annotate</h3>
575 <table border=\"1\">
576 <tr align=\"center\">
577 <th align=\"left\">clusters number</th>\n
578 ";
579
580 foreach (@marks) {
581 print OUT "<th> $_ </th>\n";
582 }
583 print OUT "</tr>
584 <tr align=\"center\">
585 <th align=\"left\">Phase</th>\n
586 ";
587 foreach (@phase) {
588 print OUT "<td> $_ </td>\n";
589 }
590
591 print OUT "</tr>
592 <tr align=\"center\">
593 <th align=\"left\">Long</th>\n
594 ";
595 foreach (@long) {
596 print OUT "<td> $_ </td>\n";
597 }
598
599 print OUT "</tr>
600 <tr align=\"center\">
601 <th align=\"left\">Repeat</th>\n
602 ";
603 foreach (@repeat) {
604 print OUT "<td> $_ </td>\n";
605 }
606
607 print OUT "</tr>
608 <tr align=\"center\">
609 <th align=\"left\">Nat</th>\n
610 ";
611 foreach (@nat) {
612 print OUT "<td> $_ </td>\n";
613 }
614 print OUT "</tr>\n</table>";
615
616 print OUT "<p>
617 Repeat subclass annotate:
618 ";
619
620 print OUT "<table border=\"1\">
621 <tr align=\"center\">
622 <th align=\"left\">Repeat subclass</th>\n
623 ";
624 foreach (@marks) {
625 print OUT "<th> $_ </th>\n";
626 }
627
628 foreach my $key (sort keys %repeat) {
629 print OUT "</tr>
630 <tr align=\"center\">
631 <th align=\"left\">$key</th>
632 ";
633 for (my $i=0;$i<@marks ;$i++) {
634 if (defined($repeat{$key}[$i])) {
635 print OUT "<td> $repeat{$key}[$i] </td>\n";
636 }
637 else{print OUT "<td> 0 </td>\n";}
638 }
639 }
640 print OUT "</tr>\n</table>";
641
642
643 print OUT "<p>
644 Nat subclass1 annotate:
645 ";
646
647 print OUT "<table border=\"1\">
648 <tr align=\"center\">
649 <th align=\"left\">Nat subclass1</th>\n
650 ";
651 foreach (@marks) {
652 print OUT "<th> $_ </th>\n";
653 }
654 foreach my $key (sort keys %nat1) {
655 print OUT "</tr>
656 <tr align=\"center\">
657 <th align=\"left\">$key</th>
658 ";
659 for (my $i=0;$i<@marks ;$i++) {
660 if (defined($nat1{$key}[$i])) {
661 print OUT "<td> $nat1{$key}[$i] </td>\n";
662 }
663 else{print OUT "<td> 0 </td>\n";}
664 }
665 }
666 print OUT "</tr>\n</table>";
667
668 print OUT "<p>
669 Nat subclass2 annotate:
670 ";
671
672 print OUT "<table border=\"1\">
673 <tr align=\"center\">
674 <th align=\"left\">Nat subclass2</th>\n
675 ";
676 foreach (@marks) {
677 print OUT "<th> $_ </th>\n";
678 }
679 foreach my $key (sort keys %nat2) {
680 print OUT "</tr>
681 <tr align=\"center\">
682 <th align=\"left\">$key</th>
683 ";
684 for (my $i=0;$i<@marks ;$i++) {
685 if (defined($nat2{$key}[$i])) {
686 print OUT "<td> $nat2{$key}[$i] </td>\n";
687 }
688 else{print OUT "<td> 0 </td>\n";}
689 }
690 }
691 print OUT "</tr>\n</table>";
692 print OUT "<p>
693 Note:<br />
694 One cluster mybe annotate to multiple repeats or nats<br />
695 ";
696 }
697 else {
698 print OUT "<h3>5.2 Cluster source mechanism annotate</h3>
699 <br />Do not do source mechanism annotate <br />";
700
701 }
702
703 print OUT "<h2>6. Graph of Clusters of all samples</h2> \n";
704
705 my $plot=$plotpath."cluster.html";
706 open IN,"<$plot";
707 while (my $aline=<IN>) {
708 chomp $aline;
709 print OUT "$aline\n";
710 }
711 close IN;
712
713
714 if ($deg_tag) {
715 my $deg_file=`ls $degpath`;
716 chomp $deg_file;
717 my @deg_file=split/\n/,$deg_file;
718 my %deg;
719 foreach (@deg_file) {
720 my $output="$degpath/$_/output_score.txt";
721 open IN,"<$output";
722 $deg{$_}[0]=0;
723 $deg{$_}[1]=0;
724 $deg{$_}[2]=0;
725 while (my $aline=<IN>) {
726 next if ($aline=~/^\"/);
727 chomp $aline;
728 my @temp=split/\t/,$aline;
729 if ($temp[9] eq "TRUE") {
730 $deg{$_}[0]++;
731 if ($temp[4] >0) {
732 $deg{$_}[1]++;
733 }
734 if ($temp[4] <0) {
735 $deg{$_}[2]++;
736 }
737 }
738 }
739 close IN;
740 }
741
742 print OUT "<h2>7. DEG</h2>
743 <table border=\"1\">
744 <tr align=\"center\">
745 <th align=\"left\">Genes number</th>\n
746 <th> DEG </th>\n
747 <th> UP </th>\n
748 <th> DOWN </th>\n
749 ";
750
751 foreach my $key (sort keys %deg) {
752 print OUT "</tr>
753 <tr align=\"center\">
754 <th align=\"left\">$key</th>
755 ";
756 for (my $i=0;$i<@{$deg{$key}} ;$i++) {
757 print OUT "<td> $deg{$key}[$i] </td>\n";
758 }
759 }
760 print OUT "</tr>\n</table>";
761 }
762 else{
763 print OUT "<h2>7. DEG</h2>
764 <br />Do not do DE clusters <br />";
765 }
766
767 print OUT "
768 </BODY>
769 </HTML>
770 ";
771 close OUT;
772
773
774
775
776 sub usage{
777 print <<"USAGE";
778 Version $version
779 Usage:
780 $0 -o
781 options:
782 -i
783 -format
784 -o output file
785 -h help
786 USAGE
787 exit(1);
788 }