annotate SampleDEGseqMerge.pl @ 50:7b5a48b972e9 draft

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