OMOP DB Advanced Language Showcase
A class for interacting with a database containing OMOP data. It provides methods for accessing person, observation, and measurement data.
1"""
2A class for interacting with a database containing OMOP data. It provides methods for accessing person, observation, and measurement data.
3"""
4from biomodel.database import OMOP_DB
5from biomodel.models import Framingham
6from pathlib import Path
7from biomodel.transformations import Set, WithProbability, Group, Before
8
9if __name__ == '__main__':
10 data_path = Path("/home/josalhor/Desktop/bioTwin/data/ukbiobank-simulation")
11
12 class TestDB(OMOP_DB):
13 """
14 A class for interacting with a database containing OMOP data. It provides methods for accessing person, observation, and measurement data.
15 """
16
17 person_path = data_path / "person.csv"
18 observation_path = data_path / "observation.csv"
19 measurement_path = data_path / "measurement.csv"
20
21
22 db = TestDB()
23 model = Framingham()
24
25 coltot = 4224820
26 hdl = 4011133
27 tas = 4152194
28 tad = 4154790
29 smoke = 1585856
30 diab = 35817874
31
32
33 prediction = model.predict_population_time(
34 db,
35 {
36 "No smoke": [
37 WithProbability(probability=0.2, transformation=Set(id=smoke, value=0))
38 ],
39 "No smoke 2Y": [
40 Before(
41 year=3,
42 transformation=WithProbability(
43 probability=0.2, transformation=Set(id=smoke, value=0)
44 ),
45 )
46 ],
47 "Imp No smoke 2Y": [
48 Group(
49 transformations=[
50 Before(
51 year=3,
52 transformation=WithProbability(
53 probability=0.2, transformation=Set(id=smoke, value=0)
54 ),
55 ),
56 WithProbability(
57 probability=0.007, transformation=Set(id=smoke, value=1)
58 ),
59 ],
60 )
61 ],
62 # "No smoke & CH control": [
63 # WithProbability(
64 # probability=0.2,
65 # transformation=Set(
66 # id=smoke,
67 # value=0
68 # )
69 # ),
70 # WithProbability(
71 # probability=0.5,
72 # transformation=Group(
73 # transformations=[
74 # RegressToValue(
75 # id=coltot,
76 # value=Normal(
77 # mean=180,
78 # std=20
79 # ),
80 # percentage=0.01
81 # ),
82 # RegressToValue(
83 # id=hdl,
84 # value=50,
85 # percentage=0.01
86 # ),
87 # ]
88 # )
89 # ),
90 # ],
91 # "Full control": [
92 # WithProbability(
93 # probability=0.2,
94 # transformation=Set(
95 # id=smoke,
96 # value=0
97 # )
98 # ),
99 # WithProbability(
100 # probability=0.6,
101 # transformation=Group(
102 # transformations=[
103 # RegressToValue(
104 # id=coltot,
105 # value=180,
106 # percentage=0.02
107 # ),
108 # RegressToValue(
109 # id=hdl,
110 # value=50,
111 # percentage=0.02
112 # ),
113 # RegressToValue(
114 # id=tas,
115 # value=125,
116 # percentage=0.02
117 # ),
118 # RegressToValue(
119 # id=tad,
120 # value=80,
121 # percentage=0.02
122 # ),
123 # ]
124 # )
125 # ),
126 # ]
127 },
128 )
129
130 prediction.show_change()
