annotate SampleDEGseqMerge.pl @ 18:22d79320085c draft

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