-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_DESeq_wrapper.pl
executable file
·90 lines (72 loc) · 2.86 KB
/
run_DESeq_wrapper.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/perl
use strict;
use Getopt::Long qw(GetOptions);
my ($config, $bin, $species, $counts, $samplekey, $comparisons, $clusterOnly, $diff_out, $count_out, $cluster_out, $gsa_out, $help, $no_replicates, $Rlibs);
my $pre = 'TEMP';
GetOptions ('pre=s' => \$pre,
'config=s' => \$config,
'bin=s' => \$bin,
'species=s' => \$species,
'counts=s' => \$counts,
'samplekey=s' => \$samplekey,
'comparisons=s' => \$comparisons,
'diff_out=s' => \$diff_out,
'count_out=s' => \$count_out,
'cluster_out=s' => \$cluster_out,
'gsa_out=s' => \$gsa_out,
'clusterOnly' => \$clusterOnly,
'no_replicates' => \$no_replicates,
'Rlibs=s' => \$Rlibs,
'help' => \$help) or exit(1);
my $R = '';
open(CONFIG, "$config") or die "CAN'T OPEN CONFIG FILE $config $!";
while(<CONFIG>){
chomp;
my @conf = split(/\s+/, $_);
if($conf[0] =~ /^r$/i){
if(!-e "$conf[1]/R"){
die "CAN'T FIND R IN $conf[1] $!";
}
$R = $conf[1];
}
}
close CONFIG;
`export R_LIBS=$Rlibs:\$R_LIBS`;
my $run_gsa = "gsa.dir='$gsa_out'";
my $gmt_dir = "''";
if(!$gsa_out){
$run_gsa = "GSA=FALSE";
} else {
if($species =~ /hg19|human/i){
$gmt_dir = "gmt.dir='$bin/data/human/MSigDB/v7.1'";
} else {
if($species =~ /mm9|mm10|mouse/i){
$gmt_dir = "gmt.dir='$bin/data/mouse/MSigDB/v7.1'";
}
}
}
my $ec = 0;
if($clusterOnly){
print "COMMAND: $R/Rscript $bin/RunDE.R \"bin='$bin'\" \"pre='$pre'\" \"counts.file='$counts'\" \"counts.dir='$count_out'\" \"$run_gsa\" \"clustering.dir='$cluster_out'\" \"Rlibs='$Rlibs'\" \n";
`$R/Rscript $bin/RunDE.R "bin='$bin'" \"pre='$pre'\" "counts.file='$counts'" "counts.dir='$count_out'" "$run_gsa" "clustering.dir='$cluster_out'" "Rlibs='$Rlibs'"`;
$ec = $? >> 8;
}
else{
open(COMP, "$comparisons") || die "Can't open comparisons file $comparisons $!";
my @comps = ();
while(<COMP>){
chomp;
my @com = split(/\s+/, $_);
push @comps, "'$com[0] - $com[1]'";
}
close COMP;
my $cmpStr = join(",", @comps);
my $reps = "";
if($no_replicates){
$reps = "no.replicates=TRUE";
}
print "command: $R/Rscript $bin/RunDE.R \"bin='$bin'\" \"$gmt_dir\" \"pre='$pre'\" \"species='$species'\" \"proj.id='$pre'\" \"diff.exp.dir='$diff_out'\" \"counts.file='$counts'\" \"counts.dir='$count_out'\" \"clustering.dir='$cluster_out'\" \"$run_gsa\" \"key.file='$samplekey'\" \"comps=c($cmpStr)\" \"$reps\" \"pre='$pre'\" \"Rlibs='$Rlibs'\"\n";
`$R/Rscript $bin/RunDE.R "bin='$bin'" "$gmt_dir" \"pre='$pre'\" "species='$species'" "proj.id='$pre'" "diff.exp.dir='$diff_out'" "counts.file='$counts'" "pre='$pre'" "counts.dir='$count_out'" "clustering.dir='$cluster_out'" "$run_gsa" "key.file='$samplekey'" "comps=c($cmpStr)" "$reps" "Rlibs='$Rlibs'"`;
$ec = $? >> 8;
}
if($ec != 0){ die "Error(s) caught from RunDE.R"; }