-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
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! |
src/hivpy/hiv_status.py
Outdated
subgroup) | ||
|
||
people_with_ltp = population.get_sub_pop([(col.LONG_TERM_PARTNER, op.eq, True)]) | ||
population.transform_group([col.VIRAL_SUPPRESSION, col.LTP_STATUS], |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
Add balancing for concordant couples
src/hivpy/hiv_status.py
Outdated
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still working on this
There was a problem hiding this 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/hiv_status.py
Outdated
# 3% chance that virally suppressed person becomes un-suppressed | ||
remaining_suppressed = rng.uniform(size=len(viral_suppressed_ltp)) < 0.97 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/hivpy/hiv_status.py
Outdated
# 2% chance that LTP on ART go off ART | ||
continuing_ART = rng.uniform(size=len(ltp_on_ART)) < 0.98 |
There was a problem hiding this comment.
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.
Co-authored-by: Emily Dubrovska <[email protected]>
Co-authored-by: Emily Dubrovska <[email protected]>
There was a problem hiding this 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.
No description provided.