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

Long-term partner infection #186

merged 44 commits into from
Nov 14, 2024

Conversation

dimitrasal
Copy link
Collaborator

No description provided.

@dimitrasal
Copy link
Collaborator Author

Hi @mmcleod89 there is still quite a bit of work to finish this up but if you could have a look and let me know what you think, that would be great!

@dimitrasal dimitrasal changed the title Monogamous and non-monogamous long-term partner infection Long-term partner infection Jul 4, 2024
src/hivpy/hiv_status.py Outdated Show resolved Hide resolved
subgroup)

people_with_ltp = population.get_sub_pop([(col.LONG_TERM_PARTNER, op.eq, True)])
population.transform_group([col.VIRAL_SUPPRESSION, col.LTP_STATUS],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of col.LTP_STATUS we might want to use a LTP_INFECTION_DATE or something similar to track whether someone is in primary infection.

In general we don't want to transform_group by dates so we can have bool column LTP_PRIMARY_INFECTION which before transform_group is set by LTP_PRIMARY_INFECTION = LTP_INFECTION_DATE < (date - length of primary)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmcleod89 thanks, following your suggestions I transformed this to ltp_primary_infection = ltp_infection_date > (population.date - timedelta(days=90)) assuming that 90 days is the timestep length in agreement with current timestep of ca.3 months in SAS.

src/hivpy/hiv_status.py Outdated Show resolved Hide resolved
src/hivpy/hiv_status.py Outdated Show resolved Hide resolved
Comment on lines 622 to 646
def prob_of_new_ltp_already_infected(self, population: Population):
for sex in [SexType.Male, SexType.Female]:
for age_group in range(5):
opposite_sex = population.get_sub_pop([(col.SEX, op.ne, sex),
(col.AGE_GROUP, op.eq, age_group)])
opposite_sex_with_hiv = population.get_sub_pop([(col.SEX, op.ne, sex),
(col.AGE_GROUP, op.eq, age_group),
(col.HIV_STATUS, op.eq, True)])

if len(opposite_sex) != 0:
self.prevalence[sex][age_group] = len(opposite_sex_with_hiv) / len(opposite_sex)

def calculate_new_ltp_infection(sex, age_group, size):
infected = (rng.uniform(0, 1, size) < 0.5) | (rng.uniform(0, 1, size) <
self.prevalence[sex][age_group])
return infected

people_with_new_ltp = population.get_sub_pop([(col.LTP_NEW, op.eq, True)])

new_ltp_infected = population.transform_group([col.SEX, col.AGE_GROUP],
calculate_new_ltp_infection,
use_size=True,
sub_pop=people_with_new_ltp)
population.set_present_variable(col.LTP_STATUS, new_ltp_infected, people_with_new_ltp)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still working on this

Copy link
Collaborator

@pineapple-cat pineapple-cat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of changes to go through here, but I think the general logic looks sound. There are a few typos to fix, variables to add, and some documentation that I would include, but there don't seem to be any glaring issues that I could find.

Don't forget to add ltp HIV transmission to update_HIV_status when it's done.

src/hivpy/column_names.py Outdated Show resolved Hide resolved
src/hivpy/hiv_status.py Outdated Show resolved Hide resolved
src/hivpy/hiv_status.py Outdated Show resolved Hide resolved
src/hivpy/hiv_status.py Outdated Show resolved Hide resolved
Comment on lines 505 to 506
# 3% chance that virally suppressed person becomes un-suppressed
remaining_suppressed = rng.uniform(size=len(viral_suppressed_ltp)) < 0.97
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probability of un-suppression seems like a good idea to turn into a data variable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have put this into a class variable but there isn't an HIV status data file yet so I'd rather create one in a separate PR than make this one bigger

Comment on lines 527 to 528
# 2% chance that LTP on ART go off ART
continuing_ART = rng.uniform(size=len(ltp_on_ART)) < 0.98
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well – this would also be good to turn into a data variable.

src/hivpy/hiv_status.py Show resolved Hide resolved
@mmcleod89 mmcleod89 marked this pull request as ready for review November 12, 2024 01:42
Copy link
Collaborator

@pineapple-cat pineapple-cat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now. The HIV status module has gotten quite big though; when we add resistance we'll have to factor it out into its own module.

@pineapple-cat pineapple-cat merged commit 0319779 into development Nov 14, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants