4
|
1 # Wrapper for MOSAiCS
|
|
2 # Written by Dongjun Chung, Jan. 15, 2013
|
|
3
|
|
4 #!/usr/bin/env perl;
|
|
5 use warnings;
|
|
6 use strict;
|
|
7 use File::Temp qw/tempfile/;
|
|
8 use File::Temp qw/tempdir/;
|
|
9 use File::Basename;
|
|
10
|
|
11 # parse command arguments
|
|
12 # inactive arguments: useChrfile, chrfile, excludeChr
|
|
13 # meaningless argument: analysisType (for later use)
|
|
14
|
|
15 die "Usage: perl mosaics_wrapper.pl [chip_path] [chip_file_format] [control_path] [control_file_format] [peak_path] [peak_file_format] [analysis_type] [report_summary_path] [report_gof_path] [report_exploratory_path] [PET?] [chromosome-wise?] [fdr_level] [frag_len] [bin_size] [capping] [signal_model] [bg_est_method] [d] [maxgap] [minsize] [thres] [parallel] [n_core]" unless @ARGV == 24;
|
|
16
|
|
17 my ( $chip_path, $chip_file_format, $control_path, $control_file_format, $peak_path, $peak_file_format, $analysis_type, $report_summary_path, $report_gof_path, $report_exploratory_path, $pet, $by_chr, $fdr_level, $frag_len, $bin_size, $capping, $signal_model, $bg_est_method, $d, $maxgap, $minsize, $thres, $parallel, $n_core ) = @ARGV;
|
|
18
|
|
19 # parse options: analysis type
|
|
20
|
|
21 if ( $analysis_type ne "IO" ) {
|
|
22 print "Only 'IO' is supported for analysis type!\n";
|
|
23 exit 1;
|
|
24 }
|
|
25
|
|
26
|
|
27 # parse options: report summary
|
|
28
|
|
29 my $report_summary = "FALSE";
|
|
30 if ( $report_summary_path ne "None" ) {
|
|
31 $report_summary = "TRUE";
|
|
32 }
|
|
33
|
|
34 # parse options: report GOF
|
|
35
|
|
36 my $report_gof = "FALSE";
|
|
37 if ( $report_gof_path ne "None" ) {
|
|
38 $report_gof = "TRUE";
|
|
39 }
|
|
40
|
|
41 # parse options: report exploratory analysis
|
|
42
|
|
43 my $report_exploratory = "FALSE";
|
|
44 if ( $report_exploratory_path ne "None" ) {
|
|
45 $report_exploratory = "TRUE";
|
|
46 }
|
|
47
|
|
48 # write a R scrip to run
|
|
49
|
|
50 my $tempdir_bin = tempdir();
|
|
51
|
|
52 my $cmd = qq|
|
|
53 suppressPackageStartupMessages(library(mosaics))
|
|
54 try( suppressPackageStartupMessages(library(parallel)), silent=TRUE )
|
|
55
|
|
56 mosaicsRunAll(
|
|
57 chipFile="$chip_path",
|
|
58 chipFileFormat="$chip_file_format",
|
|
59 controlFile="$control_path",
|
|
60 controlFileFormat="$control_file_format",
|
|
61 binfileDir="$tempdir_bin",
|
|
62 peakFile="$peak_path",
|
|
63 peakFileFormat="$peak_file_format",
|
|
64 reportSummary=$report_summary,
|
|
65 summaryFile="$report_summary_path",
|
|
66 reportExploratory=$report_exploratory,
|
|
67 exploratoryFile="$report_exploratory_path",
|
|
68 reportGOF=$report_gof,
|
|
69 gofFile="$report_gof_path",
|
|
70 PET=$pet,
|
|
71 byChr=$by_chr,
|
|
72 useChrfile=FALSE,
|
|
73 chrfile=NULL,
|
|
74 excludeChr=NULL,
|
|
75 FDR=$fdr_level,
|
|
76 fragLen=$frag_len,
|
|
77 binSize=$bin_size,
|
|
78 capping=$capping,
|
|
79 bgEst="$bg_est_method",
|
|
80 d=$d,
|
|
81 signalModel="$signal_model",
|
|
82 maxgap=$maxgap,
|
|
83 minsize=$minsize,
|
|
84 thres=$thres,
|
|
85 parallel=$parallel,
|
|
86 nCore=$n_core )
|
|
87
|
|
88 q()
|
|
89 |;
|
|
90
|
|
91 # run R
|
|
92
|
|
93 open( FT, "| R --slave --vanilla >& /dev/null" ) or die "Couldn't call R!\n";
|
|
94 print FT $cmd, "\n";
|
|
95 close FT or die "Couldn't finish R!\n";
|
|
96
|
|
97 exit;
|
|
98
|
|
99
|