-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplot_basic_stats.pl
More file actions
executable file
·99 lines (80 loc) · 2.39 KB
/
plot_basic_stats.pl
File metadata and controls
executable file
·99 lines (80 loc) · 2.39 KB
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
#!/usr/bin/perl
use warnings;
my ($data_dir, $network_type, $script_dir) = @ARGV;
require "$script_dir/Construct_network.pl";
my %gene_to_index;
my @index_to_gene;
my @connections;
if(@ARGV > 1){
if($network_type eq "NETBOX"){
construct_netbox_network($data_dir, \@index_to_gene, \%gene_to_index, \@connections, $script_dir);
}
if($network_type eq "DRIVER_NET"){
construct_driver_net_network(\@index_to_gene, \%gene_to_index, \@connections, $script_dir);
}
print STDERR "------ nb gene in network ".(@index_to_gene)."\n";
}
opendir(DIR, $data_dir);
@the_DATA_DIR = readdir(DIR);
close(DIR);
%sample_gene_mutated = ();
%sample_gene_CNV = ();
%sample_gene_dysregulated = ();
my $nb_fold_change = 13;
my $inc_fold_change = 0.5;
my @fold_change_value = ();
for($i = 0; $i < $nb_fold_change; $i++){
push(@fold_change_value, $i*$inc_fold_change);
}
foreach my $dir_sample (@the_DATA_DIR){
$mutation_file_name = "$data_dir/$dir_sample/Genelist_Status.txt";
if(-e $mutation_file_name){
open(FILE, $mutation_file_name);
my @fold_change_stats = ();
for($i = 0; $i < $nb_fold_change; $i++){
push(@fold_change_stats, 0);
}
$sample_gene_dysregulated{$dir_sample} = 0;
$sample_gene_mutated{$dir_sample} = 0;
$sample_gene_CNV{$dir_sample} = 0;
while(<FILE>){
#print $_;
chop $_;
@line = split(/\t/, $_);
@line = split(/\t/, $_);
my @parts = split(/_/,$line[0]);
my $gene_name = $parts[0];
my $status = $parts[1];
if(@ARGV == 1 || exists $gene_to_index{$gene_name}){
if ($status eq "MUT" || $status eq "AMPL" || $status eq "DEL"){
if($status eq "MUT"){
$sample_gene_mutated{$dir_sample}++;
}
else{
$sample_gene_CNV{$dir_sample}++;
}
}
if ($status eq "UP" || $status eq "DOWN"){
$fold_change = abs($line[1]);
for($i = 0; $i < @fold_change_stats; $i++){
if($fold_change != 0 && $fold_change >= $fold_change_value[$i]){
$fold_change_stats[$i]++;
}
}
}
}
}
$sample_gene_dysregulated{$dir_sample} = \@fold_change_stats;
}
}
$header = "NAME";
for($i = 0; $i < $nb_fold_change; $i++){
$h = "DYS_$fold_change_value[$i]";
$h =~ s/\./_/;
$header .= "\t$h";
}
$header .= "\tMUT\tCNV\n";
print $header;
foreach $s (keys %sample_gene_dysregulated){
print $s."\t".join("\t", @{$sample_gene_dysregulated{$s}})."\t".$sample_gene_mutated{$s}."\t".$sample_gene_CNV{$s}."\n";
}