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

RXR-550: bring 48-hour criteria to KDIGO staging definitions #23

Merged
merged 8 commits into from
Oct 20, 2021

Conversation

karawoo
Copy link
Contributor

@karawoo karawoo commented Oct 19, 2021

Pulls KDIGO logic into its own function so that we can iterate over the timepoints to check that rises of >=0.3 mg/dl happen within a 48 hour window. A few tests needed to be updated based on this logic. We may need to update some tests on the insightrxr side as well, I haven't checked those yet.

While working on this I also found that we had a bug if age was NULL here:

dat$stage[dat$scr / baseline_scr >= 3 | dat$scr >= 4 | (dat$egfr < 35 & age < 18)] <- 3

That line would evaluate to logical(0), even if the other criteria (i.e. scr >= 4) were met. That is also fixed in this branch, and a new test has been added for it.

Please do pay close attention to the logic here. I think I captured the 48 hour restriction, but after all of our discussion I want to make extra sure that we've got this right.

Rise of 0.3 mg/dl is considered an AKI *if* it occurs within a 48-hour period
Age isn't required if egfr is provided, but then if we don't use `isTRUE()` then
that conditional has length 0. Adds test for fixed age behavior -- previously if age was NULL this would return a stage of NA which was incorrect
Copy link
Contributor

@jasmineirx jasmineirx left a comment

Choose a reason for hiding this comment

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

a couple minor suggestions, otherwise approach lgtm

R/calc_aki_stage.R Outdated Show resolved Hide resolved
R/calc_aki_stage.R Outdated Show resolved Hide resolved
R/calc_aki_stage.R Outdated Show resolved Hide resolved
Copy link
Contributor

@jasmineirx jasmineirx left a comment

Choose a reason for hiding this comment

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

lgtm, clean solution to the floating point precision problem.

@jasmineirx
Copy link
Contributor

Looks like CI wants x and y to be documented for %>=%?

@karawoo
Copy link
Contributor Author

karawoo commented Oct 20, 2021

TIL how roxygen translates % when creating a file name 🍇
Screen Shot 2021-10-20 at 9 27 14 AM

Copy link
Contributor

@roninsightrx roninsightrx left a comment

Choose a reason for hiding this comment

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

ok

Comment on lines 222 to 223
# there's a rise to 1.5x baseline*. We only check for the 0.3 mg/dl rise if
# i > 1, since otherwise we don't have any prior timepoints to compare to.
Copy link
Contributor

Choose a reason for hiding this comment

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

just noticed that this comment is now out of date.

Suggested change
# there's a rise to 1.5x baseline*. We only check for the 0.3 mg/dl rise if
# i > 1, since otherwise we don't have any prior timepoints to compare to.
# there's a rise to 1.5x baseline*. We only check for the 0.3 mg/dl rise if
# scr_last_48h contains at last one value, since otherwise we don't have
# any prior timepoints to compare to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 good catch, made the changes locally so I could fix a small typo

#'
#' @param x Numeric vector
#' @param y Numeric vector
`%>=%` <- function(x, y) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thought: do we want to use this in non-clinPK package to address floating point precision issues? Could be useful to have this in irxtools

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that might be useful, but irxtools is currently private and clinPK is public, so if clinPK is going to take on that dependency we'd need to make irxtools public as well. That seemed like a bigger discussion, maybe we can revisit it separately? It wouldn't be hard to update this later if we do decide to move it to a different package.

Copy link
Contributor

@dominic-irx dominic-irx left a comment

Choose a reason for hiding this comment

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

lgtm!

@karawoo karawoo merged commit 56814d2 into master Oct 20, 2021
@karawoo karawoo deleted the RXR-550 branch October 20, 2021 17:50
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.

None yet

4 participants