Skip to contents

This function applies specific functions to generate new clinical indicators. It is designed to work with vectors (e.g., columns of a dataframe).

Usage

leo_new_clinical_indicators(
  df,
  types = c("eGDR", "TyG"),
  type_id = TRUE,
  remove_assist = TRUE,
  remove_other = TRUE,
  ...
)

Arguments

df

A dataframe containing the required columns for calculation.

types

A vector of indicator types, options are "eGDR", "TyG", "eGFR_v2009", "eGFR_v2021", "sleep_score", "LGI"...

type_id

Logical; if FALSE, the function expects semantic column names (e.g. "age", "BMI"). If TRUE (default), UKB field-id style names (e.g. "p21003_i0") are used.

remove_assist

Logical, whether to remove the assisting columns (default TRUE).

remove_other

Logical, whether to keep only eid and the newly generated indicator columns in the returned dataframe (default TRUE). If FALSE, all original columns in df are kept.

...

Additional parameters passed to the specific indicator calculation functions.

Value

A dataframe containing the new clinical indicators.

Details

Supported indicators (use values in types):

  • Basics: age, BMI, gender, ethnicity, ethnicity_finer.

  • Socioeconomic: tdi, education, household_income, household_income_2, career.

  • Kidney function: eGFR_v2009, eGFR_v2021.

  • Inflammation: LGI.

  • Insulin resistance: hba1c, hba1c_percent, eGDR, TyG.

  • Lifestyle: smoking_status, drinking_status, diet_us, physical_activity, sleep_score.

Examples

df <- data.frame(
  eid = 1:3,
  hba1c = c(48, 55, 60),
  waist = c(80, 85, 90),
  hypertension = c(1, 0, 1),
  triglycerides = c(1.5, 1.8, 2.0),
  glucose = c(5.0, 5.5, 6.0)
)
leo.ukb::leo_new_clinical_indicators(df, types = c("eGDR", "TyG"), type_id = FALSE)
#> ── Generating new clinical indicator: eGDR ─────────────────────────────────────
#>  Checking if all required column is valid for eGDR calculation.
#>  Pass for required columns checking.
#>  Calculating the eGDR using the following columns: "hba1c", "waist", and "hypertension"
#>  Converting HbA1c from mmol/mol(IFCC) to %(NGSP) >>> `NGSP=[0.09148*IFCC]+2.152` <https://ngsp.org/ifcc.asp>
#>  HbA1c recoding (IFCC, mmol/mol)
#>  Calculating eGDR using the formula: `eGDR = 21.158 + (-0.09 * waist) + (-3.407 * hypertension) + (-0.551 * hba1c_percent)`
#>  eGDR calculation completed.
#> ── Generating new clinical indicator: TyG ──────────────────────────────────────
#>  Checking if all required column is valid for TyG calculation.
#>  Pass for required columns checking.
#>  Calculating the TyG using the following columns: "triglycerides" and "glucose"
#>  Converting triglycerides and glucose from "mmmol/L" (UKB default unit) to "mg/dL"
#>  Calculating TyG index using the formula: `TyG = ln[(triglycerides * glucose)/2]`
#>  TyG calculation completed.
#> ── All done! ───────────────────────────────────────────────────────────────────
#>  [10:00:43] Elapsed 77 ms
#>   eid     eGDR      TyG
#> 1   1 6.945785 8.696858
#> 2   2 9.549947 8.974490
#> 3   3 5.440919 9.166862