-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze-subRVIS.pl
More file actions
executable file
·66 lines (59 loc) · 1.57 KB
/
analyze-subRVIS.pl
File metadata and controls
executable file
·66 lines (59 loc) · 1.57 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
#!/usr/bin/perl
use strict;
use ProgramName;
use SummaryStats;
$|=1;
my $name=ProgramName::get();
die "$name <MIN_COUNT> <homozygotes_only:0/1> <genes.txt> <background.out>\n"
unless @ARGV==4;
my ($MIN_COUNT,$HOMOZYGOTES_ONLY,$GENES,$OUT_BG)=@ARGV;
my $RVIS="/home/bmajoros/intolerance/subRVIS/subRVIS.txt";
my $NAMES="/home/bmajoros/ensembl/gene-names/combined.txt";
my %toEnsembl;
open(IN,$NAMES) || die $NAMES;
while(<IN>) {
chomp; my @fields=split; next unless @fields>=2;
my ($ensembl,$id)=@fields;
$toEnsembl{$id}=$ensembl;
}
close(IN);
my %RVIS; # indexed by ensembl id
open(IN,$RVIS) || die $RVIS;
while(<IN>) {
chomp; my @fields=split; next unless @fields>=8;
my ($triplet,$gene,$subGERP,$genicRVIS,$subRVIS,$count,$mrt,$coverage)
=@fields;
my $ensembl=$toEnsembl{$gene};
next unless $ensembl;
push @{$RVIS{$ensembl}},$subRVIS;
}
close(IN);
my (%alleles,$n);
open(IN,$GENES) || die $GENES;
while(<IN>) {
chomp; my @fields=split; next unless @fields>=1;
my ($gene)=@fields;
if($gene=~/(\S+)\./) { $gene=$1 }
my $array=$RVIS{$gene};
next unless defined $array;
my ($mean,$SD,$min,$max)=SummaryStats::summaryStats($array);
my $CV=abs($SD/$mean);
#print "$SD\n";
print "$CV\n";
++$n;
}
close(IN);
open(OUT,">$OUT_BG") || die $OUT_BG;
my @keys=keys %RVIS;
my $numKeys=@keys;
for(my $i=0 ; $i<$numKeys ; ++$i) {
my $gene=$keys[$i];
my $array=$RVIS{$gene};
next unless @$array>1;
my ($mean,$SD,$min,$max)=SummaryStats::summaryStats($array);
next unless $mean>0;
my $CV=abs($SD/$mean);
#print OUT "$SD\n";
print OUT "$CV\n";
}
close(OUT);