forked from cjieming/jmtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallelePval2minN
executable file
·107 lines (80 loc) · 1.73 KB
/
allelePval2minN
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
#!/usr/bin/perl
use warnings;
use strict;
use File::Basename;
use Getopt::Long;
use Pod::Usage;
use Cwd;
use Switch;
=head1 NAME
allelePval2minN
=head1 SYNOPSIS
allelePval2minN [options] <>
-h help
binomialChart.txt:
0 1
1 1
col1: min n
col2: p-value
pval-cutoff-rnaseq.txt:
HG00096 0.009286
HG00100 0.009399
col1: sample name
col2: p value cut off for each (rnaseq) set
Example:
allelePval2minN -b binomialChart.txt pval-cutoff-rnaseq.txt
=head1 DESCRIPTION
=cut
#option variables
my $help;
my $bfile = '';
#initialize options
Getopt::Long::Configure ('bundling');
if(!GetOptions ('h'=>\$help, 'b=s'=>\$bfile) || scalar(@ARGV)!=1)
{
if ($help)
{
pod2usage(-verbose => 2);
}
else
{
pod2usage(1);
}
}
#************************************* p value cutoff *******************************
## input list
my $ifile = $ARGV[0];
open (INPUT, $ifile) || die "Cannot open $ifile: $!";
## print to STDOUT
#************************************* binomial Chart *******************************
# binomial chart
# col1 0-100 - assume a binomial n, and the probability that all are successes (or all are failures)
# col2 p value cutoff
## read file
open (BFILE, $bfile) || die "Cannot open $bfile: $!";
my @bees = <BFILE>;
chomp @bees;
## variable
my $minN;
my $maxP;
############## read input list ##############
while (<INPUT>)
{
chomp $_;
s/\r?\n?$//;
my @fields = split(/\t/,$_);
## take p value and loop binomial chart to compare
for(my $i=0; $i<@bees; $i++)
{
if($fields[1] > $bees[$i])
{
$minN = $i;
$maxP = $bees[$i];
last;
}
}
## output
print "$fields[0]\t$fields[1]\t$minN\t$maxP\n";
} # while INPUT
close(BFILE);
close(INPUT);