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

Cancer_modules_depression_epilepsy convert excel files to csv files #1487

Merged
merged 10 commits into from
Jan 15, 2025
3 changes: 0 additions & 3 deletions resources/ResourceFile_Bladder_Cancer.xlsx

This file was deleted.

3 changes: 3 additions & 0 deletions resources/ResourceFile_Bladder_Cancer/parameter_values.csv
Git LFS file not shown
3 changes: 0 additions & 3 deletions resources/ResourceFile_Breast_Cancer.xlsx

This file was deleted.

3 changes: 3 additions & 0 deletions resources/ResourceFile_Breast_Cancer/parameter_values.csv
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/ResourceFile_Depression/parameter_values.csv
Git LFS file not shown
3 changes: 0 additions & 3 deletions resources/ResourceFile_Oesophageal_Cancer.xlsx

This file was deleted.

Git LFS file not shown
3 changes: 0 additions & 3 deletions resources/ResourceFile_Other_Adult_Cancers.xlsx

This file was deleted.

Git LFS file not shown
3 changes: 0 additions & 3 deletions resources/ResourceFile_Prostate_Cancer.xlsx

This file was deleted.

3 changes: 3 additions & 0 deletions resources/ResourceFile_Prostate_Cancer/parameter_values.csv
Git LFS file not shown
22 changes: 13 additions & 9 deletions src/tlo/methods/bladder_cancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from tlo.methods.hsi_event import HSI_Event
from tlo.methods.hsi_generic_first_appts import GenericFirstAppointmentsMixin
from tlo.methods.symptommanager import Symptom
from tlo.util import read_csv_files

if TYPE_CHECKING:
from tlo.methods.hsi_generic_first_appts import HSIEventScheduler
Expand Down Expand Up @@ -208,8 +209,8 @@ def read_parameters(self, data_folder):

# Update parameters from the resourcefile
self.load_parameters_from_dataframe(
pd.read_excel(Path(self.resourcefilepath) / "ResourceFile_Bladder_Cancer.xlsx",
sheet_name="parameter_values")
read_csv_files(Path(self.resourcefilepath) / "ResourceFile_Bladder_Cancer",
files="parameter_values")
)

# Register Symptom that this module will use
Expand Down Expand Up @@ -268,7 +269,7 @@ def initialise_population(self, population):
if bc_status_any_stage.sum():
sum_probs = sum(p['init_prop_bladder_cancer_stage'])
if sum_probs > 0:
prob_by_stage_of_cancer_if_cancer = [i/sum_probs for i in p['init_prop_bladder_cancer_stage']]
prob_by_stage_of_cancer_if_cancer = [i / sum_probs for i in p['init_prop_bladder_cancer_stage']]
assert (sum(prob_by_stage_of_cancer_if_cancer) - 1.0) < 1e-10
df.loc[bc_status_any_stage, "bc_status"] = self.rng.choice(
[val for val in df.bc_status.cat.categories if val != 'none'],
Expand Down Expand Up @@ -366,7 +367,7 @@ def initialise_population(self, population):
df.is_alive &
(df.bc_status == 'metastatic') &
~pd.isnull(df.bc_date_diagnosis)
]
]

select_for_care = self.rng.random_sample(size=len(in_metastatic_diagnosed)) < p['init_prob_palliative_care']
select_for_care = in_metastatic_diagnosed[select_for_care]
Expand Down Expand Up @@ -432,7 +433,7 @@ def initialise_simulation(self, sim):
Predictor('had_treatment_during_this_stage',
external=True).when(True, p['rr_t2p_bladder_cancer_undergone_curative_treatment']),
Predictor('bc_status').when('tis_t1', 1.0)
.otherwise(0.0)
.otherwise(0.0)
)

lm['metastatic'] = LinearModel(
Expand All @@ -441,7 +442,7 @@ def initialise_simulation(self, sim):
Predictor('had_treatment_during_this_stage',
external=True).when(True, p['rr_metastatic_undergone_curative_treatment']),
Predictor('bc_status').when('t2p', 1.0)
.otherwise(0.0)
.otherwise(0.0)
)

# Check that the dict labels are correct as these are used to set the value of bc_status
Expand Down Expand Up @@ -495,7 +496,7 @@ def initialise_simulation(self, sim):
sensitivity=self.parameters['sensitivity_of_cystoscopy_for_bladder_cancer_pelvic_pain'],
target_categories=["tis_t1", "t2p", "metastatic"]
)
)
)

# ----- DISABILITY-WEIGHT -----
if "HealthBurden" in self.sim.modules:
Expand Down Expand Up @@ -584,13 +585,13 @@ def report_daly_values(self):
disability_series_for_alive_persons.loc[
(df.bc_status == "metastatic") &
(pd.isnull(df.bc_date_palliative_care))
] = self.daly_wts['metastatic']
] = self.daly_wts['metastatic']

# Assign daly_wt to those in metastatic cancer, who have had palliative care
disability_series_for_alive_persons.loc[
(df.bc_status == "metastatic") &
(~pd.isnull(df.bc_date_palliative_care))
] = self.daly_wts['metastatic_palliative_care']
] = self.daly_wts['metastatic_palliative_care']

return disability_series_for_alive_persons

Expand Down Expand Up @@ -702,6 +703,7 @@ class HSI_BladderCancer_Investigation_Following_Blood_Urine(HSI_Event, Individua
treatment or palliative care.
It is for people with the symptom blood_urine.
"""

def __init__(self, module, person_id):
super().__init__(module, person_id=person_id)

Expand Down Expand Up @@ -852,6 +854,7 @@ class HSI_BladderCancer_StartTreatment(HSI_Event, IndividualScopeEventMixin):
diagnosis of bladder Cancer using cystoscopy. It initiates the treatment of bladder Cancer.
It is only for persons with a cancer that is not in metastatic and who have been diagnosed.
"""

def __init__(self, module, person_id):
super().__init__(module, person_id=person_id)

Expand Down Expand Up @@ -1024,6 +1027,7 @@ def apply(self, person_id, squeeze_factor):

class BladderCancerLoggingEvent(RegularEvent, PopulationScopeEventMixin):
"""The only logging event for this module"""

def __init__(self, module):
"""schedule logging to repeat every 1 month
"""
Expand Down
26 changes: 15 additions & 11 deletions src/tlo/methods/breast_cancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from tlo.methods.hsi_event import HSI_Event
from tlo.methods.hsi_generic_first_appts import GenericFirstAppointmentsMixin
from tlo.methods.symptommanager import Symptom
from tlo.util import read_csv_files

if TYPE_CHECKING:
from tlo.methods.hsi_generic_first_appts import HSIEventScheduler
Expand Down Expand Up @@ -197,8 +198,8 @@ def read_parameters(self, data_folder):

# Update parameters from the resourcefile
self.load_parameters_from_dataframe(
pd.read_excel(Path(self.resourcefilepath) / "ResourceFile_Breast_Cancer.xlsx",
sheet_name="parameter_values")
read_csv_files(Path(self.resourcefilepath) / "ResourceFile_Breast_Cancer",
files="parameter_values")
)

# Register Symptom that this module will use
Expand Down Expand Up @@ -244,7 +245,7 @@ def initialise_population(self, population):
if brc_status_any_stage.sum():
sum_probs = sum(p['init_prop_breast_cancer_stage'])
if sum_probs > 0:
prob_by_stage_of_cancer_if_cancer = [i/sum_probs for i in p['init_prop_breast_cancer_stage']]
prob_by_stage_of_cancer_if_cancer = [i / sum_probs for i in p['init_prop_breast_cancer_stage']]
assert (sum(prob_by_stage_of_cancer_if_cancer) - 1.0) < 1e-10
df.loc[brc_status_any_stage, "brc_status"] = self.rng.choice(
[val for val in df.brc_status.cat.categories if val != 'none'],
Expand Down Expand Up @@ -550,10 +551,10 @@ def report_daly_values(self):
disability_series_for_alive_persons.loc[
(
~pd.isnull(df.brc_date_treatment) & (
(df.brc_status == "stage1") |
(df.brc_status == "stage2") |
(df.brc_status == "stage3")
) & (df.brc_status == df.brc_stage_at_which_treatment_given)
(df.brc_status == "stage1") |
(df.brc_status == "stage2") |
(df.brc_status == "stage3")
) & (df.brc_status == df.brc_stage_at_which_treatment_given)
)
] = self.daly_wts['stage_1_3_treated']

Expand Down Expand Up @@ -656,6 +657,8 @@ def apply(self, population):
df.loc[selected_to_die, 'brc_date_death'] = self.sim.date

# ---------------------------------------------------------------------------------------------------------


# HEALTH SYSTEM INTERACTION EVENTS
# ---------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -742,6 +745,7 @@ def apply(self, person_id, squeeze_factor):
tclose=None
)


# todo: we would like to note that the symptom has been investigated in a diagnostic test and the diagnosis was
# todo: was missed, so the same test will not likely be repeated, at least not in the short term, so we even
# todo: though the symptom remains we don't want to keep repeating the HSI which triggers the diagnostic test
Expand Down Expand Up @@ -776,8 +780,8 @@ def apply(self, person_id, squeeze_factor):

hs.schedule_hsi_event(
hsi_event=HSI_BreastCancer_PalliativeCare(
module=self.module,
person_id=person_id,
module=self.module,
person_id=person_id,
),
topen=self.sim.date,
tclose=None,
Expand Down Expand Up @@ -819,7 +823,7 @@ def apply(self, person_id, squeeze_factor):
topen=self.sim.date + DateOffset(months=12),
tclose=None,
priority=0
)
)


class HSI_BreastCancer_PostTreatmentCheck(HSI_Event, IndividualScopeEventMixin):
Expand Down Expand Up @@ -1007,7 +1011,7 @@ def apply(self, population):
'n_newly_diagnosed_stage3': n_newly_diagnosed_stage3,
'n_newly_diagnosed_stage4': n_newly_diagnosed_stage4,
'n_diagnosed_age_15_29': n_diagnosed_age_15_29,
'n_diagnosed_age_30_49': n_diagnosed_age_30_49,
'n_diagnosed_age_30_49': n_diagnosed_age_30_49,
'n_diagnosed_age_50p': n_diagnosed_age_50p,
'n_diagnosed': n_diagnosed
})
Expand Down
19 changes: 10 additions & 9 deletions src/tlo/methods/oesophagealcancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from tlo.methods.hsi_event import HSI_Event
from tlo.methods.hsi_generic_first_appts import GenericFirstAppointmentsMixin
from tlo.methods.symptommanager import Symptom
from tlo.util import read_csv_files

if TYPE_CHECKING:
from tlo.methods.hsi_generic_first_appts import HSIEventScheduler
Expand Down Expand Up @@ -217,8 +218,8 @@ def read_parameters(self, data_folder):
"""Setup parameters used by the module, register it with healthsystem and register symptoms"""
# Update parameters from the resourcefile
self.load_parameters_from_dataframe(
pd.read_excel(Path(self.resourcefilepath) / "ResourceFile_Oesophageal_Cancer.xlsx",
sheet_name="parameter_values")
read_csv_files(Path(self.resourcefilepath) / "ResourceFile_Oesophageal_Cancer",
files="parameter_values")
)

# Register Symptom that this module will use
Expand Down Expand Up @@ -395,7 +396,7 @@ def initialise_simulation(self, sim):
Predictor('li_tob').when(True, p['rr_low_grade_dysplasia_none_tobacco']),
Predictor('li_ex_alc').when(True, p['rr_low_grade_dysplasia_none_ex_alc']),
Predictor('oc_status').when('none', 1.0)
.otherwise(0.0)
.otherwise(0.0)
)

lm['high_grade_dysplasia'] = LinearModel(
Expand All @@ -404,7 +405,7 @@ def initialise_simulation(self, sim):
Predictor('had_treatment_during_this_stage',
external=True).when(True, p['rr_high_grade_dysp_undergone_curative_treatment']),
Predictor('oc_status').when('low_grade_dysplasia', 1.0)
.otherwise(0.0)
.otherwise(0.0)
)

lm['stage1'] = LinearModel(
Expand All @@ -413,7 +414,7 @@ def initialise_simulation(self, sim):
Predictor('had_treatment_during_this_stage',
external=True).when(True, p['rr_stage1_undergone_curative_treatment']),
Predictor('oc_status').when('high_grade_dysplasia', 1.0)
.otherwise(0.0)
.otherwise(0.0)
)

lm['stage2'] = LinearModel(
Expand All @@ -422,7 +423,7 @@ def initialise_simulation(self, sim):
Predictor('had_treatment_during_this_stage',
external=True).when(True, p['rr_stage2_undergone_curative_treatment']),
Predictor('oc_status').when('stage1', 1.0)
.otherwise(0.0)
.otherwise(0.0)
)

lm['stage3'] = LinearModel(
Expand All @@ -431,7 +432,7 @@ def initialise_simulation(self, sim):
Predictor('had_treatment_during_this_stage',
external=True).when(True, p['rr_stage3_undergone_curative_treatment']),
Predictor('oc_status').when('stage2', 1.0)
.otherwise(0.0)
.otherwise(0.0)
)

lm['stage4'] = LinearModel(
Expand All @@ -440,7 +441,7 @@ def initialise_simulation(self, sim):
Predictor('had_treatment_during_this_stage',
external=True).when(True, p['rr_stage4_undergone_curative_treatment']),
Predictor('oc_status').when('stage3', 1.0)
.otherwise(0.0)
.otherwise(0.0)
)

# Check that the dict labels are correct as these are used to set the value of oc_status
Expand Down Expand Up @@ -560,7 +561,7 @@ def report_daly_values(self):
(df.oc_status == "stage2") |
(df.oc_status == "stage3")
) & (df.oc_status == df.oc_stage_at_which_treatment_applied)
)
)
] = self.daly_wts['stage_1_3_treated']

# Assign daly_wt to those in stage4 cancer (who have not had palliative care)
Expand Down
Loading
Loading