Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1b04bed
creating chronic kidney disease module for transplants
thewati Aug 18, 2025
85ea8d5
linear models
thewati Aug 25, 2025
28d0d37
Transplant Evaluation HSI
thewati Sep 15, 2025
cd50f15
restrict init_prob_any_ckd to 2, not 3
thewati Sep 22, 2025
2a6d4ec
eligible population in polling
thewati Sep 22, 2025
2368aff
go to different HSIs from polling
thewati Sep 23, 2025
5fc0469
readme
Precious29-web Oct 6, 2025
9578b54
Merge remote-tracking branch 'origin/upile/cmd_kidney_transplant' int…
Precious29-web Oct 6, 2025
384977c
equipment added
Precious29-web Nov 3, 2025
61f8b44
renal clinic next session and herbal medication
thewati Nov 18, 2025
68a6ef1
consumables
Precious29-web Nov 10, 2025
409a0ad
Merge remote-tracking branch 'origin/upile/cmd_kidney_transplant' int…
Precious29-web Nov 18, 2025
f569a42
Merge branch 'master' into upile/cmd_kidney_transplant
Precious29-web Nov 24, 2025
cd63c9d
Merge branch 'master' into upile/cmd_kidney_transplant
thewati Nov 24, 2025
9f87e9b
renal clinic next session and herbal medication
thewati Nov 24, 2025
2570e63
consumables for kidney transplant surgery
Precious29-web Nov 25, 2025
a50103d
Merge remote-tracking branch 'origin/upile/cmd_kidney_transplant' int…
Precious29-web Nov 25, 2025
02e94d3
kidney transplant HSI
Precious29-web Nov 25, 2025
2709cb2
kidney transplant HSI with equipment
Precious29-web Nov 25, 2025
5210b36
dialysis HSI
Precious29-web Nov 25, 2025
3789836
Merge branch 'master' into upile/cmd_kidney_transplant
thewati Nov 25, 2025
c0631b1
formatting
thewati Nov 25, 2025
7d0902c
Add never ran to Refill HSI
thewati Nov 25, 2025
ffa9932
queues, anti-rejection and test file
thewati Nov 26, 2025
4ac1884
stage5 dalys
thewati Nov 26, 2025
a8e8338
Improving docstrings
Precious29-web Nov 26, 2025
34b335b
Merge branch 'master' into upile/cmd_kidney_transplant
thewati Nov 27, 2025
d6588d0
cdk resource file created
thewati Dec 5, 2025
eb997fe
ckd staging HSI, referalls, resource files
thewati Dec 9, 2025
6aea13e
Merge branch 'master' into upile/cmd_kidney_transplant
thewati Dec 9, 2025
7078868
Merge branch 'master' into upile/cmd_kidney_transplant
thewati Dec 9, 2025
6657544
.
thewati Dec 9, 2025
0a95a42
Merge remote-tracking branch 'origin/master'
thewati Dec 9, 2025
dc9f283
.
thewati Dec 9, 2025
ba723cb
Merge branch 'master' into upile/cmd_kidney_transplant
thewati Dec 9, 2025
92a1ef8
Merge remote-tracking branch 'origin/upile/cmd_kidney_transplant' int…
thewati Dec 9, 2025
dd6da41
death event for those on dialysis
thewati Dec 10, 2025
eb903e2
isort
thewati Dec 10, 2025
1c5012a
analysis compare num od deaths
thewati Dec 24, 2025
6e84902
Merge remote-tracking branch 'origin/master'
thewati Dec 28, 2025
6968ab0
scheduled graft death
Precious29-web Jan 7, 2026
f6cd794
Merge remote-tracking branch 'origin/master'
thewati Jan 12, 2026
570e797
Merge branch 'master' into upile/cmd_kidney_transplant
thewati Jan 12, 2026
eb26d5c
Plot DALYs
thewati Jan 12, 2026
f222200
Renal Clinic death event
Precious29-web Jan 13, 2026
3996549
Merge remote-tracking branch 'origin/upile/cmd_kidney_transplant' int…
Precious29-web Jan 13, 2026
660f2a0
Merge remote-tracking branch 'origin/master'
thewati Jan 19, 2026
a6e2fd0
Remove error. Rework renal clinic death event
thewati Jan 20, 2026
306536c
Merge branch 'master' into upile/cmd_kidney_transplant
thewati Jan 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
"""
Runs the CMD Chronic Kidney Disease module and produces the standard `compare_deaths` analysis to check
the number of deaths modelled against the GBD data.
"""

import matplotlib.pyplot as plt
import pandas as pd

from tlo import Date, Simulation, logging
from tlo.analysis.utils import compare_number_of_deaths, get_root_path, parse_log_file, make_age_grp_types
from tlo.methods import (
cardio_metabolic_disorders,
cmd_chronic_kidney_disease,
demography,
depression,
enhanced_lifestyle,
epi,
healthburden,
healthseekingbehaviour,
healthsystem,
hiv,
simplified_births,
symptommanager,
tb,
)

# The resource files
root = get_root_path()
resourcefilepath = root / "resources"

log_config = {
"filename": "cmd_chronic_kidney_disease_analysis",
"directory": root / "outputs",
"custom_levels": {
"*": logging.WARNING,
"tlo.methods.demography": logging.INFO,
"tlo.methods.healthburden": logging.INFO,
}
}

# Set parameters for the simulation
start_date = Date(2010, 1, 1)
end_date = Date(2015, 1, 1)
popsize = 5_000


def get_ckd_dalys(logfile):
output = parse_log_file(logfile)
dalys = output['tlo.methods.healthburden']['dalys_stacked']
# Keep only numeric DALY columns + age_range
numeric_cols = dalys.select_dtypes(include='number').columns
dalys = dalys[['age_range', *numeric_cols]]

# Sum over time
dalys = (
dalys
.groupby('age_range')
.sum()
.reindex(make_age_grp_types().categories)
.fillna(0.0)
)

return dalys


def run_sim(allow_hsi: bool):
sim = Simulation(start_date=start_date, log_config=log_config, resourcefilepath=resourcefilepath)

sim.register(
demography.Demography(),
simplified_births.SimplifiedBirths(),
enhanced_lifestyle.Lifestyle(),
healthsystem.HealthSystem(
disable=(allow_hsi is True),
disable_and_reject_all=(allow_hsi is False)
),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(),
healthburden.HealthBurden(),
cardio_metabolic_disorders.CardioMetabolicDisorders(),
cmd_chronic_kidney_disease.CMDChronicKidneyDisease(),
depression.Depression(),
hiv.Hiv(),
epi.Epi(),
tb.Tb(),
)

sim.make_initial_population(n=popsize)
sim.simulate(end_date=end_date)

return sim.log_filepath


# With interventions
logfile_with_healthsystem = run_sim(allow_hsi=True)
dalys_with_hs = get_ckd_dalys(logfile_with_healthsystem)

# Without interventions
logfile_no_healthsystem = run_sim(allow_hsi=False)
dalys_no_hs = get_ckd_dalys(logfile_no_healthsystem)

CAUSE_NAME = 'Kidney Disease'

# Extract CKD only (cause is a column)
ckd_dalys_with_hs = dalys_with_hs[CAUSE_NAME].fillna(0.0)
ckd_dalys_no_hs = dalys_no_hs[CAUSE_NAME].fillna(0.0)

# With healthsystem
comparison = compare_number_of_deaths(
logfile=logfile_with_healthsystem,
resourcefilepath=resourcefilepath
).rename(columns={'model': 'model_with_healthsystem'})

# Without healthsystem
x = compare_number_of_deaths(
logfile=logfile_no_healthsystem,
resourcefilepath=resourcefilepath
)['model']
x.name = 'model_no_healthsystem'

comparison = pd.concat([comparison, x], axis=1)

comparison = comparison.loc[
("2010-2014", slice(None), slice(None), CAUSE_NAME)
].fillna(0.0)

comparison.index = comparison.index.droplevel(
[name for name in comparison.index.names if name in ('period', 'cause')]
)

print("####################################### Result ###################")
print((comparison["model_with_healthsystem"] - comparison["model_no_healthsystem"]).abs().sum())

fig, axs = plt.subplots(nrows=2, sharex=True, figsize=(8, 6))

for ax, sex in zip(axs, ("M", "F")):
comparison.loc[sex].plot(ax=ax)
ax.set_ylabel("Deaths per year")
ax.set_title(f"Sex: {sex}")

axs[-1].set_xlabel("Age group")

plt.tight_layout()
plt.show()

# Plot for DALYs
fig, axs = plt.subplots(1, 2, figsize=(10, 4), sharey=True)

ckd_dalys_with_hs.plot.bar(ax=axs[0])
axs[0].set_title("CKD DALYs – With Health System")
axs[0].set_xlabel("Age group")
axs[0].set_ylabel("Total DALYs")

ckd_dalys_no_hs.plot.bar(ax=axs[1])
axs[1].set_title("CKD DALYs – No Health System")
axs[1].set_xlabel("Age group")

plt.tight_layout()
plt.show()
Loading
Loading