annotate SampleDEGseqMerge.pl @ 0:87fe81de0931 draft default tip

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