-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunction_test.py
55 lines (39 loc) · 1.23 KB
/
function_test.py
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
import numpy as np
import math
# Changing function of phenotype scoring to make the fault scoring right.
# Every time the q=0, the score of low nq numbers end up in too high
# phenotype scores, i.e. positive scores.
# Possible solutions:
# subsetting nQ with sigmoid function
# subsetting nQ with linear function
# normalizing score, when nq=1, PS should be zero
def sigmoid(x):
return (1 / (1 + float(0.0005)*(np.exp(-(x-8)))))
q = 3
Q = 393
nq = 32
nQ = 3777 - Q
print "q = %i\n Q = %i\n nq = %i\n nQ = %i\n"%(q,Q,nq,nQ)
if q == 0:
q = 0.1
if nq == 0:
nq = 0.1
def formula(q,Q,nq,nQ):
return math.log((q / float(Q)) / float((nq / float(nQ))), 2)
def formula_lin_zerocorr(q,Q,nq,nQ):
#if Q <= 40:
# nq_corr = 0.025*Q
#else:
# nq_corr = 1
#nQ = nQ * nq_corr
nq_corr = 1
if q == 0.1:
zero_corr = math.log((0.1 / float(Q)) / float((1 / float(nQ))), 2)
else:
zero_corr = 0
print "nQ corr",nq_corr,"\tnew nQ:",nQ,"\nzero corr",zero_corr
return nq_corr*math.log((q / float(Q)) / float((nq / float(nQ))), 2) - zero_corr
Phenotype_score = formula(q,Q,nq,nQ)
Phenotype_score_lin_zerocorr = formula_lin_zerocorr(q,Q,nq,nQ)
print "PS original", Phenotype_score
print "formula_lin_zerocorr: ", Phenotype_score_lin_zerocorr