Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasting Module #543

Open
wants to merge 173 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 100 commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
1b3c72e
add test_wasting.py
tbhallett Apr 6, 2022
7c57737
add wasting.py
tbhallett Apr 6, 2022
d35833c
edit hsi_generic_first_appts.py
tbhallett Apr 6, 2022
55aa12c
made some changes in wasting to ensure all tests in test_wasting are …
mnjowe Oct 5, 2023
e34e350
Merge branch 'master' into hallett/wasting_module
mnjowe Oct 5, 2023
f399fbf
getting things running in the current wasting state and generate some…
mnjowe Oct 6, 2023
75ebb3a
not import but important
mnjowe Oct 6, 2023
5f12010
Linter Changes
thewati Oct 9, 2023
25d4493
added more treatment ids to color map
thewati Oct 10, 2023
22e013d
Updated policies excel and wasting dependencies python files
thewati Oct 11, 2023
0c12856
module dependencies, cause of death color map, linting
mnjowe Oct 12, 2023
4c089a1
Merge branch 'master' into hallett/wasting_module
mnjowe Oct 13, 2023
44cb176
HSI event name should include module name
mnjowe Oct 17, 2023
3e6c6f0
changed some logic, linting, progress individuals to SAM instead of k…
mnjowe Oct 20, 2023
9df52aa
code cleaning
mnjowe Oct 20, 2023
4cae512
fixed line error
thewati Oct 23, 2023
c416d7a
added oedema reset to Wasting Natural Recovery
inesll Nov 3, 2023
3c80825
Remove progression to severe following treatment failure for MAM.
inesll Nov 3, 2023
d4fff87
re-structuring wasting module, activated HSI events, modified some pa…
mnjowe Dec 4, 2023
639fecd
Merge remote-tracking branch 'origin/hallett/wasting_module' into hal…
mnjowe Dec 4, 2023
344cf92
added a new sheet as per same file in master
mnjowe Dec 5, 2023
19e6c5a
Merge branch 'master' into hallett/wasting_module
mnjowe Dec 5, 2023
a711061
addressing the test membership error
mnjowe Dec 5, 2023
1cecf26
update
thewati Dec 5, 2023
09a1326
Merge remote-tracking branch 'origin/hallett/wasting_module' into hal…
thewati Dec 5, 2023
7563c94
Worked on graphs
thewati Dec 5, 2023
c57438f
Wasting Graphs
thewati Dec 5, 2023
7583361
Merge remote-tracking branch 'origin/hallett/wasting_module' into hal…
thewati Dec 5, 2023
5176fbc
remove hard-corded parameters and add them to resource file, reformat…
mnjowe Dec 7, 2023
2e68ce4
run from simulation
mnjowe Dec 7, 2023
1f0d55e
Merge remote-tracking branch 'origin/hallett/wasting_module' into hal…
mnjowe Dec 7, 2023
b902922
resolving test health system error, changed values in resource file f…
mnjowe Dec 11, 2023
0768775
correcting imports
mnjowe Dec 11, 2023
721ed0c
linting
mnjowe Dec 19, 2023
a4ff6bf
Merge branch 'master' into hallett/wasting_module
mnjowe Jan 4, 2024
cd20c5c
removing unnecessary semicolon
mnjowe Jan 4, 2024
7a7138d
Merge branch 'master' into hallett/wasting_module
mnjowe Jan 8, 2024
308e453
General changes after review 1
thewati Jan 29, 2024
cea20e0
Updated Priority Ranking Policies resource file
thewati Jan 31, 2024
b7f9e34
Stunting Rollback
thewati Jan 31, 2024
ed1723f
Treatment_ID update
thewati Jan 31, 2024
760e092
Update src/tlo/analysis/utils.py
thewati Feb 1, 2024
73407ad
Added Dalys reported test, Treatment_ID naming and other fixes
thewati Feb 2, 2024
7e5375e
Merge remote-tracking branch 'origin/hallett/wasting_module' into hal…
thewati Feb 2, 2024
140641c
removing unused death parameters and linear model, restructuring line…
mnjowe Feb 5, 2024
6ba66ca
Merge branch 'master' into hallett/wasting_module
mnjowe Feb 5, 2024
e1ab6f1
addressing failing tests
mnjowe Feb 5, 2024
e4b2df8
resolving checks error
mnjowe Feb 5, 2024
8f22e8e
isort error
mnjowe Feb 5, 2024
6c5d875
small fixes in wasting analyses, test and main module
mnjowe Feb 6, 2024
a038a8a
use "left" not left when assigning inclusive value in linear models
mnjowe Feb 6, 2024
b6b7306
remove misleading comment
mnjowe Feb 6, 2024
84ef308
Merge branch 'master' into hallett/wasting_module
thewati Feb 12, 2024
83d3ec4
addressing eva's comments and suggestions
mnjowe Feb 13, 2024
5c2fce3
Merge branch 'master' into hallett/wasting_module
mnjowe Feb 13, 2024
5fc9747
Merge branch 'master' into hallett/wasting_module
mnjowe Feb 13, 2024
bcb9bec
resolving conflicts
mnjowe Feb 15, 2024
7f39dea
Merge branch 'master' into hallett/wasting_module
mnjowe Feb 15, 2024
f522fed
RF_Wasting: CSV instead of XLSX
EvaJanouskova Feb 11, 2024
a6281a5
RF_Wasting: comments added
EvaJanouskova Feb 11, 2024
a348b88
wast: parameters re-ordered, comments adjusted
EvaJanouskova Feb 11, 2024
2776254
wast & test_wast: property renamed un_acute_malnutrition_tx_start_dat…
EvaJanouskova Feb 11, 2024
be848bb
wast: read parameters from CSV
EvaJanouskova Feb 12, 2024
2c67007
wast: properties descriptions adjusted
EvaJanouskova Feb 12, 2024
255e841
RF_Wast: note updated
EvaJanouskova Feb 12, 2024
645acc1
wast: minor changes (param moved; comment added)
EvaJanouskova Feb 12, 2024
177d8b0
RF_Wast: rename col 'more notes' to 'old values'; avoid multiple rows…
EvaJanouskova Feb 12, 2024
e70b39e
RF_Wast: added REF to some old values
EvaJanouskova Feb 19, 2024
d983393
wast: comments adjusted
EvaJanouskova Feb 19, 2024
b0d0b91
wast: setting properties in the order they are defined
EvaJanouskova Feb 19, 2024
a4d15e0
wast: TODO
EvaJanouskova Feb 19, 2024
11bfe6c
wast: tidy up the get_prob_severe_wasting_or_odds_wasting fnc; TODO i…
EvaJanouskova Feb 20, 2024
bee7e69
wast: descriptions and comments adjusted
EvaJanouskova Feb 20, 2024
e6e581e
Updated proportion, prob/odds function_name, rng
thewati Feb 22, 2024
d56f677
Merge remote-tracking branch 'origin/hallett/wasting_module' into hal…
thewati Feb 22, 2024
20b5cb5
Updated proportion, prob/odds function_name, rng
thewati Feb 22, 2024
e98abc7
Merge remote-tracking branch 'origin/hallett/wasting_module' into hal…
mnjowe Feb 26, 2024
268bebe
Fix prob_odds function_name, rng
thewati Mar 1, 2024
b263ef4
Merge branch 'master' into hallett/wasting_module
mnjowe Mar 1, 2024
06cf3ee
Merge remote-tracking branch 'origin/hallett/wasting_module' into hal…
mnjowe Mar 1, 2024
a6eb7b8
wast: fix a bug; rm TODOs
EvaJanouskova Mar 1, 2024
89e54ad
Standardize progression to sev wasting
thewati Mar 5, 2024
0a8c3ce
fixing the bug. return proportion not product
mnjowe Mar 5, 2024
0228ad2
changing all appearance of '115-<125mm' to '[115,125)mm'
mnjowe Mar 5, 2024
9420a41
Merge remote-tracking branch 'origin/hallett/wasting_module' into hal…
mnjowe Mar 5, 2024
7e5b471
adding random number generator to linear model
mnjowe Mar 5, 2024
f1eb95c
squeeze single row output
mnjowe Mar 6, 2024
ada21ed
plotting wasting prevalence by age group and year
mnjowe Mar 16, 2024
444f6d0
Merge branch 'master' into hallett/wasting_module
mnjowe Mar 16, 2024
30f480d
added footnote, fixed isort error
mnjowe Mar 17, 2024
7030202
RF_Wast, wast: CSV instead of XLSX
EvaJanouskova Feb 11, 2024
6f398bb
added wasting scenario run file for azure
mnjowe Jul 19, 2024
b0b8827
Merge branch 'master' into hallett/wasting_module
EvaJanouskova Jul 23, 2024
4558afd
PEP8
EvaJanouskova Jul 23, 2024
361c89d
Merge remote-tracking branch 'origin/master' into hallett/wasting_module
EvaJanouskova Jul 23, 2024
d5da5db
Merge branch 'EvaJ/wasting/first_suggestions' into hallett/wasting_mo…
EvaJanouskova Jul 23, 2024
de06bf6
RF_Wast, wast: [115,125) -> [115-125) (comma confuses the data as it …
EvaJanouskova Jul 24, 2024
070ec85
wast: fix the imports of HSIEventScheduler and IndividualProperties
EvaJanouskova Jul 24, 2024
17e4f21
RF_PriorityRanking_ALLPOLICIES: priorities changed for undernutrition…
EvaJanouskova Jul 25, 2024
79ba5e1
test_wast: input params of sim.modules['SymptomManager'].has_what fixed
EvaJanouskova Jul 25, 2024
c2646e2
wast: duplicated logger setup rm; logger arguments added
EvaJanouskova Jul 29, 2024
42f49c1
Merge branch 'master' into hallett/wasting_module
EvaJanouskova Jul 30, 2024
e59c24a
wast: fix MUAC distribution for moderate wasting; apply choice fnc to…
EvaJanouskova Jul 30, 2024
baa2631
RF_PriorityRanking_ALLPOLICIES: priorities changed for undernutrition…
EvaJanouskova Jul 30, 2024
11c7124
wast: apply fixed to be used on rows
EvaJanouskova Jul 31, 2024
005e3a8
test_wast: update checking of scheduled hsi events; outpatient and in…
EvaJanouskova Jul 31, 2024
dad77e6
wast: simplified setting of oedema status
EvaJanouskova Jul 31, 2024
190ede1
wast: returns rm from fnc descriptions if no return, outdated params …
EvaJanouskova Jul 31, 2024
cc05882
wast: update the var/fnc names to reflect what they store/do (esp. do…
EvaJanouskova Aug 2, 2024
4c29cca
[no ci] wast: update the par names to reflect what they represent
EvaJanouskova Aug 2, 2024
7cec79e
Merge branch 'master' into hallett/wasting_module
EvaJanouskova Aug 2, 2024
14e6b18
RF_Wast: update the par names to reflect what they represent
EvaJanouskova Aug 2, 2024
7158286
wast: assert added as stated in comment + minor changes (out of loop …
EvaJanouskova Aug 6, 2024
1f033fa
wast & analysis_wast: logging key updated to reflect prevalence props…
EvaJanouskova Aug 6, 2024
3246500
wast & test_wast: MAM/SAM corrected to mod/sev wasting
EvaJanouskova Aug 6, 2024
2fad6be
wast & test_wast: DALY calculations corrected
EvaJanouskova Aug 6, 2024
d0c88f4
wast: minor changes (comments, debug messages adjusted)
EvaJanouskova Aug 6, 2024
daef56b
wast: minor changes (params descriptions adjusted)
EvaJanouskova Aug 8, 2024
c73742c
wast & RF_wast: probs corrected
EvaJanouskova Aug 9, 2024
5baa6de
wast & test_wast: PollingEvent name specified
EvaJanouskova Aug 9, 2024
2115441
wast: MUAC, oedema, clinical state of acute malnutrition, and complic…
EvaJanouskova Aug 9, 2024
42b9bf5
wast & test_wast: natural recovery -prepared for future (to improve a…
EvaJanouskova Aug 23, 2024
0770b13
wast, RF_Wast & test_wast: treatment -lengths as parameters, -var nam…
EvaJanouskova Aug 23, 2024
a2efbf8
wast: actual mean for wasting incidence lm corrected
EvaJanouskova Aug 23, 2024
ebca720
wast: track incidence only (it is not incidence if they remained non-…
EvaJanouskova Aug 24, 2024
cc8d4ba
wast: return wasted always as series (even if 1 bool retuned) when in…
EvaJanouskova Oct 8, 2024
0c15bee
Merge remote-tracking branch 'origin/master' into hallett/wasting_module
EvaJanouskova Oct 8, 2024
cf83494
wast: progress/recovery from moderate wasting schedule only for new c…
EvaJanouskova Oct 8, 2024
be8521e
wast: split get_prob_severe_wasting_or_odds_wasting() fnc into two se…
EvaJanouskova Oct 8, 2024
c7a25a4
wast: fix wasting_prevalence_props calculations (logged)
EvaJanouskova Oct 8, 2024
03cae88
wast: typo
EvaJanouskova Oct 9, 2024
ad2ace6
Merge remote-tracking branch 'origin/master' into hallett/wasting_module
EvaJanouskova Oct 9, 2024
9ae10c1
wast & test_wast: fix and simplify calculation of proportion_normalWH…
EvaJanouskova Oct 9, 2024
91b70e5
wast: more descriptive names (consistent with other names)
EvaJanouskova Oct 10, 2024
15272c8
analysis_wast: rm note, update axis label
EvaJanouskova Oct 11, 2024
b454398
RF_wast: more precise value of proportion_oedema_with_WHZ<-2
EvaJanouskova Oct 11, 2024
61e6570
scenario_wast: create 2 scenarios incl. wasting - minimal and full_mo…
EvaJanouskova Oct 11, 2024
92eb806
scenario_wast_full|minimal_model: scenarios updated
EvaJanouskova Oct 11, 2024
16bf5bb
analysis_wast: renamed -> .._with_sim_running
EvaJanouskova Oct 11, 2024
9e12d96
analysis_wast: new analysis script analysis without running sim, to a…
EvaJanouskova Oct 11, 2024
a6de785
scenarios wast: names udpated in comments
EvaJanouskova Oct 11, 2024
3d7adfb
scenarios wast: start and end dates corrected
EvaJanouskova Oct 11, 2024
4880416
scenario_wast_min_model: 1 year sim & 2K pop
EvaJanouskova Oct 11, 2024
4b18b14
scenario_wast_orig: match modules with minimal_model
EvaJanouskova Oct 14, 2024
e607927
scenario_wast_orig: add name of scenario to output filename
EvaJanouskova Oct 14, 2024
9a52b89
undernutrion_analyses folder renamed -> stunting_analyses
EvaJanouskova Oct 14, 2024
57796ee
wast: print rm
EvaJanouskova Oct 14, 2024
dbaae82
analysis_wast: update the analysis script to analyse sim run from Azu…
EvaJanouskova Oct 15, 2024
b38e79a
analysis_wast: PEP 8
EvaJanouskova Oct 15, 2024
62af5e7
analysis_wast: save both png and pdf for each figure & all_figures in…
EvaJanouskova Oct 15, 2024
a0efad1
analysis_wast: save figs into simulation results folder
EvaJanouskova Oct 15, 2024
c7c3497
scenario_wast_full|minimal_model: sim 2010-2030(incl), 20K pop, 10 runs
EvaJanouskova Oct 15, 2024
ef9cb70
analysis_wast: PEP 8
EvaJanouskova Oct 15, 2024
065d1f4
scenario_wast_full|minimal_model: up to 2023-01-02 (wasting log after…
EvaJanouskova Oct 15, 2024
5695d74
wast: clinical acute malnutrition categories written together
EvaJanouskova Oct 17, 2024
4601dc6
analysis_wast: footnote corrected
EvaJanouskova Oct 17, 2024
a7fdda8
Merge remote-tracking branch 'origin/master' into hallett/wasting_module
EvaJanouskova Oct 17, 2024
c328ddb
wast: tidy up
EvaJanouskova Oct 17, 2024
3deb9f7
analysis_wast: title corrected
EvaJanouskova Oct 17, 2024
d463b56
wast: increase care_seeking_odds_ratio for SAM symptom, so almost eve…
EvaJanouskova Oct 22, 2024
88bc3f0
wast: follow-up MAM treatment after SAM treatment when recovered to MAM
EvaJanouskova Oct 22, 2024
5b5d8a2
wast: *new MAM, SAM cases start with 'none' treatment (not only wasti…
EvaJanouskova Oct 22, 2024
d96b53a
wast & test_wast: new HSI_Wasting_GrowthMonitoring; other events renamed
EvaJanouskova Oct 27, 2024
5ae5958
wast: rm duplicated setting of tx_start_date
EvaJanouskova Oct 28, 2024
c7adae1
wast: diagnosis any rnd day within the month; fasten run by excluding…
EvaJanouskova Oct 29, 2024
164f055
wast: priority=2 for HSI_Wasting_GrowthMonitoring
EvaJanouskova Oct 29, 2024
fa8cf23
wast: comment corrected
EvaJanouskova Oct 29, 2024
c2028d6
RF_PriorityRanking_ALLPOLICIES: Undernutrition_GrowthMonitoring added
EvaJanouskova Oct 29, 2024
e7023be
Merge remote-tracking branch 'origin/master' into hallett/wasting_module
EvaJanouskova Oct 30, 2024
14a8e11
Revert "RF_PriorityRanking_ALLPOLICIES: Undernutrition_GrowthMonitori…
EvaJanouskova Oct 30, 2024
4f8190c
RF_PriorityRanking_ALLPOLICIES: Undernutrition_GrowthMonitoring added…
EvaJanouskova Oct 29, 2024
17e7f20
hs: enforce_priority_policy() fnc updated to work for individual & po…
EvaJanouskova Oct 30, 2024
7da7768
scenario_wast_full_model|minimal_model|orig: till the end of 2030 no …
EvaJanouskova Oct 30, 2024
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
3 changes: 3 additions & 0 deletions resources/ResourceFile_Wasting.csv
Git LFS file not shown
Git LFS file not shown
252 changes: 252 additions & 0 deletions src/scripts/wasting_analyses/analysis_wasting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
"""
An analysis file for the wasting module
"""
import datetime
# %% Import statements
from pathlib import Path

import pandas as pd
from matplotlib import pyplot as plt

from tlo import Date, Simulation, logging
from tlo.analysis.utils import compare_number_of_deaths, parse_log_file
from tlo.methods import (
care_of_women_during_pregnancy,
contraception,
demography,
enhanced_lifestyle,
epi,
healthburden,
healthseekingbehaviour,
healthsystem,
hiv,
labour,
newborn_outcomes,
postnatal_supervisor,
pregnancy_supervisor,
symptommanager,
tb,
wasting,
)


def add_footnote(fig: plt.Figure, footnote: str):
""" A function that adds a footnote below each plot. Here we are explaining what a denominator for every
graph is """
fig.figure.text(0.5, 0.01, footnote, ha="center", fontsize=10,
bbox={"facecolor": "gray", "alpha": 0.3, "pad": 5})


class WastingAnalyses:
"""
This class looks at plotting all important outputs from the wasting module
"""

def __init__(self, log_file_path):
self.__log_file_path = log_file_path
# parse wasting logs
self.__logs_dict = \
parse_log_file(self.__log_file_path)['tlo.methods.wasting']

# gender description
self.__gender_desc = {'M': 'Males',
'F': 'Females'}

# wasting types description
self.__wasting_types_desc = {'WHZ<-3': 'severe wasting',
'-3<=WHZ<-2': 'moderate wasting',
'WHZ>=-2': 'not undernourished'}

def plot_wasting_incidence(self):
""" plot the incidence of wasting over time """
w_inc_df = self.__logs_dict['wasting_incidence_count']
w_inc_df.set_index(w_inc_df.date.dt.year, inplace=True)
w_inc_df.drop(columns='date', inplace=True)
# get age year. doesn't matter what wasting category you choose for
# they all have same age groups
age_years = list(w_inc_df.loc[w_inc_df.index[0], 'WHZ<-3'].keys(

))
age_years.remove('5+y')

_row_counter = 0
_col_counter = 0
# plot setup
fig, axes = plt.subplots(nrows=2, ncols=3, sharex=True, sharey=True)
for _age in age_years:
new_df = pd.DataFrame()
for state in w_inc_df.columns:
new_df[state] = \
w_inc_df.apply(lambda row: row[state][_age], axis=1)

new_df = new_df.apply(lambda _row: _row / _row.sum(), axis=1)
plotting = new_df[["WHZ<-3", "-3<=WHZ<-2"]]
# convert into proportions
ax = plotting.plot(kind='bar', stacked=True,
ax=axes[_row_counter, _col_counter],
title=f"incidence of wasting in {_age} infants",
ylim=[0, 0.05])
ax.legend(self.__wasting_types_desc.values(), loc='lower right')
ax.set_xlabel('year')
ax.set_ylabel('proportions')
# move to another row
if _col_counter == 2:
_row_counter += 1
_col_counter = -1
_col_counter += 1 # increment column counter
fig.tight_layout()
fig.savefig(
outputs / ('wasting incidence' + datestamp + ".pdf"),
format="pdf"
)
plt.show()

def plot_wasting_prevalence_per_year(self):
""" plot wasting prevalence of all age groups per year. Proportions are obtained by getting a total number of
children wasted divide by the total number of children less than 5 years"""
w_prev_df = self.__logs_dict["wasting_prevalence_count"]
w_prev_df = w_prev_df[['date', 'total_under5_prop']]
w_prev_df.set_index(w_prev_df.date.dt.year, inplace=True)
w_prev_df.drop(columns='date', inplace=True)
fig, ax = plt.subplots()
w_prev_df["total_under5_prop"].plot(kind='bar', stacked=True,
ax=ax,
title="Wasting prevalence in children 0-59 months per year",
ylabel='proportions',
xlabel='year',
ylim=[0, 0.05])
add_footnote(fig, "Proportion = total number of wasted children < 5 years / total number of children < 5 years")
plt.tight_layout()
fig.savefig(
outputs / ('wasting_prevalence_per_year' + datestamp + ".pdf"),
format="pdf"
)
plt.show()

def plot_wasting_prevalence_by_age_group(self):
""" plot wasting prevalence per each age group. Proportions are obtained by getting a total number of
children wasted in a particular age-group divide by the total number of children per that age-group"""
w_prev_df = self.__logs_dict["wasting_prevalence_count"]
w_prev_df.drop(columns={'total_under5_prop'}, inplace=True)
w_prev_df.set_index(w_prev_df.date.dt.year, inplace=True)
w_prev_df = w_prev_df.loc[w_prev_df.index == 2023]
w_prev_df.drop(columns='date', inplace=True)
fig, ax = plt.subplots()
# plot wasting prevalence
w_prev_df.squeeze().plot(kind='bar', stacked=False,
ax=ax,
title="Wasting prevalence in children 0-59 months per each age group in 2023",
ylabel='proportions',
xlabel='year',
ylim=[0, 0.1])
add_footnote(fig, "Proportion = total number of wasted children < 5 years per each age-group / total number of "
"children < 5 years per each age-group")
plt.tight_layout()
fig.savefig(
outputs / ('wasting_prevalence_per_each_age_group' + datestamp + ".pdf"),
format="pdf"
)
plt.show()

def plot_modal_gbd_deaths_by_gender(self):
""" compare modal and GBD deaths by gender """
death_compare = \
compare_number_of_deaths(self.__log_file_path, resources)
fig, axs = plt.subplots(nrows=1, ncols=2, sharey=True, sharex=True)
for _col, sex in enumerate(('M', 'F')):
plot_df = death_compare.loc[(['2010-2014', '2015-2019'],
sex, slice(None), 'Childhood Undernutrition'
)].groupby('period').sum()
plotting = plot_df.loc[['2010-2014', '2015-2019']]
ax = plotting['model'].plot.bar(label='Model', ax=axs[_col], rot=0)
ax.errorbar(x=plotting['model'].index, y=plotting.GBD_mean,
yerr=[plotting.GBD_lower, plotting.GBD_upper],
fmt='o', color='#000', label="GBD")
ax.set_title(f'{self.__gender_desc[sex]} '
f'wasting deaths, 2010-2014')
ax.set_xlabel("Time period")
ax.set_ylabel("Number of deaths")
ax.legend(loc=2)
fig.tight_layout()
add_footnote(fig, "Model output against Global Burden of Diseases(GDB) study data")
fig.savefig(
outputs / ('modal_gbd_deaths_by_gender' + datestamp + ".pdf"),
format="pdf"
)
plt.show()


thewati marked this conversation as resolved.
Show resolved Hide resolved
if __name__ == "__main__":
seed = 1

# Path to the resource files used by the disease and intervention methods
resources = Path("./resources")
outputs = Path("./outputs")

# create a datestamp
datestamp = datetime.date.today().strftime("__%Y_%m_%d") + \
datetime.datetime.now().strftime("%H_%M_%S")

# configure logging
log_config = {
# output filename. A timestamp will be added to this.
"filename": "wasting",
"custom_levels": { # Customise the output of specific loggers
"tlo.methods.demography": logging.INFO,
"tlo.methods.population": logging.INFO,
"tlo.methods.wasting": logging.INFO,
'*': logging.WARNING
}
}

# Basic arguments required for the simulation
start_date = Date(2010, 1, 1)
end_date = Date(2030, 1, 2)
pop_size = 20000

# Create simulation instance for this run.
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config)

# Register modules for simulation
sim.register(
demography.Demography(resourcefilepath=resources),
healthsystem.HealthSystem(resourcefilepath=resources,
service_availability=['*'],
cons_availability='default'),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resources),
healthburden.HealthBurden(resourcefilepath=resources),
symptommanager.SymptomManager(resourcefilepath=resources),
enhanced_lifestyle.Lifestyle(resourcefilepath=resources),
labour.Labour(resourcefilepath=resources),
care_of_women_during_pregnancy.CareOfWomenDuringPregnancy(
resourcefilepath=resources),
contraception.Contraception(resourcefilepath=resources),
pregnancy_supervisor.PregnancySupervisor(resourcefilepath=resources),
postnatal_supervisor.PostnatalSupervisor(resourcefilepath=resources),
newborn_outcomes.NewbornOutcomes(resourcefilepath=resources),
hiv.Hiv(resourcefilepath=resources),
tb.Tb(resourcefilepath=resources),
epi.Epi(resourcefilepath=resources),
wasting.Wasting(resourcefilepath=resources),
)

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

# read the results
output_path = sim.log_filepath

# initialise the wasting class
wasting_analyses = WastingAnalyses(output_path)

# plot wasting incidence
wasting_analyses.plot_wasting_incidence()

# plot wasting prevalence
wasting_analyses.plot_wasting_prevalence_per_year()

# plot wasting prevalence by age group
wasting_analyses.plot_wasting_prevalence_by_age_group()

# plot wasting deaths by gender as compared to GBD deaths
wasting_analyses.plot_modal_gbd_deaths_by_gender()
91 changes: 91 additions & 0 deletions src/scripts/wasting_analyses/scenario_wasting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
"""
This file defines a scenario for wasting analysis.

It can be submitted on Azure Batch by running:

tlo batch-submit src/scripts/wasting_analyses/scenario_wasting.py

or locally using:

tlo scenario-run src/scripts/wasting_analyses/scenario_wasting.py
"""
import warnings

from tlo import Date, logging
from tlo.methods import (
care_of_women_during_pregnancy,
contraception,
demography,
enhanced_lifestyle,
epi,
healthburden,
healthseekingbehaviour,
healthsystem,
hiv,
labour,
newborn_outcomes,
postnatal_supervisor,
pregnancy_supervisor,
symptommanager,
tb,
wasting,
)
from tlo.scenario import BaseScenario

# capture warnings during simulation run
warnings.simplefilter('default', (UserWarning, RuntimeWarning))


class WastingAnalysis(BaseScenario):

def __init__(self):
super().__init__(
seed=0,
start_date=Date(2010, 1, 1),
end_date=Date(2030, 1, 1),
initial_population_size=20_000,
number_of_draws=1,
runs_per_draw=1,
)

def log_configuration(self):
return {
'filename': 'wasting_analysis',
'directory': './outputs',
"custom_levels": { # Customise the output of specific loggers
"tlo.methods.demography": logging.INFO,
"tlo.methods.population": logging.INFO,
"tlo.methods.wasting": logging.INFO,
'*': logging.WARNING
}
}

def modules(self):
return [demography.Demography(resourcefilepath=self.resources),
healthsystem.HealthSystem(resourcefilepath=self.resources,
service_availability=['*'],
cons_availability='default'),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=self.resources),
healthburden.HealthBurden(resourcefilepath=self.resources),
symptommanager.SymptomManager(resourcefilepath=self.resources),
enhanced_lifestyle.Lifestyle(resourcefilepath=self.resources),
labour.Labour(resourcefilepath=self.resources),
care_of_women_during_pregnancy.CareOfWomenDuringPregnancy(
resourcefilepath=self.resources),
contraception.Contraception(resourcefilepath=self.resources),
pregnancy_supervisor.PregnancySupervisor(resourcefilepath=self.resources),
postnatal_supervisor.PostnatalSupervisor(resourcefilepath=self.resources),
newborn_outcomes.NewbornOutcomes(resourcefilepath=self.resources),
hiv.Hiv(resourcefilepath=self.resources),
tb.Tb(resourcefilepath=self.resources),
epi.Epi(resourcefilepath=self.resources),
wasting.Wasting(resourcefilepath=self.resources)]

def draw_parameters(self, draw_number, rng):
return {}


if __name__ == '__main__':
from tlo.cli import scenario_run

scenario_run([__file__])
2 changes: 1 addition & 1 deletion src/tlo/analysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@ def get_color_coarse_appt(coarse_appt_type: str) -> str:
'*': 'black',

'FirstAttendance*': 'darkgrey',
'Inpatient*': 'silver',

'Contraception*': 'darkseagreen',
'AntenatalCare*': 'green',
Expand Down Expand Up @@ -806,6 +805,7 @@ def get_color_short_treatment_id(short_treatment_id: str) -> str:

'Lower respiratory infections': 'darkorange',
'Childhood Diarrhoea': 'tan',
'Childhood Undernutrition': 'tomato',

'AIDS': 'deepskyblue',
'Malaria': 'lightsteelblue',
Expand Down
Loading
Loading