-
Notifications
You must be signed in to change notification settings - Fork 5
/
covcheck_score.py
71 lines (51 loc) · 1.8 KB
/
covcheck_score.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""This module does blah blah."""
## TODO: Scores should be LOD risk ratios I think...
def score_individual_by_age(individual):
"""Score an individuals 'COVID risk' by age.
See the analysis within stats/age_score.r to understand where the
scores come from. Scores are 'odds ratios' of COVID-19 CFR risk.
TODO: Read this data from file.
TODO: Update the analyis!
"""
if individual.age is None:
return None
if individual.age < 9:
return 0
if individual.age < 19:
return 0.500
if individual.age < 29:
return 1.050
if individual.age < 39:
return 1.875
if individual.age < 49:
return 2.950
if individual.age < 59:
return 8.000
if individual.age < 69:
return 27.000
if individual.age < 79:
return 79.750
# Age is 80+
return 159
def score_individual_by_snp(individual):
"""Score an individuals 'COVID risk' using SNPs.
The increased CFR (is based on the analysis in this preprint:
https://www.researchsquare.com/article/rs-37798/v1
Below we assume statistical independence of the two variables!
See the README.md for details.
"""
snp_score = 0
baseline_cfr = 0.1
# TODO: Remove magic knowledge using a SNP object?
# TODO: This is really crappy code!
if len(set(('rs12329760', 'rs75603675')) & set(individual.snps)) == 0:
return None
for snp_id, alleles in individual.snps.items():
if snp_id == 'rs12329760':
# Each C adds 0.2320
snp_score = snp_score + ( alleles.count("C") * 0.146 ) # CFR!
if snp_id == 'rs75603675':
# Each A adds 0.3565
snp_score = snp_score + ( alleles.count("A") * 0.148 ) # CFR!
snp_score = snp_score / baseline_cfr
return snp_score