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

Long-term partner infection #186

Merged
merged 44 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6559fdf
monogamous-nonmonogamous ltp infection
dimitrasal Jun 3, 2024
3a0f09f
Merge branch 'development' of github.com:UCL/hivpy into ds/ltpinfection
dimitrasal Jun 3, 2024
5661860
formatting
dimitrasal Jun 10, 2024
39f557b
style fixes
dimitrasal Jun 10, 2024
6e6da8f
removing COL.RISK_LTP
dimitrasal Jun 17, 2024
5765acf
vectorization part1
dimitrasal Jun 18, 2024
c72e84d
Refactoring monogamous ltp transmission
dimitrasal Jul 1, 2024
a7c557a
unit test correction
dimitrasal Jul 1, 2024
1da35a5
probability of infection from infected partner
dimitrasal Jul 4, 2024
e6c291a
prevalence
dimitrasal Jul 4, 2024
7b7579d
unit test for new ltp being already infected
dimitrasal Jul 4, 2024
132c3f7
Add tracking for new ltps
mmcleod89 Jul 8, 2024
1b868a9
updating functions and tests
dimitrasal Jul 9, 2024
dec9147
Merge branch 'development' of github.com:UCL/hivpy into ds/ltpinfection
dimitrasal Jul 9, 2024
5757804
test changes
dimitrasal Jul 9, 2024
a18a5dc
Some refactoring and generalise population size
mmcleod89 Aug 8, 2024
bf8c4d3
Remove LTP for people outside age range and update LTP infection code.
mmcleod89 Aug 9, 2024
7944ba6
Merge branch 'development' of github.com:UCL/hivpy into ds/ltpinfection
dimitrasal Sep 3, 2024
5c9d9c1
Add LTP treatment and viral suppression
mmcleod89 Sep 30, 2024
2196776
Merge branch 'ds/ltpinfection' of github.com:UCL/hivpy into ds/ltpinf…
mmcleod89 Sep 30, 2024
57990b7
Style fixes that make things harder to read
mmcleod89 Sep 30, 2024
39bb9e5
Making horribly reformatted code readable again
mmcleod89 Oct 1, 2024
cb1b86e
Add recent LTP status
mmcleod89 Oct 2, 2024
69b7668
Reorganising HIV module
mmcleod89 Oct 3, 2024
02077b3
Refactoring repeated diagnosis & ART logic
mmcleod89 Oct 3, 2024
3b63b9d
New LTP ART and fixing format bug!
mmcleod89 Oct 3, 2024
5caa9c8
refactor LTP viral suppression
mmcleod89 Oct 3, 2024
eb62e6c
Formatting and increase max line length
mmcleod89 Oct 3, 2024
50fb402
Create general HIV stats update function
mmcleod89 Oct 3, 2024
9272596
Call general stats update from HIV update func
mmcleod89 Oct 3, 2024
b9f6570
style fix
mmcleod89 Oct 3, 2024
c516686
Fix divide by zero errors
mmcleod89 Oct 3, 2024
3e42c5f
Style
mmcleod89 Oct 3, 2024
daf10b6
Update src/hivpy/column_names.py
mmcleod89 Oct 7, 2024
cf9ed29
Update src/hivpy/hiv_status.py
mmcleod89 Oct 7, 2024
7a80d1b
Recent partner status, diagnosis, and ART
mmcleod89 Oct 7, 2024
916666b
refactor/rename; add ltp HIV to evolve
mmcleod89 Oct 7, 2024
194ef7d
Make viral suppression prob class property
mmcleod89 Oct 7, 2024
821c2e4
prob continue ART now class variable
mmcleod89 Oct 7, 2024
046b526
initialisation error
mmcleod89 Oct 7, 2024
0ce1f01
style
mmcleod89 Oct 7, 2024
0806185
Fix prevalence age group indexing
mmcleod89 Oct 7, 2024
617226c
Rewrite tests and some refactoring to clarify tests
mmcleod89 Nov 12, 2024
00f0400
Fix assertion syntax
mmcleod89 Nov 12, 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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ console_scripts =
run_model = hivpy.cli:run_model

[flake8]
max-line-length = 120
max-line-length = 150
per-file-ignores =
# Don't complain about unused imports in __init__.py
*/__init__.py: F401
Expand Down
2 changes: 1 addition & 1 deletion src/hivpy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import yaml

from .experiment import create_experiment, run_experiment
from hivpy.experiment import create_experiment, run_experiment


def run_model():
Expand Down
18 changes: 17 additions & 1 deletion src/hivpy/column_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
RISK_DIAGNOSIS = "risk_diagnosis" # float: risk associated with recent HIV diagnosis
RISK_PERSONAL = "risk_personal" # float: individual risk reduction applied with a certain probability
RISK_LTP = "risk_long_term_partnered" # float: risk reduction for people in long term partnerships
RISK_LTP_INFECTED = "risk_ltp_infected" # float: risk of infection from infected long term partner
RISK_ART_ADHERENCE = "risk_art_adherence" # float: risk reduction associated with low ART adherence
RISK_INITIAL = "risk_initial" # float: initial risk reduction factor
CIRCUMCISED = "circumcised" # bool: True if a man is circumcised
Expand All @@ -27,10 +28,18 @@
SEX_BEHAVIOUR = "sex_behaviour" # int: sexual behaviour grouping
SEX_BEHAVIOUR_CLASS = "sex_class" # sexual_behaviour.SexBehaviourClass(enum): Men, Young Women, Older Women, or Sex Workers
LONG_TERM_PARTNER = "long_term_partner" # bool: True if the subject has a long term condomless partner
LTP_NEW = "ltp_new" # bool: True if condomless sex with ltp is new this timestep
LTP_LONGEVITY = "ltp_longevity" # int: categorises longevity of long term partnerships (higher => more stable)
LTP_HIV_STATUS = "ltp_HIV_status" # bool: True if an individual's long term partner is infected with HIV (DUMMY)
LTP_HIV_DIAGNOSED = "ltp_HIV_diagnosed" # bool: True if an individual's long term partner is diagnosed with HIV (DUMMY)
LTP_ON_ART = "ltp_on_art" # bool: True if an individual's long term partner is on ART (DUMMY)
LTP_MONOGAMOUS = "ltp_monogamous" # bool: True if a person's long term partner has no short term partners o/w False
LTP_INFECTION_DATE = "ltp_infection_date" # date: date at which the long term partner gets infected o/w None if not infected
LTP_DIAGNOSED = "ltp_diagnosed" # bool: True if a person's long term partner has been diagnosed, o/w False
RECENT_LTP_DIAGNOSED = "recent_ltp_diagnosed" # bool: True if a person's most recent long term partner was diagnosed
RECENT_LTP_ART = "recent_ltp_art" # bool: True if a person's most recent long term partner was on ART
LTP_ART = "ltp_art" # bool: True if a person's long term partner is on ART
LTP_VIRAL_SUPPRESSED = "ltp_viral_suppressed" # bool: True if a person's long term partner is virally suppressed
LOW_FERTILITY = "low_fertility" # bool: True if a woman is considered to have a 0% chance of pregnancy, o/w False
PREGNANT = "pregnant" # bool: True if a woman is currently pregnant
LAST_PREGNANCY_DATE = "last_pregnancy_date" # None | datetime.date: date of most recent pregnancy, o/w None if never pregnant
Expand All @@ -41,6 +50,8 @@
NUM_HIV_CHILDREN = "num_HIV_children" # int: number of children infected with HIV a woman has
WANT_NO_CHILDREN = "want_no_children" # bool: True if a woman does not want any more children

ON_ART = "on_art" # bool: True if a person is currently on ART

SEX_WORKER = "sex_worker" # bool: True if person is a sex worker, o/w False
SW_AGE_GROUP = "sw_age_group" # int: categorises sex worker behaviour by age
DATE_STOP_SW = "date_stop_sex_work" # date: date at which a former sex worker (last) stopped sex work
Expand All @@ -62,14 +73,19 @@
NSTP_LAST_TEST = "nstp_last_test" # int: number of short term condomless sex partners since last test (DUMMY)
NP_LAST_TEST = "np_last_test" # int: total number of condomless sex partners since last test (DUMMY)
HIV_STATUS = "HIV_status" # bool: True if person is HIV positive, o/w False
LTP_STATUS = "LTP_status" # bool: True if long term partner is HIV positive, o/w False
RECENT_LTP_STATUS = "recent_LTP_status" # bool: True if the most recent long term partner was HIV positive
DATE_HIV_INFECTION = "date_HIV_infection" # None | date: date of HIV infection if HIV+, o/w None
IN_PRIMARY_INFECTION = "in_primary_infection" # bool: True if a person contracted HIV within 3 months of the current date, o/w False
HIV_INFECTION_GE6M = "HIV_infection_ge6m" # bool: True is a person has been infected with HIV for 6 months or more (DUMMY)
LTP_IN_PRIMARY = "ltp_in_primary" # bool: True if a person's long term partner is in primary infection
HIV_DIAGNOSED = "HIV_diagnosed" # bool: True if individual had a positive HIV test
HIV_DIAGNOSIS_DATE = "HIV_Diagnosis_Date" # None | datetime.date: date of HIV diagnosis (to nearest timestep) if HIV+, o/w None
VIRAL_LOAD_GROUP = "viral_load_group" # int: value 0-5 placing bounds on viral load for an HIV positive person. [(0, 2.7), (2.7, 3.7), (3.7, 4.7), (4.7, 5.7), > 5.7, primary infection]
UNDER_CARE = "under_care" # bool: True if under care after a positive HIV diagnosis
VIRAL_LOAD_GROUP = "viral_load_group" # int: value 0-5 placing bounds on viral load for an HIV positive person
VIRAL_LOAD = "viral_load" # float: viral load for HIV+ person
VIRAL_SUPPRESSION = "viral suppression" # bool: True if person is virally suppressed
RESISTANCE_MUTATIONS = "resistance_mutations" # integer: total proportion of (people in?) resistance mutations
CD4 = "cd4" # None | float: CD4 count per cubic millimeter; set to None for people w/o HIV
MAX_CD4 = "max_cd4" # float: maximum CD4 count to which a person can return when on ART
ART_NAIVE = "art_naive" # bool: True if person has never been on antiretroviral therapy
Expand Down
14 changes: 14 additions & 0 deletions src/hivpy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ def opposite_sex(sex: SexType):
return (1 - sex)


def sub_pop_ratio(sp1, sp2):
if len(sp2) == 0:
return 0
else:
return len(sp1) / len(sp2)


def safe_ratio(n1, n2):
if n2 == 0:
return 0
else:
return n1/n2


class date:
def __init__(self, year, month=1, day=1):
self.year = year
Expand Down
Loading
Loading