Skip to content

Commit

Permalink
Merge pull request #28 from lshtm-gigs/dev
Browse files Browse the repository at this point in the history
gigs 0.4.1
  • Loading branch information
simpar1471 authored Feb 7, 2024
2 parents f6b04c1 + d98f507 commit a9d9654
Show file tree
Hide file tree
Showing 35 changed files with 552 additions and 345 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/update-citation-cff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# The action runs when:
# - A new release is published
# - The DESCRIPTION or inst/CITATION are modified
# - Can be run manually
# For customizing the triggers, visit https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
release:
types: [published]
push:
branches: [master, main]
paths:
- DESCRIPTION
- inst/CITATION
workflow_dispatch:

name: Update CITATION.cff

jobs:
update-citation-cff:
runs-on: macos-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::cffr
any::V8
- name: Update CITATION.cff
run: |
library(cffr)
# Customize with your own code
# See https://docs.ropensci.org/cffr/articles/cffr.html
# Create your CITATION.cff file
cff_write()
shell: Rscript {0}

- name: Commit results
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add CITATION.cff
git commit -m 'Update CITATION.cff' || echo "No changes to commit"
git push origin || echo "No changes to commit"
8 changes: 4 additions & 4 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ cff-version: 1.2.0
message: 'To cite package "gigs" in publications use:'
type: software
license: GPL-3.0-or-later
title: 'gigs: Assess Fetal, Newborn, and Child Growth'
version: 0.4.0
title: 'gigs: Assess Fetal, Newborn, and Child Growth with International Standards'
version: 0.4.1
abstract: Convert between anthropometric measures and z-scores/centiles in multiple
growth standards, and classify fetal, newborn, and child growth accordingly. With
a simple interface to growth standards from the World Health Organisation and International
Expand All @@ -21,14 +21,14 @@ authors:
orcid: https://orcid.org/0009-0003-8214-4496
preferred-citation:
type: manual
title: 'gigs: Assess Growth in Infants and Newborns'
title: 'gigs: Assess Fetal, Newborn, and Child Growth with International Standards'
authors:
- family-names: Parker
given-names: Simon
email: [email protected]
orcid: https://orcid.org/0009-0003-8214-4496
year: '2023'
notes: 0.4.0
notes: 0.4.1
url: https://github.com/lshtm-gigs/gigs/
repository-code: https://github.com/lshtm-gigs/gigs
url: https://github.com/lshtm-gigs/gigs/
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: gigs
Title: Assess Fetal, Newborn, and Child Growth
Version: 0.4.0
Title: Assess Fetal, Newborn, and Child Growth with International Standards
Version: 0.4.1
Authors@R: c(
person(given = "Simon", family = "Parker",
email = "[email protected]",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# gigs 0.4.1

* Changes to documentation to facilitate `autotest::autotest_package()` pass.
* Minor changes to vignettes for new patched version.

# gigs 0.4.0

* **BREAKING CHANGES:**
Expand Down
56 changes: 29 additions & 27 deletions R/classification.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,27 @@
#' behaviour can be customised using the functions in [gigs_options].
#' @param severe A single logical value specifying whether to categorise SGA
#' values are below the third centile as `"SGA(<3)"`. Default = `FALSE`.
#' @return Factor the same length as the longest input vector, with
#' size-for-gestational age classification(s). If `severe = FALSE`, levels are
#' `c("SGA", "AGA", "LGA")`. If `severe = TRUE`, levels are `c("SGA(<3)",
#' "SGA", "AGA", "LGA")`.
#' @returns An object of class factor with the same length as the longest input
#' vector, containing size-for-GA classifications. If `severe = FALSE`, levels
#' are `c("SGA", "AGA", "LGA")`. If `severe = TRUE`, levels are `c("SGA(<3)",
#' "SGA", "AGA", "LGA")`.
#' @note Input vectors are recycled by [vctrs::vec_recycle_common()], and must
#' adhere to the [vctrs] recycling rules.
#' @seealso [ig_nbs_wfga_value2centile()], which this function calls to get
#' centiles for each observation.
#' @examples
#' # Without severe flag, does not differentiate between
#' # p < 0.03 and p < 0.10
#' # By default, does not differentiate between p < 0.03 and p < 0.10
#' classify_sfga(
#' weight_kg = c(2.2, 3.4, 4.2),
#' gest_days = 267,
#' sex = "M"
#' weight_kg = c(2.2, 3.3, 4.2),
#' gest_days = 267:269,
#' sex = c("M", "F", "M")
#' )
#'
#' # With severe = TRUE, highlights p < 0.03
#' classify_sfga(
#' weight_kg = c(2.2, 3.4, 4.2),
#' gest_days = 267,
#' sex = "M",
#' weight_kg = c(2.2, 3.3, 4.2),
#' gest_days = 267:269,
#' sex = c("M", "F", "M"),
#' severe = TRUE
#' )
#' @references
Expand Down Expand Up @@ -77,8 +76,9 @@ classify_sfga <- function(weight_kg, gest_days, sex, severe = FALSE) {
#' newborns according to their SVN type, for use in downstream analyses.
#'
#' @inherit classify_sfga params note
#' @return Factor with small vulnerable newborn classification(s), with levels
#' `c("Preterm SGA", "Preterm AGA", "Preterm LGA", "Term SGA", "Term AGA",
#' @returns An object of class factor with the same length as the longest input
#' vector, containing small vulnerable newborn classifications. Its levels
#' are `c("Preterm SGA", "Preterm AGA", "Preterm LGA", "Term SGA", "Term AGA",
#' "Term LGA")`.
#' @examples
#' classify_svn(
Expand Down Expand Up @@ -132,10 +132,11 @@ classify_svn <- function(weight_kg, gest_days, sex) {
#' @param gest_days Numeric vector with gestational age(s) at birth in days.
#' @param outliers A single `TRUE` or `FALSE` value specifying whether
#' implausible z-score value thresholds should be applied. Default = `FALSE`.
#' @return Factor of stunting classification(s) with same length as longest
#' input vector. Levels are `c("stunting_severe", "stunting", "not_stunting")`
#' if `outliers = FALSE`, else `c("stunting_severe", "stunting",
#' "not_stunting", "outlier")`.
#' @returns An object of class factor with the same length as the longest input
#' vector, containing stunting classifications. Its levels are
#' `c("stunting_severe", "stunting", "not_stunting")` if `outliers = FALSE`
#' (the default), else `c("stunting_severe", "stunting", "not_stunting",
#' "outlier")`.
#' @note Input vectors are recycled by [vctrs::vec_recycle_common()], and must
#' adhere to the [vctrs] recycling rules. This function assumes that your
#' measurements were taken according to the WHO guidelines, which stipulate
Expand Down Expand Up @@ -200,10 +201,11 @@ classify_stunting <- function(lenht_cm, age_days, gest_days, sex,
#'
#' @inheritParams classify_sfga
#' @inheritParams classify_stunting
#' @return Factor of wasting classifications with same length as longest input.
#' If `outliers = FALSE`, levels are `c("wasting_severe", "wasting",
#' "not_wasting", "overweight")`. If `outliers = TRUE`, levels are
#' `c("wasting_severe", "wasting", "not_wasting", "overweight", "outlier")`.
#' @returns An object of class factor with the same length as the longest input
#' vector, containing wasting classifications. Its levels are
#' `c("wasting_severe", "wasting", "not_wasting", "overweight")` if `outliers
#' = FALSE` (the default), else `c("wasting_severe", "wasting", "not_wasting",
#' "overweight", "outlier")`.
#' @note Input vectors will be recycled by [vctrs::vec_recycle_common()].
#' Implausible z-score bounds are sourced from the referenced WHO report, and
#' classification cut-offs from the DHS manual.
Expand Down Expand Up @@ -256,11 +258,11 @@ classify_wasting <- function(weight_kg, lenht_cm, gest_days, age_days, sex,
#'
#' @inheritParams classify_sfga
#' @inherit classify_stunting params references
#' @return Factor of weight-for-age classifications with same length as longest
#' input. If `outliers = FALSE`, levels are `c("underweight_severe",
#' "underweight", "normal", "overweight")`. If `outliers = TRUE`, levels are
#' `c("underweight_severe", "underweight", "normal", "overweight",
#' "outlier")`.
#' @returns An object of class factor with the same length as the longest input
#' vector, containing weight-for-age classifications. Its levels are
#' `c("underweight_severe", "underweight", "normal", "overweight")` if
#' `outliers = FALSE` (the default), else `c("underweight_severe",
#' "underweight", "normal", "overweight", "outlier")`.
#' @inherit classify_wasting note
#' @examples
#' classify_wfa(
Expand Down
2 changes: 1 addition & 1 deletion R/data.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' gigs: Assess Growth in Infants and Newborns
#' gigs: Assess Fetal, Newborn, and Child Growth with International Standards
#'
#' Convert between anthropometric measures and z-scores/centiles using WHO
#' and INTERGROWTH-21<sup>st</sup> growth standards. This includes functions for
Expand Down
52 changes: 31 additions & 21 deletions R/ig_fet.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,32 +101,37 @@
#' **56(3):359-370** \doi{10.1002/uog.21990}
#' @examples
#' # Convert centiles to values
#' p <- 0.25 # 25th centile
#' ig_fet_centile2value(p = p, x = 280, acronym = "hcfga") |>
#' ig_fet_centile2value(p = c(0.25, 0.5, 0.75), # 25th, 50th, 75th centile
#' x = 279:281,
#' acronym = "hcfga") |>
#' round(digits = 2)
#'
#' # Or z-scores to values
#' z <- qnorm(p)
#' ig_fet_zscore2value(z = z, x = 280, acronym = "hcfga") |>
#' ig_fet_zscore2value(z = qnorm(c(0.25, 0.5, 0.75)),
#' x = 279:281,
#' acronym = "hcfga") |>
#' round(digits = 2)
#'
#' # Specify which standard to use with the acronym parameter...
#' ig_fet_zscore2value(z = z, x = 280, acronym = "acfga") |>
#' ig_fet_zscore2value(z = -1:1,
#' x = 279:281,
#' acronym = "acfga") |>
#' round(digits = 2)
#'
#' # ... or by using a standard-specific function
#' ig_fet_acfga_zscore2value(z = z, gest_days = 280) |>
#' ig_fet_acfga_zscore2value(z = -1:1,
#' gest_days = 279:281) |>
#' round(digits = 2)
#'
#' # Inputs are recycled to the input of the longest length
#' ig_fet_efwfga_zscore2value(z = seq(0.1, 0.9, by = 0.2),
#' gest_days = 280) |>
#' ig_fet_acfga_zscore2value(z = 0,
#' gest_days = 279:281) |>
#' round(digits = 2)
#'
#' # Bad inputs will not stop the function but will instead return NA - here 91
#' # days for gest_days is outside the bounds of the INTERGROWTH-21st Fetal
#' # Growth standard for head circumference-for-GA
#' ig_fet_hcfga_zscore2value(z = z, gest_days = c(91, 98, 224, 266)) |>
#' # Bad inputs will not stop the function but will instead produce `NA`s in the
#' # output - by default gigs will issue useful warnings
#' ig_fet_hcfga_centile2value(p = c(-0.5, 0.15, 0.5, 0.85),
#' gest_days = c(91, 98, 224, NA)) |>
#' round(digits = 2)
#' @rdname ig_fet_zscore2value
#' @export
Expand Down Expand Up @@ -632,31 +637,36 @@ ig_fet_cmfga_centile2value <- function(p, gest_days) {
#' @inherit shared_value2zscore_returns return
#' @examples
#' # Convert values to centiles
#' y <- 335
#' ig_fet_value2centile(y = y, x = 280, acronym = "hcfga") |>
#' ig_fet_value2centile(y = 335:345,
#' x = 260:270,
#' acronym = "hcfga") |>
#' round(digits = 2)
#'
#' # Or values to z-scores
#' ig_fet_value2zscore(y = y, x = 280, acronym = "hcfga") |>
#' ig_fet_value2zscore(y = 335:345,
#' x = 260:270,
#' acronym = "hcfga") |>
#' round(digits = 2)
#'
#' # Specify which standard to use with the acronym parameter...
#' ig_fet_value2zscore(y = 340, x = 280, acronym = "acfga") |>
#' ig_fet_value2zscore(y = 335:345,
#' x = 260:270,
#' acronym = "acfga") |>
#' round(digits = 2)
#'
#' # ... or by using a standard-specific function
#' ig_fet_acfga_value2zscore(abdocirc_mm = 340, gest_days = 280) |>
#' ig_fet_acfga_value2zscore(abdocirc_mm = 335:345,
#' gest_days = 260:270) |>
#' round(digits = 2)
#'
#' # Inputs are recycled to the input of the longest length
#' ig_fet_efwfga_value2zscore(efw_g = seq(3200, 3500, by = 50),
#' gest_days = 280) |>
#' round(digits = 2)
#'
#' # Bad inputs will not stop the function but will instead return NA - here 90
#' # days for `gest_days` is outside the bounds of the INTERGROWTH-21st Fetal
#' # Growth standards
#' ig_fet_hcfga_value2zscore(headcirc_mm = c(90, 100, 300, 310),
#' # Bad inputs will not stop the function but will instead produce `NA`s in the
#' # output - by default gigs will issue useful warnings
#' ig_fet_hcfga_value2zscore(headcirc_mm = c(90, 100, 300, NaN),
#' gest_days = c(91, 98, 224, 266)) |>
#' round(digits = 2)
#' @rdname ig_fet_value2zscore
Expand Down
19 changes: 12 additions & 7 deletions R/ig_fet_estimation.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
#' @note Inputs are recycled using [vctrs::vec_recycle_common()].
#' @examples
#' # Estimate fetal weight in grams
#' ig_fet_estimate_fetal_weight(abdocirc_mm = 31, headcirc_mm = 26.5)
#' ig_fet_estimate_fetal_weight(abdocirc_mm = 31:33,
#' headcirc_mm = 25:27)
#'
#' # Input vectors are recycled using vctrs::vec_recycle_common
#' ig_fet_estimate_fetal_weight(abdocirc_mm = 25, headcirc_mm = 24:26)
#' ig_fet_estimate_fetal_weight(abdocirc_mm = 25.0,
#' headcirc_mm = 24:26)
#' @returns Numeric vector with estimated fetal weight(s) in g, with the same
#' length as the longest input vector.
#' @seealso Get z-scores/centiles for estimated fetal weights at known
Expand Down Expand Up @@ -67,21 +69,24 @@ ig_fet_estimate_fetal_weight <- function(abdocirc_mm, headcirc_mm) {
#' finally with head circumference alone.
#' @examples
#' # Estimate gestational age in days using crown-rump length (most accurate)
#' ig_fet_estimate_ga(crl_mm = 25)
#' ig_fet_estimate_ga(crl_mm = 40:45)
#'
#' # Estimate gestational age in days using head circumference and femur length
#' # (second-most accurate)
#' ig_fet_estimate_ga(headcirc_mm = 250, femurlen_mm = 55)
#' ig_fet_estimate_ga(headcirc_mm = 250:255, femurlen_mm = 55:60)
#'
#' # Estimate gestational age in days using head circumference only (least
#' # accurate)
#' ig_fet_estimate_ga(headcirc_mm = 250)
#' ig_fet_estimate_ga(headcirc_mm = 250:255)
#'
#' # The function defaults to CRL if available
#' ig_fet_estimate_ga(crl_mm = 25, headcirc_mm = 250, femurlen_mm = 55)
#' ig_fet_estimate_ga(crl_mm = 40:45,
#' headcirc_mm = 250:255,
#' femurlen_mm = 55:60)
#'
#' # Inputs are recycled using [vctrs::vec_recycle_common]
#' ig_fet_estimate_ga(headcirc_mm = 249:251, femurlen_mm = 55)
#' ig_fet_estimate_ga(headcirc_mm = 252,
#' femurlen_mm = 55:60)
#' @returns A numeric vector with estimated gestational ages in days. This
#' vector will have a length equal to the outputs from
#' [vctrs::vec_recycle_common()].
Expand Down
Loading

0 comments on commit a9d9654

Please sign in to comment.