ln_quantile_value {labNorm}R Documentation

Compute the lab value for a given quantile

Description

The function ln_quantile_value calculates lab values at a specified quantile, using the default units for that lab. The function ln_patients_quantile_value does the same calculation for a specific group of patients.
Default units for a lab can be obtained using ln_lab_default_units.
If no quantile data is available for a particular lab, age, and sex, the function returns 'NA'.
It should be noted that the values of extreme quantiles (e.g. >0.95 or <0.05 on low resolution, >0.99 or <0.01 on high resolution) may not be reliable, as they may represent outliers in the data.

Note that ln_quantile_value returns values for all combinations of age, sex, and lab, while ln_patients_quantile_value returns values for a specific set of patients, similar to ln_normalize.

Usage

ln_quantile_value(
  quantiles,
  age,
  sex,
  lab,
  reference = "Clalit",
  allow_edge_quantiles = FALSE
)

ln_patients_quantile_value(
  quantiles,
  age,
  sex,
  lab,
  reference = "Clalit",
  allow_edge_quantiles = FALSE
)

Arguments

quantiles

a vector of quantiles (in the range 0-1) to compute the lab value for, or a vector with a quantile for each patient when running ln_patients_quantile_value.

age

a vector of ages to compute the lab values for or a vector with an age for each patient when running ln_patients_quantile_value. Note that the age should be in years, and would be floored to the nearest integer.

sex

the sexes to compute the lab values for, or a vector with a sex for each patient when running ln_patients_quantile_value. Note that for ln_quantile_value this parameter can only be either: "male", "female" or c("male", "female")

lab

The lab name.

reference

the reference distribution to use. Can be either "Clalit" or "UKBB" or "Clalit-demo". Please download the Clalit and UKBB reference distributions using ln_download_data().

allow_edge_quantiles

If TRUE (default) then the function will return the value for the edge quantiles (<0.01 or >0.99) even though they are not reliable. If FALSE then the function will return NA for those quantiles. Note that for the "Clalit-demo" reference, the threshold would be <0.05 or >0.95.

Value

ln_quantile_value returns a data frame which contains the values for each combination of quantile, age and sex. The data frame has the the following columns:

ln_patients_quantile_value returns a vector of value per patient.

Examples


ln_quantile_value(c(0.05, 0.5, 0.95), 50, "male", "WBC")

ln_quantile_value(
    c(0, 0.05, 0.1, 0.4, 0.5, 0.6, 0.9, 1),
    c(50, 60),
    c("male", "female"),
    "Glucose"
)


# on the demo data



hemoglobin_data$quantile <- ln_normalize(
    hemoglobin_data$value,
    hemoglobin_data$age,
    hemoglobin_data$sex,
    "Hemoglobin"
)

hemoglobin_data$value1 <- ln_patients_quantile_value(
    hemoglobin_data$quantile,
    hemoglobin_data$age,
    hemoglobin_data$sex,
    "Hemoglobin"
)
head(hemoglobin_data)





[Package labNorm version 1.0.1 Index]