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 |
age |
a vector of ages to compute the lab values for or a vector with an age for each patient when running |
sex |
the sexes to compute the lab values for, or a vector with a sex for each patient when running |
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 |
allow_edge_quantiles |
If |
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:
age: age in years
sex: "male" or "female"
quantile: he quantile
value: the lab value
unit: the lab unit
lab: the lab name
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)