Skip to content

Commit 29edd21

Browse files
authored
Merge pull request #19 from ihmeuw-msca/cat_dev_pairwise
Cat dev pairwise
2 parents 3801e1d + 89790b1 commit 29edd21

File tree

17 files changed

+2539
-57
lines changed

17 files changed

+2539
-57
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,7 @@ result/
189189
# vscode
190190
.vscode/
191191

192+
# MacOS DS Store files
193+
.DS_Store
194+
192195
results/

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.4.2
4+
hooks:
5+
- id: ruff
6+
args: [ --fix ]
7+
- id: ruff-format
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v4.6.0
10+
hooks:
11+
- id: trailing-whitespace
12+
- id: end-of-file-fixer
13+
- repo: https://github.com/pre-commit/mirrors-mypy
14+
rev: v1.10.0
15+
hooks:
16+
- id: mypy
17+
files: ^src

data/categorical/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Data Format
2+
3+
The data file need to stored in name `{rei}-{acause}.csv`.
4+
This name will be used through out the process.
5+
6+
**Columns of the data frame**
7+
* `seq`: unique row id
8+
* `study_id`: usually equivalent with `nid` but with minor exceptions
9+
* `risk_type`: type of the risk, continuous, dichotomous, categorical, etc
10+
* `ln_rr`: mean of log relative risk
11+
* `ln_rr_se`: standard error of the log relative risk
12+
* `ref_risk_cat`: reference exposure category of the risk factor
13+
* `alt_risk_cat`: alternative exposure category of the risk factor
14+
* `cov_{name}`: bias covariates, usually related to study design
15+
16+
17+
**Settings**
18+
19+
`settings.yaml` file contains settings for actions in the process, main actions including
20+
* `fit_signal_model`: fit signal model
21+
* `select_bias_covs`: select bias covariates
22+
* `fit_linear_model`: fit final linear model

data/categorical/settings.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
default:
2+
# random seed
3+
seed: 0
4+
# order for clearly ordinal categories
5+
cat_order: []
6+
cov_type:
7+
# Specify covariates by type: bias (binary) and model (interacted and non-interacted)
8+
bias_covs: []
9+
interacted_covs: []
10+
non_interacted_covs: []
11+
fit_signal_model:
12+
# signal model settings, contains configurations for the exposure categories
13+
cat_cov_model:
14+
# reference exposure category, default is most common category in the data
15+
ref_cat:
16+
# priors for categories (in increasing order)
17+
# e.g., [risk_cat_1, risk_cat_2] corresponds to the logRR for risk_cat_1 <= risk_cat_2
18+
# complete or partial orderings may be provided
19+
prior_order: []
20+
signal_model:
21+
# trimming settings, inlier percentage default to be 90%, if you don't want to trim, use 1.0
22+
inlier_pct: 0.9
23+
select_bias_covs:
24+
cov_finder:
25+
# please put the pre-selected bias covariates in list
26+
pre_selected_covs: []
27+
complete_summary:
28+
# draws configuration
29+
draws:
30+
num_draws: 1000
31+
# additional quantiles for accurate estimation of quantiles rather than rely on draws
32+
quantiles: [0.025, 0.05, 0.5, 0.95, 0.975]
33+
score:
34+
# if we normalize the risk 'curve' to the lowest log RR
35+
# only for j-shaped this can be true
36+
# NOTE: shape will be dependent on plotting order (i.e., could artificially end up with a j-shaped curve,
37+
# as risk exposure categories do not increase in a fixed order, unlike continuous risk exposure values)
38+
normalize_to_tmrel: false
39+
figure:
40+
# show line connecting alternative and reference datapoints
41+
show_ref: true
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
seq,study_id,risk_type,ln_rr,ln_rr_se,ref_risk_cat,alt_risk_cat,cov_dummy
2+
0,93649,categorical,-0.357753711,0.088960128,unimproved,improved,0
3+
1,94512,categorical,-0.162518906,0.142761757,unimproved,solar,0
4+
2,111111,categorical,-1.56861592,0.667572011,piped,hq_piped,0
5+
3,116812,categorical,-0.287682072,0.034064764,unimproved,improved,0
6+
4,191572,categorical,-0.287682072,0.164257146,unimproved,improved,0
7+
5,191579,categorical,0.039220713,0.226110888,unimproved,piped,0
8+
6,191586,categorical,-0.248461398,0.148969044,unimproved,solar,0
9+
7,191801,categorical,-0.653926506,0.252201429,unimproved,filter,0
10+
9,191811,categorical,-0.46203546,0.614148812,improved,filter,0
11+
10,191811,categorical,-0.994252273,0.67865009,unimproved,filter,0
12+
11,193694,categorical,-0.036663995,0.054962366,unimproved,improved,0
13+
12,193701,categorical,-0.776528768,0.277094312,unimproved,solar,1
14+
13,193702,categorical,-0.616186102,0.163396749,unimproved,solar,0
15+
14,193703,categorical,-0.494296305,0.270635568,unimproved,improved,0
16+
15,193703,categorical,-0.494296305,0.270635568,unimproved,solar,0
17+
16,193728,categorical,-0.597836983,0.349056377,unimproved,filter,0
18+
17,193729,categorical,-0.755022584,0.165315975,improved,filter,0
19+
18,193730,categorical,-1.171182982,0.147471549,unimproved,solar,0
20+
19,193731,categorical,-0.293791819,0.067961316,unimproved,solar,0
21+
20,193732,categorical,-0.891598119,0.337997407,unimproved,solar,0
22+
21,193733,categorical,-0.030459177,0.112102077,unimproved,solar,0
23+
22,193734,categorical,-0.843970047,0.303932648,unimproved,piped,0
24+
23,193735,categorical,-0.994252273,0.128549606,unimproved,solar,0
25+
24,193736,categorical,-1.145703896,0.429935705,improved,hq_piped,0
26+
25,193737,categorical,-0.713349867,0.369118779,unimproved,filter,0
27+
26,193738,categorical,-0.597836983,0.189437785,unimproved,filter,0
28+
27,193739,categorical,-0.356674958,0.090123944,unimproved,solar,0
29+
28,193740,categorical,-0.494296305,0.029067948,unimproved,piped,0
30+
29,193741,categorical,0.122217633,0.067273797,unimproved,solar,0
31+
30,193742,categorical,-0.415515399,0.141299819,unimproved,solar,0
32+
31,193743,categorical,-0.415515399,0.141299819,unimproved,solar,0
33+
32,193744,categorical,-0.371063681,0.044478722,unimproved,solar,0
34+
33,193745,categorical,-0.446287118,0.148764549,unimproved,solar,0
35+
34,193746,categorical,-1.832581464,0.607038234,unimproved,solar,0
36+
35,193747,categorical,-0.094310647,0.180781736,unimproved,solar,0
37+
36,193748,categorical,-0.634878329,0.353653029,improved,piped,0
38+
37,193749,categorical,-0.457424867,0.17512395,unimproved,solar,0
39+
38,193750,categorical,-1.560647796,0.280263394,unimproved,filter,0
40+
39,193751,categorical,-0.056935116,0.125713839,unimproved,solar,0
41+
40,193751,categorical,-0.056935116,0.125713839,unimproved,improved,1
42+
41,193752,categorical,-0.105360538,0.290076399,unimproved,solar,0
43+
42,193753,categorical,-0.597836983,0.296212753,unimproved,solar,0
44+
43,193754,categorical,-0.287682072,0.145137252,improved,piped,0
45+
44,193755,categorical,-0.653926506,0.280263373,unimproved,solar,0
46+
45,193756,categorical,0.292669614,0.149948333,unimproved,piped,0
47+
46,193757,categorical,-0.248461398,0.032750886,unimproved,solar,0
48+
47,193758,categorical,-1.347073686,0.648666565,unimproved,filter,0
49+
48,193759,categorical,-0.941608565,0.340567751,unimproved,filter,0
50+
49,193760,categorical,-0.187211557,0.037168916,unimproved,piped,0
51+
50,193761,categorical,0.031193388,0.246379896,unimproved,solar,0
52+
51,193762,categorical,0.036405408,0.407646154,unimproved,improved,0
53+
52,193763,categorical,-0.010050326,0.080132943,unimproved,solar,0
54+
53,193764,categorical,-0.494296305,0.131421797,unimproved,filter,0
55+
54,193765,categorical,-0.527632793,0.2161514,improved,piped,0
56+
55,193766,categorical,-0.174353423,0.14096308,improved,piped,0
57+
56,193766,categorical,0.131028262,0.163571224,unimproved,piped,1
58+
57,193767,categorical,-0.494296305,0.156170756,unimproved,solar,0
59+
58,193768,categorical,-0.301105079,0.116089406,unimproved,piped,0
60+
59,193769,categorical,-1.660731207,0.578756432,unimproved,filter,0
61+
60,193769,categorical,-0.51082559,0.477509324,improved,filter,0
62+
61,193769,categorical,0.31481074,0.954946777,unimproved,filter,0
63+
62,193770,categorical,-1.272965676,0.264797633,unimproved,filter,0
64+
63,193771,categorical,-0.713349888,0.366605381,unimproved,filter,0
65+
64,193772,categorical,-0.235722308,0.08472957,unimproved,solar,0
66+
65,193773,categorical,-1.108662594,0.280263382,unimproved,solar,0
67+
66,193774,categorical,-0.061875404,0.029728563,unimproved,improved,0
68+
67,193775,categorical,-0.798507718,0.276971645,unimproved,filter,0
69+
68,222222,categorical,-2.772588722,0.597610582,piped,hq_piped,0
70+
69,268285,categorical,-0.223143539,0.232749551,unimproved,solar,0
71+
70,319502,categorical,-0.843970047,0.064856845,unimproved,solar,0
72+
71,333333,categorical,-0.376686124,0.947036574,piped,hq_piped,0
73+
72,334739,categorical,-1.560647796,0.083803584,unimproved,filter,0
74+
73,334743,categorical,-0.162518906,0.204375142,improved,filter,0
75+
74,334747,categorical,-0.162518906,0.176826501,unimproved,filter,0
76+
75,334751,categorical,-0.287682072,0.114530213,unimproved,filter,0
77+
76,334755,categorical,-1.560647796,0.16817797,unimproved,filter,0
78+
77,334755,categorical,-1.309333283,0.103436885,unimproved,filter,0
79+
78,354306,categorical,0.019802627,0.054697401,unimproved,solar,1
80+
79,357179,categorical,0.009950331,0.853402562,unimproved,solar,0
81+
80,357201,categorical,-0.248461398,0.032750886,unimproved,solar,0

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "bopforge"
7-
version = "0.0.6"
7+
version = "0.1.0"
88
description = "Pipelines for Burden of Proof (BoP) analyses"
99
readme = "REDME.md"
1010
requires-python = ">=3.10"
1111
license = { file = "LICENSE" }
1212
authors = [
1313
{ name = "IHME Math Sciences", email = "ihme.math.sciences@gmail.com" },
1414
]
15-
dependencies = ["numpy", "scipy", "pandas", "matplotlib", "mrtool==0.1.4", "pplkit"]
15+
dependencies = ["numpy<2.0.0", "scipy>=1.14.1", "pandas", "matplotlib", "mrtool>=0.2.1", "pplkit"]
1616

1717
[project.optional-dependencies]
1818
test = ["pytest"]
@@ -24,9 +24,10 @@ github = "https://github.com/ihmeuw-msca/bopforge"
2424
[project.scripts]
2525
continuous_pipeline = "bopforge.continuous_pipeline.__main__:main"
2626
dichotomous_pipeline = "bopforge.dichotomous_pipeline.__main__:main"
27+
categorical_pipeline = "bopforge.categorical_pipeline.__main__:main"
2728

2829
[tool.sphinx]
29-
project = "modrover"
30+
project = "bopforge"
3031
author = "IHME Math Sciences"
3132
copyright = "2024, IHME Math Sciences"
32-
version = "0.0.6"
33+
version = "0.1.0"

ruff.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
line-length = 80
2+
src = ["src"]
3+
4+
[format]
5+
docstring-code-format = true
6+
7+
[lint.pydocstyle]
8+
convention = "numpy"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Categorical Pipeline
2+
====================
3+
4+
Actions
5+
-------
6+
7+
.. autofunction:: bopforge.categorical.__main__.pre_processing
8+
9+
.. autofunction:: bopforge.categorical.__main__.fit_signal_model
10+
11+
.. autofunction:: bopforge.categorical.__main__.select_bias_covs
12+
13+
.. autofunction:: bopforge.categorical.__main__.fit_linear_model
14+
15+
16+
Functions
17+
---------
18+
19+
.. automodule:: bopforge.categorical_pipeline.functions
20+
:members:

src/bopforge/categorical_pipeline/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)