Skip to content

Commit

Permalink
Merge pull request #208 from UCL/prep-usage
Browse files Browse the repository at this point in the history
Continuous PrEP usage
  • Loading branch information
mmcleod89 authored Nov 18, 2024
2 parents 0319779 + 78a7c74 commit 2cda7ea
Show file tree
Hide file tree
Showing 6 changed files with 647 additions and 236 deletions.
21 changes: 14 additions & 7 deletions src/hivpy/column_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,29 @@
PREP_LEN_WILLING = "prep_len_willing" # Bool: True if an individual is willing to use injectable Lenacapavir PrEP
PREP_VR_WILLING = "prep_vr_willing" # Bool: True if an individual is willing to use vaginal ring PrEP
PREP_ANY_WILLING = "prep_any_willing" # Bool: True if an individual is willing to use at least one type of PrEP
FAVOURED_PREP_TYPE = "favoured_prep_type" # None | prep.PrEPType(enum): PrEP type with highest preference an individual is willing to take that is also currently available, o/w None
PREP_ELIGIBLE = "prep_eligible" # Bool: True if an individual is eligible for PrEP usage
PREP_ORAL_TESTED = "prep_oral_tested" # Bool: True if an individual has tested explicitly to start oral PrEP (DUMMY)
PREP_CAB_TESTED = "prep_cab_tested" # Bool: True if an individual has tested explicitly to start injectable Cab PrEP (DUMMY)
PREP_LEN_TESTED = "prep_len_tested" # Bool: True if an individual has tested explicitly to start injectable Len PrEP (DUMMY)
PREP_VR_TESTED = "prep_vr_tested" # Bool: True if an individual has tested explicitly to start vaginal ring PrEP (DUMMY)
PREP_TYPE = "prep_type" # None | prep.PrEPType(enum): Oral, Cabotegravir, Lenacapavir, or VaginalRing if PrEP is being used, o/w None
EVER_PREP = "ever_prep" # Bool: True if an individual has ever been on PrEP
FIRST_ORAL_START_DATE = "first_oral_start_date" # None | date: start date of first ever oral PrEP usage
FIRST_CAB_START_DATE = "first_cab_start_date" # None | date: start date of first ever injectable Cab PrEP usage
FIRST_LEN_START_DATE = "first_len_start_date" # None | date: start date of first ever injectable Len PrEP usage
FIRST_VR_START_DATE = "first_vr_start_date" # None | date: start date of first ever vaginal ring PrEP usage
LAST_PREP_START_DATE = "last_prep_start_date" # None | date: start date of most recent PrEP usage
PREP_JUST_STARTED = "prep_just_started" # Bool: True if PrEP usage began this time step (DUMMY)
PREP_ORAL_TESTED = "prep_oral_tested" # Bool: True if an individual has tested explicitly to start oral PrEP (DUMMY)
PREP_CAB_TESTED = "prep_cab_tested" # Bool: True if an individual has tested explicitly to start injectable Cab PrEP (DUMMY)
PREP_LEN_TESTED = "prep_len_tested" # Bool: True if an individual has tested explicitly to start injectable Len PrEP (DUMMY)
PREP_VR_TESTED = "prep_vr_tested" # Bool: True if an individual has tested explicitly to start vaginal ring PrEP (DUMMY)

ART_ADHERENCE = "art_adherence" # DUMMY
LAST_PREP_STOP_DATE = "last_prep_stop_date" # None | date: stop date of most recent PrEP usage
PREP_JUST_STARTED = "prep_just_started" # Bool: True if PrEP usage began this time step
CONT_ON_PREP = "cont_on_prep" # None | timedelta: total length of continuous usage of current PrEP based on user intention (breaks due to ineligibility do not count against continuity)
CONT_ACTIVE_ON_PREP = "cont_active_on_prep" # None | timedelta: actual total length of continuous usage of current PrEP
CUMULATIVE_PREP_ORAL = "cumulative_prep_oral" # None | timedelta: total length of cumulative oral PrEP usage
CUMULATIVE_PREP_CAB = "cumulative_prep_cab" # None | timedelta: total length of cumulative injectable Cab PrEP usage
CUMULATIVE_PREP_LEN = "cumulative_prep_len" # None | timedelta: total length of cumulative injectable Len PrEP usage
CUMULATIVE_PREP_VR = "cumulative_prep_vr" # None | timedelta: total length of cumulative injectable vaginal ring PrEP usage

ART_ADHERENCE = "art_adherence" # None | Float: percentage of ART intake that is adhered to
TA_MUTATION = "tam" # X_MUTATION: drug resistance cols (TODO: all 24 currently DUMMIED)
M184_MUTATION = "m184m"
K65_MUTATION = "k65m"
Expand Down
8 changes: 6 additions & 2 deletions src/hivpy/data/prep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ prep_willing_threshold: 0.2
prob_test_prep_start:
Value: [0.25, 0.50, 0.75]
prob_base_prep_start:
Value: [0.05, 0.10, 0.20]
# FIXME: do we need this to be separate from prob_base_prep_start?
Value: [0.10, 0.30]
prob_prep_restart:
Value: [0.05, 0.10, 0.20]
prob_base_prep_stop:
Value: [0.05, 0.15, 0.30]
prob_base_prep_stop_nonuniform:
Value: [0.05, 0.15, 0.30]
Probability: [0.8, 0.1, 0.1]
15 changes: 13 additions & 2 deletions src/hivpy/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,17 @@ def general_func(g):
# Use Dummy column to in order to enable transform method and avoid any risks to data
return df.groupby(param_list, dropna=dropna)["Dummy"].transform(general_func)

def col_apply(self, param_list, func, sub_pop=None):
"""
Applies a function to specific columns in the dataframe.
"""
if sub_pop is not None:
df = self.data.loc[sub_pop]
else:
df = self.data
# Lambda function used to extract param column contents
return df.apply(lambda x: func(*[x[p] for p in param_list]), axis=1)

def evolve(self, time_step: timedelta):
"""
Advance the population by one time step.
Expand All @@ -287,7 +298,7 @@ def evolve(self, time_step: timedelta):
if self.HIV_introduced:
self.hiv_status.set_primary_infection(self)
self.hiv_status.set_viral_load_groups(self)
self.prep.prep_willingness(self)
self.prep.prep_propensity(self)
self.prep.prep_eligibility(self)

if self.circumcision.vmmc_disrup_covid:
Expand All @@ -307,7 +318,7 @@ def evolve(self, time_step: timedelta):
if (n_deaths and self.apply_death):
self.drop_from_population(HIV_deaths)
self.hiv_diagnosis.update_HIV_diagnosis(self)
self.prep.prep_usage(self)
self.prep.prep_usage(self, time_step)

# Some population cleanup
self.pregnancy.reset_anc_at_birth(self)
Expand Down
Loading

0 comments on commit 2cda7ea

Please sign in to comment.