annotate DEGseq_2.pl @ 15:0e4b6b0c6e9d draft

Uploaded
author big-tiandm
date Wed, 29 Oct 2014 04:20:16 -0400
parents 07745c0958dd
children 22d79320085c
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: tiandm@big.ac.cn
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
5 #Date: 2009-05-06
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
6 #Modified:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
7 #Description: ɾ³ýmatched reads
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 use File::Basename;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
13
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
14 my %opts;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
15 GetOptions(\%opts,"i=s","outdir=s","column1:i","mark1=s","depth1:i","depth2:i","column2:i","mark2=s","h");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
16 if (!(defined $opts{i} and defined $opts{outdir} and defined $opts{mark1} and defined $opts{mark2}) || defined $opts{h}) { #necessary arguments
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
17 &usage;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
18 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
19
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
20 my $filein=$opts{'i'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
21 my $outputdir=$opts{'outdir'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
22 unless ($outputdir=~/\/$/) {$outputdir .="/";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
23 my $column1=defined $opts{column1} ? $opts{column1} : 3;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
24 my $column2=defined $opts{column2} ? $opts{column2} : 4;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
25 my $mark1=$opts{mark1};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
26 my $mark2=$opts{mark2};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
27 my $fileout=$outputdir."degseq.R";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
28 my $log=$outputdir."LOG.txt";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
29
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
30 open OUT,">$fileout"; #output file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
31 open LOG,">$log";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
32 print LOG "JOB start!\t";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
33 print LOG `date`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
34 print LOG "\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
35 #my ($name,$dir);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
36 #$name=basename($filein);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
37 print OUT "library(DEGseq)\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
38 print OUT "geneExpFile <- system.file(package=\"DEGseq\")\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
39 print OUT "geneExpFile<-file.path(\"$filein\")\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
40 print OUT "layout(matrix(c(1,2,3,4,5,6), 3, 2, byrow=TRUE))\npar(mar=c(2, 2, 2,2))\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
41 print OUT "outputdir<-file.path(\"$outputdir\")\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
42 print OUT "geneExpMatrix1 <- readGeneExp(file=geneExpFile, geneCol=1, valCol=c($column1))\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
43 print OUT "geneExpMatrix2 <- readGeneExp(file=geneExpFile, geneCol=1, valCol=c($column2))\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
44 if(defined $opts{'depth1'} && defined $opts{'depth2'}){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
45 print OUT "DEGexp(geneExpMatrix1=geneExpMatrix1, geneCol1=1, expCol1=c(2), groupLabel1=\"$mark1\",geneExpMatrix2=geneExpMatrix2, geneCol2=1, expCol2=c(2), groupLabel2=\"$mark2\",depth1=$opts{depth1},depth2=$opts{depth2},outputDir=outputdir,method=\"MARS\")\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
46 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
47 else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
48 print OUT "DEGexp(geneExpMatrix1=geneExpMatrix1, geneCol1=1, expCol1=c(2), groupLabel1=\"$mark1\",geneExpMatrix2=geneExpMatrix2, geneCol2=1, expCol2=c(2), groupLabel2=\"$mark2\",outputDir=outputdir,method=\"MARS\")\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
49 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
50 close OUT;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
51
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
52 print LOG "Prepare for DEGseq!\t";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
53 print LOG `date`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
54 print LOG "\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
55
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
56 system("R CMD BATCH $fileout");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
57
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
58 wait;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
59
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
60 my $outfile=$outputdir."result.txt";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
61 open OUT ,">$outfile";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
62 my $deg=$outputdir."output_score.txt";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
63 open IN,"<$deg";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
64 my %hash;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
65 while (my $aline=<IN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
66 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
67 if($aline=~/^\"/){print OUT "#GeneID\tchromsome\tvalue1\tvalue2\ttag\n";next;}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
68 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
69 #$hash{$temp[0].$temp[1].$temp[2]}=$temp[$#temp];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
70 #my @tmp=split/\|/,$temp[0];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
71 #my @tmp=split/\:/,$temp[0];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
72 #my @po=split/\-/,$tmp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
73 print OUT $temp[0],"\t",$temp[1],"\t",$temp[2],"\t",$temp[-1],"\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
74 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
75 close IN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
76
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
77 #open IN,"<$filein";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
78 #while (my $aline=<IN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
79 # chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
80 # my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
81 # if (defined $hash{$temp[0].$temp[2].$temp[3]}) {print OUT $aline,"\t",$hash{$temp[0].$temp[2].$temp[3]},"\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
82 # }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
83 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
84
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
85 print LOG "Finish all JOB !\t";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
86 print LOG `date`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
87 print LOG "\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
88
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
89 sub usage{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
90 print <<"USAGE";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
91 Version $version
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
92 Usage:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
93 $0 -i -outdir -column1 -mark1 -column2 -mark2 -depth1 -depth2
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
94 options:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
95 -i input file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
96 -outdir output file dir
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
97 -column1 the first column for DEGseq
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
98 -mark1 the name of the column1
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
99 -depth1 depth for the first file,use for normalize
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
100 -column2 the second column for DEGseq
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
101 -mark2 the name of the column2
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
102 -depth2 depth for the second file,use for normalize
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
103
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
104 -h help
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
105 USAGE
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
106 exit(1);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
107 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
108