-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_project.pl
executable file
·85 lines (66 loc) · 3.75 KB
/
run_project.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
#!/usr/bin/perl
use strict;
#Use this script when needing to run cnfind on multiple samples from the same individual. It will streamline the process
#The script does not run anything but prints a series of commands which you can then pipe to sh or run in parallel as need be
#The project file (first argument) contains in each row a bam file and its "name"
#The first line is treated as the normal
#The second argument is the project output directory, which will contain subdirectories for every sample output
#The script will make several figures in the project output directory
my $project_file = $ARGV[0];
my $work_base = $ARGV[1];
(-e $project_file) or die("Project file \"$project_file\" not found\n");
my $alt_work_dir;
my $singlestage;
my $normal_dir;
my $starting_mode = "stage1";
my $expectedCalc = "gw";
my $normalization = "normalPreGC";
#my $ref_folder = "/home/groups/atlas/pmedvedev/hg18comp";
my $ref_folder = "hg19comp";
my $win_size = 10000;
$alt_work_dir = "--alt_work_dir $work_base";
#$singlestage = "--singlestage";
my @colors = ("green", "cyan", "orange", "pink");
my @samples;
open(PROJECT, $project_file);
while (<PROJECT>) {
chomp;
push(@samples, $_);
}
close(PROJECT);
my @normInfo = split / /, $samples[0];
my $normBam = $normInfo[0];
my $normName = $normInfo[1];
if ($starting_mode eq "stage1") {
#first run the normal all the way and everything else in only stage1. This is because stage1 takes a long time, but in stage2 the tumor calling will depend on the normal being completed.
for (my $i = 1; $i < @samples; $i++) {
my @info = split / /, $samples[$i];
my $bam = $info[0];
my $name = $info[1];
print "cnfind.pl --ref_folder $ref_folder $alt_work_dir/$name --work_dir $work_base/$name --mode $starting_mode --bam_files $bam --normalization $normalization --expectedCalc $expectedCalc --par --win_size $win_size --pval 1e-10 --singlestage & \n";
}
print "cnfind.pl --ref_folder $ref_folder $alt_work_dir/$normName --work_dir $work_base/$normName --mode $starting_mode --bam_files $normBam --normalization self --expectedCalc $expectedCalc --par --win_size $win_size --minlogratio -0.15 --maxlogratio 0.15\n";
$starting_mode = "annot2_win";
} else {
# need to just run the normal all the way through
print "cnfind.pl --ref_folder $ref_folder $alt_work_dir/$normName --work_dir $work_base/$normName --mode $starting_mode --bam_files $normBam --normalization self --expectedCalc $expectedCalc --par --win_size $win_size --minlogratio -0.15 --maxlogratio 0.15 $singlestage\n";
}
#next run the rest of the samples
my $normal_dir = "--normal_dir $work_base/$normName";
my $tum_files;
for (my $i = 1; $i < @samples; $i++) {
my @info = split / /, $samples[$i];
my $bam = $info[0];
my $name = $info[1];
$tum_files .= "$work_base/$name $name $colors[$i] ";
print "cnfind.pl --ref_folder $ref_folder $alt_work_dir/$name --work_dir $work_base/$name --mode $starting_mode --bam_files $bam $normal_dir --normalization $normalization --expectedCalc $expectedCalc --par --win_size $win_size --pval 1e-10 $singlestage\n";
}
#combined plots
print "cnfind.pl --mode plot_doc --fig_name $work_base/all_nocalls.png --samples \"$work_base/$normName $normName $colors[0] $tum_files\"\n";
print "cnfind.pl --mode plot_doc --fig_name $work_base/tums_nocalls.png --samples \"$tum_files\" \n";
print "cnfind.pl --mode plot_doc --fig_name $work_base/$normName.png --samples \"$work_base/$normName $normName $colors[0]\" --work_dir $work_base/$normName\n";
for (my $i = 1; $i < @samples; $i++) {
my @info = split / /, $samples[$i];
my $name = $info[1];
print "cnfind.pl --mode plot_doc --fig_name $work_base/${name}_$normName.png --samples \"$work_base/$name $name $colors[$i] $work_base/$normName $normName $colors[0]\" --work_dir $work_base/$name\n";
}