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 #34 function for growth parameters for height/length #45

Merged
merged 22 commits into from
Jun 17, 2024

Conversation

zdz2101
Copy link
Collaborator

@zdz2101 zdz2101 commented May 30, 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?
  • 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 # admiralpeds (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)
  • Build admiralpeds 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!

Copy link

github-actions bot commented May 30, 2024

Code Coverage

Package Line Rate Health
admiralpeds 71%
Summary 71% (88 / 124)

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.

@zdz2101 i focused my review on the documentation and trust @kabis-ops and others to check the function code. and we can add more unit tests later as per the plan for the other function.

R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
@@ -93,14 +92,13 @@
#' advs <- dm_peds %>%
#' select(USUBJID, BRTHDTC, SEX) %>%
#' right_join(., vs_peds, by = "USUBJID") %>%
#' filter(USUBJID != "PEDS-1010") %>%
#' mutate(
#' VSDT = ymd(VSDTC),
#' BRTHDT = ymd(BRTHDTC)
#' ) %>%
#' derive_vars_duration(
Copy link
Collaborator

Choose a reason for hiding this comment

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

trunc_out = FALSE can be removed as its default anyway for this function - to simplify the example

@@ -93,14 +92,13 @@
#' advs <- dm_peds %>%
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add comments to this example please? as its quite a lot for users to follow with so much pre-processing before we even get to the example function call

Copy link
Contributor

@Fanny-Gautier Fanny-Gautier left a comment

Choose a reason for hiding this comment

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

looks like I didn't push my comments... sorry for the delay

R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
R/derive_params_growth_height.R Outdated Show resolved Hide resolved
#' The CDC/WHO growth chart metadata datasets are available in the package and will
#' require small modifications.
#' * `HEIGHT` - Height/Length
#' * `HEIGHTU` - Height Unit
Copy link
Contributor

Choose a reason for hiding this comment

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

HEIGHTU - Height/Length Unit instead of only Height unit. I think that the name is confusing when length is selected

#' parameter = VSTESTCD == "WEIGHT",
#' analysis_var = VSSTRESN,
#' set_values_to_sds = exprs(
#' PARAMCD = "WTASDS",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be PARAMCD = "WTHSDS"?

#' )
#'
#'
#' derive_params_growth_height(
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is patient 01-701-1033 gone ? While running this code I don't have any records created for patient 01-701-1033. Could you please clarify the reason ? thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

patient should be in there, at least showing on my end

#' right_join(., heights, by = c("USUBJID", "VSDTC"))
#'
#' advs_under2 <- advs %>%
#' filter(AGECUR_M <= 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you select patients under 2 months only ? should it not be 24 months to consider 2 years ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

my mistake this was fixed

#' filter(AGECUR_M <= 2)
#'
#' advs_over2 <- advs %>%
#' filter(AGECUR_M > 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you select patients over 2 months only ? should it not be 24 months to consider 2 years ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see above

#' Derive Anthropometric indicators (Z-Scores/Percentiles-for-Age) based on Standard Growth Charts
#' for Weight/BMI/Head Circumference by Height/Length
#'
#' @param dataset Input dataset
Copy link
Contributor

Choose a reason for hiding this comment

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

In the template we selected the records from the metadata where MEASURE ="LENGTH" for patients <730.5 days, and MEASURE="HEIGHT" for patients >=730.5 days. As Zelos mentioned, it will require additional variables to merge the right data depending on the age.
We also added message in the ADVS peds template for the same message("To derive height/length parameters, below function needs to call separately for Height and Length based on the input data and current age of the patient, as it depends on your CRF guidelines.").
I think it is easier to split it because if the user has only HEIGHT then there is only one call, similarly for LENGTH. But if the user has both LENGTH and HEIGHT in the data, it will complexify the merge. I think the user has more flexibility while splitting the derivation.

#' * `M` - Median
#' * `S` - Coefficient of variation
#'
#' @param parameter Anthropometric measurement parameter to calculate z-score or percentile
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we include a reminder that the expected unit of weight is kg?

#'
#' The dataset can be derived from WHO or user-defined datasets.
#' The WHO growth chart metadata datasets are available in the package and will
#' require small modifications.
Copy link
Contributor

Choose a reason for hiding this comment

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

The original WHO metadata table has height/length increment of 0.5, but the metadata in the admiralpeds packages has increment of 0.1. How was it extrapolated? Do we have any documentation on that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

https://www.who.int/tools/child-growth-standards/standards/weight-for-length-height

scroll to the bottom on the expanded tables section you will find the increments were by 0.1

#' `HEIGHT_LENGTH`, `HEIGHT_LENGTHU`, `SEX`, `L`, `M`, `S`
#'
#' The dataset can be derived from WHO or user-defined datasets.
#' The WHO growth chart metadata datasets are available in the package and will
Copy link
Contributor

@Minlei0201 Minlei0201 Jun 11, 2024

Choose a reason for hiding this comment

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

Shall we list out the names of the metadata and clarify that "who_wt_for_lgth_boys" and "who_wt_for_lgth_girls" are for subjects with age <730.5 days, and "who_wt_for_ht_boys" and "who_wt_for_ht_girls" are for those with age>=730.5 days? By doing this, the user knows the metadata he/she can use, and also knows to apply different metadata based on subjects' age.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a good idea, but I think we'll need to draw up a bigger vignette/article for metadata creation/preprocessing anyway

Copy link
Collaborator

Choose a reason for hiding this comment

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

hopefully the template and vignette can cover this more so user gets the full context

#' PARAMCD = "WTHPCTL",
#' PARAM = "Weight-for-height percentile"
#' )
#' )
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we include codes to bind rows of advs_under2 and advs_over2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense just for the sake of completing the example

#' new_var_unit = AAGECURU,
#' start_date = BRTHDT,
#' end_date = VSDT,
#' out_unit = "months"
Copy link
Contributor

Choose a reason for hiding this comment

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

In the ad_advs.R template (PR #32 ), the unit of age is days (with 730.5 days as cutoff). Shall we be consistent in the example here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I will fix this

@Minlei0201
Copy link
Contributor

Hi @zdz2101 , I've added a few comments on the PR (on the derive_params_growth_height.R). Feel free to take a look and let me know if you have any follow-up questions!

#' PARAM = "Weight-for-height z-score"
#' ),
#' set_values_to_pctl = exprs(
#' PARAMCD = "WTHPCTL",
Copy link
Contributor

Choose a reason for hiding this comment

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

@zdz2101 please modify the PARAMCD to WGTHSDS/WGTHPCTL to be consistent with the ADVS template. Same changes are required for derive_params_by_age() function as well.
image
image

@@ -0,0 +1,41 @@
# derive_params_growth_heightlength ----

## Test 1: derive_params_growth_heightlength works ----
Copy link
Contributor

Choose a reason for hiding this comment

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

Some outliers data to be added

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Additional testing will be handled in #50 #51

Copy link
Contributor

@Fanny-Gautier Fanny-Gautier left a comment

Choose a reason for hiding this comment

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

Minor comments added

@rossfarrugia rossfarrugia merged commit a33f415 into main Jun 17, 2024
15 of 16 checks passed
@rossfarrugia rossfarrugia deleted the 34_new_func_lengthheight branch June 17, 2024 08:26
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.

New function: derive_params_growth_height - for BY LENGTH/HEIGHT growth parameters
5 participants