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

Bug: AUC start 0 (which also needs Feature: C0 imputation) #138

Open
wants to merge 60 commits into
base: main
Choose a base branch
from

Conversation

Gero1999
Copy link
Collaborator

@Gero1999 Gero1999 commented Nov 27, 2024

Issue

Closes #2 #60

Description

After running NCA, AUC calculations always consider the discrete start (start at where first concentration sample was collected). This can indeed alter slightly the real values of the AUC. This is a consequence of 2 problems:

  1. Doses times are being considered at the first measure, instead of at the real dose time
  2. No imputed measure at dose time is consdiered

Change description.

Definition of Done

C0 imputation option for the user specified in Setup > Data Selection

How to test

  • At "NCA">"NCA Results", when C0 is imputed it is expected that start=AFRLT-ARRLT (being AFRLT-ARRLT= 0 in DOSNO=1)
  • At "NCA">"NCA Results", when C0 is not imputed it is expected that start={time of 1st observation}
  • AUC values (auclast, aucinf...) from start=AFRLT-ARRLT are calculated when C0 is imputed
  • All variables that should only be based on observed data (cmax, tmax...) are not considering C0 imputations
  • Test that PKNCA also deals well with predoses as duplicates for the NCA
  • Check slope selector plots and NCA results remain well after running NCA
  • Check if in general C0 imputation logic works well (NCA experts):
    if C0 exists ~ C0=C0
    if DOSNO=1 & IV bolus (ADOSEDUR=0, ROUTE=intravascular) ~ C0=0
    if DOSNO>1 & not IV bolus ~ C0=predose
    if IV bolus and monoexponential data ~ logslope
    if IV bolus and not monoexponential data ~ C0=C1

Contributor checklist

  • Code passes lintr checks
  • Code passes all unit tests
  • New logic covered by unit tests
  • New logic is documented

Notes to reviewer

Anything that the reviewer should know before tacking the pull request?

@Gero1999 Gero1999 marked this pull request as draft November 28, 2024 09:37
Merge remote-tracking branch 'origin/main' into bug/auc-start-0

# Conflicts:
#	inst/shiny/tabs/nca.R
#	inst/shiny/tabs/outputs.R
@Gero1999 Gero1999 requested a review from js3110 December 9, 2024 11:18
Copy link
Collaborator

@m-kolomanski m-kolomanski left a comment

Choose a reason for hiding this comment

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

Hey,

Are the diffs displayed by github accurate? Seems like a lengthy change, are there any artifacts/errors that happened due to merge (it did happen to me on occasions)? If the diffs are inaccurate, please point out the actual changes and disregard the below.

I do not have the time to do a detailed review (it is quite a lengthy change), but after a quick look there is some general things I want to point out:

  1. Please do not any files that solely generate UI to the /R folder - this is a folder for our logic. File partial_auc_input belongs in the inst/shiny folder, either in /modules (if there is any server logic attached, here it isnt, but might be added) or folder like functions. We can also create a new folder for UI elements, called ui or elements or widgets or whatever you find suitable.
  2. If you are creating new files or adding new functions in the /R folder, please make sure that this logic is testable and do take some effort to write at least basic unit tests. Adding tests back to existing logic is tough and time consuming, so we should at least make sure that our testing suite keeps up with any new features or major changes to the old ones.

@js3110 js3110 mentioned this pull request Dec 18, 2024
5 tasks
Merge branch 'main' into bug/auc-start-0
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
Merge branch 'main' into bug/auc-start-0

# Conflicts:
#	inst/shiny/tabs/outputs.R
@Gero1999
Copy link
Collaborator Author

Gero1999 commented Jan 2, 2025

Hey,

Are the diffs displayed by github accurate? Seems like a lengthy change, are there any artifacts/errors that happened due to merge (it did happen to me on occasions)? If the diffs are inaccurate, please point out the actual changes and disregard the below.

I do not have the time to do a detailed review (it is quite a lengthy change), but after a quick look there is some general things I want to point out:

  1. Please do not any files that solely generate UI to the /R folder - this is a folder for our logic. File partial_auc_input belongs in the inst/shiny folder, either in /modules (if there is any server logic attached, here it isnt, but might be added) or folder like functions. We can also create a new folder for UI elements, called ui or elements or widgets or whatever you find suitable.
  2. If you are creating new files or adding new functions in the /R folder, please make sure that this logic is testable and do take some effort to write at least basic unit tests. Adding tests back to existing logic is tough and time consuming, so we should at least make sure that our testing suite keeps up with any new features or major changes to the old ones.

Hello and happy new year @m-kolomanski !

You are right, this is a very lengthy change but I re checked and everything was intentional. Most of them are new created manuals for each function. As requested I also:

  1. Deleted the extra UI function from \R
  2. Added tests for all functions called in format_data,R, create_start_impute and PKNCA_impute_method_additions

Don't hesitate to let me know if there is anything else I can do or if there are other concerns that I can address! I also asked @js3110 for re-review to make sure all looks as expected.

Copy link
Collaborator

@js3110 js3110 left a comment

Choose a reason for hiding this comment

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

LGTM

@Gero1999 Gero1999 requested a review from m-kolomanski January 2, 2025 12:23
Copy link
Collaborator

@m-kolomanski m-kolomanski left a comment

Choose a reason for hiding this comment

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

Hey, happy new year to you too and thank you for all the hard work!

I have to request some changes and have some suggestions/nitpicks to consider. I know that some of my comments refer to lines that were not changed in this PR, but since we are working on those functions I think it would be beneficial to go back and improve the code, even if it is not directly related to the changes.

R/PKNCA_impute_method_additions.R Show resolved Hide resolved
R/PKNCA_impute_method_additions.R Outdated Show resolved Hide resolved
R/PKNCA_impute_method_additions.R Outdated Show resolved Hide resolved

PKNCA_impute_method_start_log <- function(conc, time, start, end, ..., options = list()) { # nolint

ret <- data.frame(conc = conc, time = time)
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: What is ret in this context? Might I suggest a more descriptive name for the variable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I asked Bill because I actually followed his syntax from the other parallel functions. Apparently is from the word return (of the function). But I will change it to something more intuitive now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I put d_conc_time, hope that makes more sense!

R/PKNCA_impute_method_additions.R Outdated Show resolved Hide resolved
tests/testthat/test-format_data.R Outdated Show resolved Hide resolved
tests/testthat/test-format_data.R Outdated Show resolved Hide resolved
tests/testthat/test-format_data.R Outdated Show resolved Hide resolved
tests/testthat/test-format_data.R Outdated Show resolved Hide resolved
R/format_data.R Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants