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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions R/derive_params_growth_height.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' Derive Anthropometric indicators (Z-Scores/Percentiles-for-Height) based on Standard Growth Charts
#' Derive Anthropometric indicators (Z-Scores/Percentiles-for-Height/Length)
#' based on Standard Growth Charts
#'
#' Derive Anthropometric indicators (Z-Scores/Percentiles-for-Height) based on Standard Growth Charts
#' for Weight by Height/Length
#' Derive Anthropometric indicators (Z-Scores/Percentiles-for-Height/Lenght)
#' based on Standard Growth Charts for Weight by Height/Length
zdz2101 marked this conversation as resolved.
Show resolved Hide resolved
#'
#' @param dataset Input dataset
#'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing parameters from the issue:
age,
age_unit,
height_age,
These are all needed as we need to know at which age to assume height instead of body length but they're optional as: If only ever length or height is used then leave this NULL and just feed in only the corresponding by length or height metadata (instead of the combined version which has both)

I agree measure argument in the issue not needed - as we can add the height temp var to the input dataset

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is so that you use the right metadata from WHO depending on patient age and which way they were likely measuring (height or body length). it'd be good in the examples to use height_age = 730.5 days i.e. 2 years (even as default from what David explained to us?). See https://github.com/pharmaverse/admiralpeds/blob/35_advs_vignette/vignettes/advs.Rmd from line 229 for further explanation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rossfarrugia I think that's why in the example I actually split the dataset into over 2 and under 2 and just ran the function twice, otherwise you would need to create some sort of additional joining variable on both sides, dataset and metadata, which involves additional pre-processing to both datasets, while adding complexity to the function too, the "modularity" of running it twice felt more intuitive to me

I'm open to this adoption with additional arguments, but I wonder what other programmers would think

Copy link
Collaborator

@rossfarrugia rossfarrugia Jun 6, 2024

Choose a reason for hiding this comment

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

@zdz2101 i'm open to your approach - it does give the user complete control still. we'll just need to well comment this to explain our approach in your roxygen2 function documentation example (e.g. at the end you should add a comment to explain that the 2 resulting dataframes would need to be set back together to get the complete ADVS for this parameter) and also we'll need to explain well in our template comments and our vignette.

@Fanny-Gautier @Lina2689 what do you think? as the template authors i would trust your advice here as you'll have a good read on what makes this least complex for users.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

makes sense Fanny, sounds like we have a plan then! and thanks for the other comments here too - looks like me and you picked up similar spots.

Expand All @@ -18,7 +19,7 @@
#'
#' A numeric vector is expected. Note that this is the actual height at the current visit.
#'
#' @param height_unit Lenght/Height Unit
#' @param height_unit Height/Length Unit
#
#' A character vector is expected.
#'
Expand All @@ -29,11 +30,11 @@
#' A metadata dataset with the following expected variables:
#' `HEIGHT_LENGTH`, `HEIGHT_LENGTHU`, `SEX`, `L`, `M`, `S`
#'
#' The dataset can be derived from CDC/WHO or user-defined datasets.
#' The CDC/WHO growth chart metadata datasets are available in the package and will
#' 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

@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

#' * `HEIGHT_LENGTH` - Height/Length
rossfarrugia marked this conversation as resolved.
Show resolved Hide resolved

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_LENGTHU` - Height Unit
#' * `HEIGHT_LENGTHU` - Height/Length Unit
#' * `SEX` - Sex
#' * `L` - Power in the Box-Cox transformation to normality
#' * `M` - Median
Expand Down Expand Up @@ -67,7 +68,7 @@
#'
#' The specified variables are set to the specified values for the new
#' observations. For example,
#' `set_values_to_pctl(exprs(PARAMCD = “WTAPCTL”, PARAM = “Weight-for-height percentile”))`
#' `set_values_to_pctl(exprs(PARAMCD = “WTHPCTL”, PARAM = “Weight-for-height percentile”))`
#' defines the parameter code and parameter.
#'
#' *Permitted Values*: List of variable-value pair
Expand Down Expand Up @@ -101,8 +102,7 @@
#' new_var_unit = AAGECURU,
#' start_date = BRTHDT,
#' end_date = VSDT,
#' out_unit = "months",
#' trunc_out = FALSE
#' out_unit = "months"
#' )

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

#'
#' heights <- vs_peds %>%
Expand Down Expand Up @@ -170,11 +170,11 @@
#' parameter = VSTESTCD == "WEIGHT",
#' analysis_var = VSSTRESN,
#' set_values_to_sds = exprs(
#' PARAMCD = "WTASDS",
#' PARAMCD = "WTHSDS",
#' PARAM = "Weight-for-height z-score"
#' ),
#' set_values_to_pctl = exprs(
#' PARAMCD = "WTAPCTL",
#' 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.

@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

#' )
#' )
Expand All @@ -188,11 +188,11 @@
#' parameter = VSTESTCD == "WEIGHT",
#' analysis_var = VSSTRESN,
#' set_values_to_sds = exprs(
#' PARAMCD = "WTASDS",
#' PARAMCD = "WTHSDS",
#' PARAM = "Weight-for-height z-score"
#' ),
#' set_values_to_pctl = exprs(
#' PARAMCD = "WTAPCTL",
#' PARAMCD = "WTHPCTL",
#' PARAM = "Weight-for-height percentile"
#' )
#' )
Expand Down
28 changes: 14 additions & 14 deletions man/derive_params_growth_height.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading