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

closes #2481 bug the result of derive param tte depends on the sort order of the input #2569

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

Conversation

ProfessorP-beep
Copy link
Collaborator

@ProfessorP-beep ProfessorP-beep commented Nov 18, 2024

Thank you for your Pull Request! We have developed this task checklist from the Development Process Guide to help with the final steps of the process. Completing the below tasks helps to ensure our reviewers can maximize their time on your code as well as making sure the admiral codebase remains robust and consistent.

Please check off each taskbox as an acknowledgment that you completed the task or check off that it is not relevant to your Pull Request. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the main branch until you have checked off each task.

  • Place Closes #<insert_issue_number> into the beginning of your Pull Request Title (Use Edit button in top-right if you need to update)
  • Code is formatted according to the tidyverse style guide. Run styler::style_file() to style R and Rmd files
  • Updated relevant unit tests or have written new unit tests, which should consider realistic data scenarios and edge cases, e.g. empty datasets, errors, boundary cases etc. - See Unit Test Guide
  • If you removed/replaced any function and/or function parameters, did you fully follow the deprecation guidance?
  • Review the Cheat Sheet. Make any required updates to it by editing the file inst/cheatsheet/admiral_cheatsheet.pptx and re-upload a PDF and a PNG version of it to the same folder. (The PNG version can be created by taking a screenshot of the PDF version.)
  • Update to all relevant roxygen headers and examples, including keywords and families. Refer to the categorization of functions to tag appropriate keyword/family.
  • Run devtools::document() so all .Rd files in the man folder and the NAMESPACE file in the project root are updated appropriately
  • Address any updates needed for vignettes and/or templates
  • Update NEWS.md under the header # admiral (development version) if the changes pertain to a user-facing function (i.e. it has an @export tag) or documentation aimed at users (rather than developers). A Developer Notes section is available in NEWS.md for tracking developer-facing issues.
  • Build admiral site pkgdown::build_site() and check that all affected examples are displayed correctly and that all new functions occur on the "Reference" page.
  • Address or fix all lintr warnings and errors - lintr::lint_package()
  • Run R CMD check locally and address all errors and warnings - devtools::check()
  • Link the issue in the Development Section on the right hand side.
  • Address all merge conflicts and resolve appropriately
  • Pat yourself on the back for a job well done! Much love to your accomplishment!

…ignal_duplicate_records to derive_param_tte.

Still troubleshooting the test-derive_param_tte script. Failed tests have a "Required variable `AEDECOD` is missing in `dataset`" error.
@ProfessorP-beep
Copy link
Collaborator Author

ProfessorP-beep commented Nov 18, 2024

I'll need to some help reviewing the test scripts I wrote for this change. I haven't written any myself to this degree. I'm also still seeing some errors when I still build_site and document() the package but maybe I implemented the changes incorrectly? @bundfussr @bms63

R/derive_joined.R Outdated Show resolved Hide resolved
Pushing again and confirmed check_type argument is in derive_var_obs_number in derive_joined.R scripts
@bms63
Copy link
Collaborator

bms63 commented Nov 18, 2024

You need to fix this conflict. You might need to accept the updated snapshot

tests/testthat/test-derive_param_tte.R Outdated Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
tests/testthat/test-derive_param_tte.R Outdated Show resolved Hide resolved
tests/testthat/test-derive_param_tte.R Outdated Show resolved Hide resolved
tests/testthat/test-derive_param_tte.R Outdated Show resolved Hide resolved
tests/testthat/test-derive_param_tte.R Outdated Show resolved Hide resolved
ProfessorP-beep and others added 4 commits November 19, 2024 10:54
…om test-derive_param_tte as it was redundant, and ran pharmaverse4devs format test script addin to format testest-derive_param_tte.
…le dataset_adsl and source_datasets by combining them with bind_rows before to address error of AEDECOD missing from the dataset when just calling dataset_adsl. This starts on line 381 of derive_param_tte.R
…sort-order-of-the-input' of https://github.com/pharmaverse/admiral into 2481-bug-the-result-of-derive_param_tte-depends-on-the-sort-order-of-the-input
tests/testthat/test-derive_param_tte.R Outdated Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
…ess failed runs in Test 16 of test-derive_param_tte.

removed signal_duplicate_records() from within derive_param_tte

Still need to troubleshoot errors in test script.
…ote Test 15 and 16 on test-derive_param_tte to deal with update to duplicate warnings within tryCatch and not directly by signal_duplicate_records inside derive_param_tte function.

Accepted snapshots from devtools::check
@ProfessorP-beep
Copy link
Collaborator Author

You need to fix this conflict. You might need to accept the updated snapshot

Hey @bms63 accepted the snapshots and passed the dev tools::check() on my end but it fails when pushed. I noticed in the failure output that the snapshots I accepted didn't seem to go through. Did I miss something?

Copy link
Collaborator

@bms63 bms63 left a comment

Choose a reason for hiding this comment

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

It looks like a different test is falling over
image

R/derive_param_tte.R Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
R/derive_param_tte.R Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
NEWS.md Outdated Show resolved Hide resolved
NEWS.md Outdated Show resolved Hide resolved
NEWS.md Outdated Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Dec 3, 2024

Code Coverage

Package Line Rate Health
admiral 97%
Summary 97% (5092 / 5266)

@ProfessorP-beep ProfessorP-beep requested a review from bms63 December 7, 2024 09:14
NEWS.md Outdated Show resolved Hide resolved
NEWS.md Outdated Show resolved Hide resolved
R/derive_merged.R Outdated Show resolved Hide resolved
R/derive_param_tte.R Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
Comment on lines +658 to +686
warning = function(cnd) {
# Handle warnings
if (grepl("duplicate records", conditionMessage(cnd))) {
cli::cli_warn(c(
"Dataset '{.val {sources[[i]]$dataset_name}}' contains duplicate records.",
"i Duplicates were identified based on variables:
{.val {paste(c(subject_keys, by_vars, source_date_var), collapse = ', ')}}."
))
}
source_dataset %>%
filter_if(sources[[i]]$filter) %>%
arrange(!!!sources[[i]]$order) # Return filtered dataset even if a warning occurred
},
error = function(err) {
cli::cli_abort(c(
"Duplicate records detected during processing.",
"x Duplicate records were found in dataset {.val {sources[[i]]$dataset_name}}.",
"i The duplicates were identified based on the following variables:
{.val {paste(c(subject_keys, by_vars, source_date_var), collapse = ', ')}}.",
"i Consider reviewing your `by_vars` or `order` argument to ensure uniqueness."
))
},
message = function(msg) {
cli::cli_inform(c(
"Processing dataset '{.val {sources[[i]]$dataset_name}}'...",
"i Filter and order criteria: {.val {paste(c(subject_keys, by_vars,
sources[[i]]$order), collapse = ', ')}}."
))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Once #2592 is merged this could be simplified:

      duplicate_records = function(cnd) {
        cnd_funs <- list(message = cli_inform, warning = cli_warn, error = cli_abort)
        cnd_funs[[check_type]](
          paste(
            "Dataset {.val {sources[[i]]$dataset_name}} contains duplicate records with respect to",
            "{.var {cnd$by_vars}}"
          ),
          class = class(cnd))
        cnd_muffle(cnd)
        zap()
      }

tests/testthat/test-derive_param_tte.R Outdated Show resolved Hide resolved
vignettes/bds_tte.Rmd Outdated Show resolved Hide resolved
@rossfarrugia
Copy link
Collaborator

@ProfessorP-beep how's it going with the review updates for this one? I only ask as it impacts updates for our internal admiralroche package that I am assigned to. Hoping this one could merge before the holidays and then I could take care of mine early Jan.

@ProfessorP-beep
Copy link
Collaborator Author

@ProfessorP-beep how's it going with the review updates for this one? I only ask as it impacts updates for our internal admiralroche package that I am assigned to. Hoping this one could merge before the holidays and then I could take care of mine early Jan.

Sorry, making these changes this afternoon.

#' @param order Sort order
#'
#' If the argument is set to a non-null value, for each by group the first or
#' last observation
Copy link
Collaborator

@rossfarrugia rossfarrugia Dec 18, 2024

Choose a reason for hiding this comment

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

@ProfessorP-beep from a user perspective i find this argument description confusing. I'm unclear whether i need to use exprs() like for set_values_to explained above and i don't really understand the description here. I thought it would be worded more something like:

An optional named list returned by exprs() defining additional variables that the input dataset is sorted on after date.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@bundfussr any thoughts on this suggestion? just in case i'm missing anything.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@rossfarrugia , I agree that the description should be updated. I would move the technical details to "Permitted Values". For example

Additional variables that the source dataset is sorted on after date.

Permitted Values: list of variables created by exprs() e.g. exprs(ASEQ)

@rossfarrugia rossfarrugia changed the title 2481 bug the result of derive param tte depends on the sort order of the input closes #2481 bug the result of derive param tte depends on the sort order of the input Dec 20, 2024
Copy link
Collaborator

@rossfarrugia rossfarrugia left a comment

Choose a reason for hiding this comment

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

@ProfessorP-beep thanks for updating for my comments! i spotted a few minor things in the updates

R/derive_param_tte.R Outdated Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
R/derive_param_tte.R Outdated Show resolved Hide resolved
@@ -61,7 +61,7 @@
i Following names were provided by `source_datasets`: "adsl"
i But, `censor_conditions[[1]]$dataset_name = adls`

# list_tte_source_objects Test 14: error is issued if package does not exist
# list_tte_source_objects Test 16: error is issued if package does not exist
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be 17

tests/testthat/test-derive_param_tte.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
Development

Successfully merging this pull request may close these issues.

Bug: The result of derive_param_tte() depends on the sort order of the input
4 participants