-
Notifications
You must be signed in to change notification settings - Fork 1
/
EXCAVATORDataAnalysis.pl
executable file
·225 lines (145 loc) · 6.97 KB
/
EXCAVATORDataAnalysis.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/usr/bin/perl
use warnings;
use Pod::Usage;
use Getopt::Long;
use strict;
use File::Path;
use Cwd 'abs_path';
use File::Basename;
######################################################################
#
# Variables initialization with default values
#
######################################################################
my ($record,@words,@unlinkfiles,@SamplesVect);
my ($Program_Folder_Path,$Main_Output_Folder_Path,$Sample_Out_Folder_Path,$Sample_Label,$Analysis_Label,$Assembly,$Target_Name,$Target_File_Path,$RC_Folder_Path,$RCNorm_Folder_Path,$Images_Folder_Path,$R_Target_Folder,$R_Target_Path,$R_Norm_Path,$Input_File_Path,$Mode,$Sample_Res_Folder_Path,$Sample_Plot_Folder_Path,$Sample_Data_Folder_Path,$processors);
my ($verbose,$help,$man);
######################################################################
#
# Defining system variables
#
######################################################################
my ($myscript,$workingfolder,$L1,$L2);
$myscript = abs_path($0);
$Program_Folder_Path= dirname $myscript;
######################################################################
#
# Reading user's options
#
######################################################################
GetOptions('processors=s'=>\$processors,'assembly|a=s'=>\$Assembly,'target|t=s'=>\$Target_Name,'output|o=s'=>\$Main_Output_Folder_Path,'mode|e:s'=>\$Mode,'verbose|v'=>\$verbose,'help|h'=>\$help,'man|m'=>\$man,) or pod2usage ();
$help and pod2usage (-verbose=>1, -exitval=>1, -output=>\*STDOUT);
$man and pod2usage (-verbose=>2, -exitval=>1, -output=>\*STDOUT);
@ARGV == 1 or pod2usage ("Syntax error: the number of arguments found at command line is incorrect.");
$Input_File_Path=$ARGV[0];
die ("User ERROR: Please set option --mode with a valid string ('pooling' or 'paired').\n") if( $Mode ne "pooling" && $Mode ne "paired" );
#die ("User ERROR: the target specified with --target wasn't found for assembly $Assembly. \nPlease check --target and --assembly. \nError found") if (! -d "$Program_Folder_Path/data/targets/$Assembly/$Target_Name" );
######################################################################
#
# Checking system folders
#
######################################################################
print "Checking output folders...\n";
if(-e $Main_Output_Folder_Path){
print "'$Main_Output_Folder_Path' folder ready!\n";
}
else{
mkpath($Main_Output_Folder_Path);
if(-e $Main_Output_Folder_Path){
print "'$Main_Output_Folder_Path' folder created!\n";
}
}
print "Checking output subfolders...\n";
if(-e "$Main_Output_Folder_Path/Results"){
print "'$Main_Output_Folder_Path/Results' folder ready!\n";
}
else{
mkdir ("$Main_Output_Folder_Path/Results");
print "Creating '$Main_Output_Folder_Path/Results' folder...\n";
}
if(-e "$Main_Output_Folder_Path/Plots"){
print "'$Main_Output_Folder_Path/Plots' folder ready!\n";
}
else{
mkdir ("$Main_Output_Folder_Path/Plots");
print "Creating '$Main_Output_Folder_Path/Plots' folder...\n";
}
if(-e "$Main_Output_Folder_Path/.tmp"){
print "'$Main_Output_Folder_Path/.tmp' folder ready!\n";
}
else{
mkdir ("$Main_Output_Folder_Path/.tmp");
print "Creating '$Main_Output_Folder_Path/.tmp' folder...\n";
}
######################################################################
#
# When mode is pooling generates the Read Count for Controls
#
######################################################################
if($Mode eq "pooling"){
print "Creating Pooling Control!\n";
system qq(R --slave --args $Program_Folder_Path,$Main_Output_Folder_Path,$Program_Folder_Path/data/targets/$Assembly/$Target_Name,$Input_File_Path,$Mode,$Target_Name < $Program_Folder_Path/lib/R/PoolingCreateControl.R);
print "Pooling Control Created!\n";
}
######################################################################
#
# Creating Multi Processor Analysis
#
######################################################################
print "Preparing Multiprocessor Analysis...\n";
system qq(R --slave --args $Program_Folder_Path,$Input_File_Path,$Main_Output_Folder_Path,$Target_Name,$Assembly,$processors,$Mode < $Program_Folder_Path/lib/R/DataAnalysisParallel.R);
print "Multiprocessor Analysis Complete\n";
print "Starting Multiprocessor Analysis!\n";
######################################################################
#
# Running Multi Processor Analysis
#
######################################################################
my $Input_File_Parallel="$Main_Output_Folder_Path/.tmp/ParallelAnalyzePerla.sh";
open(CHECKBOOK,"$Input_File_Parallel") || die "Couldn't open the input file $Input_File_Parallel.";
my @pids;
while($record=<CHECKBOOK>){
my $childpid = fork() or exec($record);
push(@pids,$childpid);
}
print "My Children: ", join(' ',@pids), "\n";
waitpid($_,0) for @pids;
print "Multiprocessor Analysis Complete!\n";
######################################################################
#
# Documentation
#
######################################################################
=head1 SYNOPSIS
perl EXCAVATORDataAnalysis.pl [arguments] [options]
Options:
-h, --help Print help message.
-m, --man Print complete documentation.
-v, --verbose Use verbose output.
Function:
EXCAVATORDataAnalysis.pl performs segmentation of the WMRC and classify each segmented region as one of 5 possible discrete states (2-copy deletion, 1-copy deletion, normal, 1-copy duplication and N-copy amplification).
Example:
EXCAVATOR2> perl EXCAVATORDataAnalysis.pl ExperimentalFileAnalysis.w50K.txt --processors 6 --target MyTarget_w50K --assembly hg19 --output /.../OutEXCAVATOR2/Results_MyProject_w50K --mode pooling/paired
=head1 OPTIONS
=over 8
=item B<--help>
Print a brief usage message and detailed explanation of options.
=item B<--man>
Print the complete manual of the script.
=item B<--verbose>
Use verbose output.
=item B<--processors>
The number of thread to use for the analysis.
=item B<--output>
The output folder for resulting files.
=item B<--assembly>
The assembly exploited for read mapping and target initialization.
=item B<--target>
The "target name" used for target initialization with TargetPerla.pl.
=item B<--mode>
The experimental design mode to use. The possible options are "pooling" or "paired".
=back
=head1 DESCRIPTION
EXCAVATORDataAnalysis.pl perform the segmentation of the WMRC by means of the Shifting Level Model algorithm and exploits FastCall algorithm to classify each segmented region as one of the five possible discrete states (2-copy deletion, 1-copy deletion, normal, 1-copy duplication and N-copy amplification). The FastCall calling procedure takes into account sample heterogeneity and exploits the Expectation Maximization algorithm to estimate the parameters of a five gaussian mixture model and to provide the probability that each segment belongs to a specific copy number state.
EXCAVATOR2 is freely available to the community for non-commercial use. For questions or comments, please contact "romina.daurizio@gmail.com".
=cut