comparison SampleDEGseqMerge.pl @ 50:7b5a48b972e9 draft

Uploaded
author big-tiandm
date Fri, 05 Dec 2014 00:11:02 -0500
parents
children
comparison
equal deleted inserted replaced
49:f008ab2cadc6 50:7b5a48b972e9
1 #!/usr/bin/perl -w
2 #Filename:
3 #Author: Tian Dongmei
4 #Email: chentt@big.ac.cn
5 #Date: 2014-05-21
6 #Modified:
7 #Description: merged deg file and total information
8 my $version=1.00;
9
10 use strict;
11 use Getopt::Long;
12
13 my %opts;
14 GetOptions(\%opts,"i:s@","mark:s@","f:s","o=s","n=s","h");
15 if (!(defined $opts{o} ) || defined $opts{h}) { #necessary arguments
16 &usage;
17 }
18
19 my @filein=@{$opts{'i'}};
20 my @mark=@{$opts{'mark'}};
21 my $fileout=$opts{'o'};
22 my $number=$opts{'n'};
23
24 my %hash;
25 open IN,"<$filein[0]"; #input file
26
27 while (my $aline=<IN>) {
28 chomp $aline;
29 next if($aline=~/^\"/);
30 my @temp=split/\t/,$aline;
31 $hash{$temp[0]}=$temp[4]."\t".$temp[6]."\t".$temp[7]."\t".$temp[-1];
32 }
33 close IN;
34
35 for (my $i=1;$i<=$#filein;$i++) {
36 open IN,"<$filein[$i]"; #input file
37
38 while (my $aline=<IN>) {
39 chomp $aline;
40 next if($aline=~/^\"/);
41 my @temp=split/\t/,$aline;
42 if (!(defined $hash{$temp[0]})) {
43 print "Not find $temp[0]in sample one!\n";
44 next;
45 }
46 $hash{$temp[0]} .="\t".$temp[4]."\t".$temp[6]."\t".$temp[7]."\t".$temp[-1];
47 }
48 close IN;
49 }
50
51 open OUT,">$fileout"; #output file
52 my $deg_title;
53 foreach (@mark) {
54 $deg_title.="log2(Fold_change)\tp_value\tq_value\t".$_."\t";
55 }
56 $deg_title=~s/\s+$//;
57 my %function;
58 my $title;
59 open F,"<$opts{f}";
60 while (my $aline=<F>) {
61 chomp $aline;
62 if($aline=~/^\#/){
63 my $title=$aline;
64 my @title=split/\t/,$aline;
65 $title[2+$number].="\t".$deg_title;
66 $title=join"\t",@title;
67 print OUT "$title\n";
68 next;
69 }
70 my @temp=split/\t/,$aline;
71 $temp[2+$number].="\t".$hash{$temp[0]};
72 my $temp=join"\t",@temp;
73 print OUT "$temp\n";
74
75 }
76 close F;
77 close OUT;
78
79 sub usage{
80 print <<"USAGE";
81 Version $version
82 Usage:
83 $0 -i -o -mark -f
84 options:
85 -i input file # -i output_score.txt -i output_score.txt -i output_score.txt
86 -mark sample name # -mark sam1_VS_sam2 -mark sam1_VS_sam3 -mark sam2_VS_sam3
87 -f cluster file
88 -n sample number
89 -o output file
90 -h help
91 USAGE
92 exit(1);
93 }
94