# Lab Grading

# Introduction

Within the ADLB ADaM data set there is a concept of lab grading, where there is a set of criteria for particular lab tests that grade the severity or abnormality of a lab value. The grades are from 0 to 4, where grade 0 can be viewed generally as a “NORMAL” value. The higher the grade the more severe or more abnormal the lab value is. There are several sets of lab grading criteria, currently `{admiral}` has implemented NCI-CTCAEv4 and NCI-CTCAEv5 grading criteria. In future releases `{admiral}` may look to implement further grading criteria.

The NCI-CTCAE version 4 and 5 grading criteria can be found here: https://ctep.cancer.gov/protocoldevelopment/electronic_applications/ctc.htm .

The NCI-CTCAEv4 criteria can be found under the heading Common Terminology Criteria for Adverse Events (CTCAE)v4.0

The NCI-CTCAEv5 criteria can be found under the heading Common Terminology Criteria for Adverse Events (CTCAE)v5.0

# Grading metadata

`{admiral}` will store a metadata data set with required variables and optional variables, the optional variables are purely for transparency, and will contain detailed information about the grading criteria. The required variables are those used by `{admiral}` to create the grade.

## Structure of metadata set

The metadata data set has the following structure for the required variables:

Variable | Scope | Type | Example Value
--- | --- | --- | ---
TERM | Term describing the criteria applied to a particular lab test. | Character | “Anemia”
DIRECTION | The direction of the abnormality of a particular lab test value | Character | “L” or “H”.
SI_UNIT_CHECK | Unit of lab test, to check against input data if criteria is based on absolute values. | Character | “mmol/L”
VAR_CHECK | Comma separated list of variables used in criteria, to check input data that variables exist. | Character | “AVAL, ANRLO”
GRADE_CRITERIA_CODE | Variable to hold code that creates grade based on defined criteria. | Character | R code that is a valid case statement within a `mutate` function call

The metadata data set has the following structure for the optional variables:

Variable | Scope | Type | Example Value
--- | --- | --- | ---
SOC | System Organ Class the lab test belongs to. | Character | “Investigations”
GRADE_1 | Grade 1 criteria for lab test, normally straight from source document. | Character | “>ULN - 3.0 x ULN”.
GRADE_2 | Grade 2 criteria for lab test, normally straight from source document. | Character | “>3.0 - 5.0 x ULN”.
GRADE_3 | Grade 3 criteria for lab test, normally straight from source document. | Character | “>5.0 - 20.0 x ULN”.
GRADE_4 | Grade 4 criteria for lab test, normally straight from source document. | Character | “>20.0 x ULN”.
DEFINITION | Definition of abnormality, normally from source document. | Character | “A finding based on laboratory test results that indicate an increase in the level of alanine aminotransferase (ALT or SGPT) in the blood specimen.”.
COMMENT | Description of any decisions made by `{admiral}` to implement grading criteria, where grading criteria alone was ambiguous. | Character | “Take worst case and assume on anticoagulation”.

# Creating the lab grade

## Mapping ADLB VAD to the TERM variable in the `{admiral}` metadata data set

    library(admiral)
    library(admiral.test)
    library(dplyr, warn.conflicts = FALSE)
    library(stringr)
    library(tibble)

    data("admiral_lb")

    adsl <- admiral_adsl
    lb <- convert_blanks_to_na(admiral_lb)

Each company needs to map their lab test to a term that describes the criteria being applied. The list of terms defined in the `{admiral}` metadata to implement NCI-CTCAEv4 is below:

TERM
Anemia
Leukocytosis
Activated partial thromboplastin time prolonged
Alanine aminotransferase increased
Alkaline phosphatase increased
Aspartate aminotransferase increased
Blood bilirubin increased
CD4 lymphocytes decreased
Cholesterol high
CPK increased

Likewise, the list of terms defined in the `{admiral}` metadata to implement NCI-CTCAEv5 is below: (Terms identical to NCI-CTCAEv4, except `Hyperglycemia`, `Hyperglycemia (Fasting)` and `Hypophosphatemia`) which are not present in NCI-CTCAEv5.

TERM
Anemia
Leukocytosis
Activated partial thromboplastin time prolonged
Alanine aminotransferase increased
Alkaline phosphatase increased
Aspartate aminotransferase increased
Blood bilirubin increased
CD4 lymphocytes decreased
Cholesterol high
CPK increased

Using CDISC data these lab tests can be mapped to the correct terms, firstly create `PARAMCD`, `PARAM`, `AVAL`, `ANRLO` and `ANRHI`, also some lab grading criteria require `BASE` and `PCHG`, so these would also need to be created before running `derive_var_atoxgr_dir()` function.

    # Look-up tables ----

    # Assign PARAMCD, PARAM, and PARAMN
    param_lookup <- tibble::tribble(
      ~LBTESTCD, ~PARAMCD,  ~PARAM,                                             ~PARAMN,
      "ALB",     "ALB",     "Albumin (g/L)",                                    1,
      "ALP",     "ALKPH",   "Alkaline Phosphatase (U/L)",                       2,
      "ALT",     "ALT",     "Alanine Aminotransferase (U/L)",                   3,
      "ANISO",   "ANISO",   "Anisocytes",                                       4,
      "AST",     "AST",     "Aspartate Aminotransferase (U/L)",                 5,
      "BASO",    "BASO",    "Basophils (10^9/L)",                               6,
      "BASOLE",  "BASOLE",  "Basophils/Leukocytes (FRACTION)",                  7,
      "BILI",    "BILI",    "Bilirubin (umol/L)",                               8,
      "BUN",     "BUN",     "Blood Urea Nitrogen (mmol/L)",                     9,
      "CA",      "CA",      "Calcium (mmol/L)",                                 10,
      "CHOL",    "CHOLES",  "Cholesterol (mmol/L)",                             11,
      "CK",      "CK",      "Creatinine Kinase (U/L)",                          12,
      "CL",      "CL",      "Chloride (mmol/L)",                                13,
      "COLOR",   "COLOR",   "Color",                                            14,
      "CREAT",   "CREAT",   "Creatinine (umol/L)",                              15,
      "EOS",     "EOS",     "Eosinophils (10^9/L)",                             16,
      "EOSLE",   "EOSLE",   "Eosinophils/Leukocytes (FRACTION)",                17,
      "GGT",     "GGT",     "Gamma Glutamyl Transferase (U/L)",                 18,
      "GLUC",    "GLUC",    "Glucose (mmol/L)",                                 19,
      "HBA1C",   "HBA1C",   "Hemoglobin A1C (1)",                               20,
      "HCT",     "HCT",     "Hematocrit (1)",                                   21,
      "HGB",     "HGB",     "Hemoglobin (mmol/L)",                              22,
      "K",       "POTAS",   "Potassium (mmol/L)",                               23,
      "KETONES", "KETON",   "Ketones",                                          24,
      "LYM",     "LYMPH",   "Lymphocytes (10^9/L)",                             25,
      "LYMLE",   "LYMPHLE", "Lymphocytes/Leukocytes (FRACTION)",                26,
      "MACROCY", "MACROC",  "Macrocytes",                                       27,
      "MCH",     "MCH",     "Ery. Mean Corpuscular Hemoglobin (fmol(Fe))",      28,
      "MCHC",    "MCHC",    "Ery. Mean Corpuscular HGB Concentration (mmol/L)", 29,
      "MCV",     "MCV",     "Ery. Mean Corpuscular Volume (f/L)",               30,
      "MICROCY", "MICROC",  "Microcytes",                                       31,
      "MONO",    "MONO",    "Monocytes (10^9/L)",                               32,
      "MONOLE",  "MONOLE",  "Monocytes/Leukocytes (FRACTION)",                  33,
      "PH",      "PH",      "pH",                                               34,
      "PHOS",    "PHOS",    "Phosphate (mmol/L)",                               35,
      "PLAT",    "PLAT",    "Platelet (10^9/L)",                                36,
      "POIKILO", "POIKIL",  "Poikilocytes",                                     37,
      "POLYCHR", "POLYCH",  "Polychromasia",                                    38,
      "PROT",    "PROT",    "Protein (g/L)",                                    39,
      "RBC",     "RBC",     "Erythrocytes (TI/L)",                              40,
      "SODIUM",  "SODIUM",  "Sodium (mmol/L)",                                  41,
      "SPGRAV",  "SPGRAV",  "Specific Gravity",                                 42,
      "TSH",     "TSH",     "Thyrotropin (mU/L)",                               43,
      "URATE",   "URATE",   "Urate (umol/L)",                                   44,
      "UROBIL",  "UROBIL",  "Urobilinogen",                                     45,
      "VITB12",  "VITB12",  "Vitamin B12 (pmol/L)",                             46,
      "WBC",     "WBC",     "Leukocytes (10^9/L)",                              47
    )

    adlb <- lb %>%
      ## Add PARAMCD PARAM and PARAMN - from LOOK-UP table
      derive_vars_merged_lookup(
        dataset_add = param_lookup,
        new_vars = exprs(PARAMCD, PARAM, PARAMN),
        by_vars = exprs(LBTESTCD)
      ) %>%
      ## Calculate PARCAT1 AVAL AVALC ANRLO ANRHI
      ## Dummy the values for BASE
      mutate(
        PARCAT1 = LBCAT,
        AVAL = LBSTRESN,
        AVALC = LBSTRESC,
        ANRLO = LBSTNRLO,
        ANRHI = LBSTNRHI,
        BASE = AVAL - 10
      )
    #> All `LBTESTCD` are mapped.

Another look-up table is used to add on `ATOXDSCL` and `ATOXDSCH` using `PARAMCD`. `ATOXDSCL` holds the terms for grading low lab values, and `ATOXDSCH` holds the terms for grading high lab values. The names of these variables can be user-defined. `ATOXDSCL` and `ATOXDSCH` are the link from ADLB data to the `{admiral}` metadata that holds the grading criteria.

    # Assign ATOXDSCL and ATOXDSCH to hold lab grading terms
    # ATOXDSCL and ATOXDSCH hold terms defined by NCI-CTCAEv4.
    grade_lookup <- tibble::tribble(
      ~PARAMCD, ~ATOXDSCL,                    ~ATOXDSCH,
      "ALB",    "Hypoalbuminemia",            NA_character_,
      "ALKPH",  NA_character_,                "Alkaline phosphatase increased",
      "ALT",    NA_character_,                "Alanine aminotransferase increased",
      "AST",    NA_character_,                "Aspartate aminotransferase increased",
      "BILI",   NA_character_,                "Blood bilirubin increased",
      "CA",     "Hypocalcemia",               "Hypercalcemia",
      "CHOLES", NA_character_,                "Cholesterol high",
      "CK",     NA_character_,                "CPK increased",
      "CREAT",  NA_character_,                "Creatinine increased",
      "GGT",    NA_character_,                "GGT increased",
      "GLUC",   "Hypoglycemia",               "Hyperglycemia",
      "HGB",    "Anemia",                     "Hemoglobin increased",
      "POTAS",  "Hypokalemia",                "Hyperkalemia",
      "LYMPH",  "CD4 lymphocytes decreased",  NA_character_,
      "PHOS",   "Hypophosphatemia",           NA_character_,
      "PLAT",   "Platelet count decreased",   NA_character_,
      "SODIUM", "Hyponatremia",               "Hypernatremia",
      "WBC",    "White blood cell decreased", "Leukocytosis",
    )

    adlb <- adlb %>%
      derive_vars_merged(
        dataset_add = grade_lookup,
        by_vars = exprs(PARAMCD),
      )

It is now straightforward to create the grade, for low lab values the grade will be held in `ATOXGRL` and for high lab values the grade will be held in `ATOXGRH`.

Note: for NCICTCAEv5 grading, you would update `meta_criteria` parameter to `atoxgr_criteria_ctcv5`.

    adlb <- adlb %>%
      derive_var_atoxgr_dir(
        new_var = ATOXGRL,
        tox_description_var = ATOXDSCL,
        meta_criteria = atoxgr_criteria_ctcv4,
        criteria_direction = "L",
        get_unit_expr = extract_unit(PARAM)
      ) %>%
      derive_var_atoxgr_dir(
        new_var = ATOXGRH,
        tox_description_var = ATOXDSCH,
        meta_criteria = atoxgr_criteria_ctcv4,
        criteria_direction = "H",
        get_unit_expr = extract_unit(PARAM)
      )

Note: `{admiral}` does not grade ‘Anemia’ or ‘Hemoglobin Increased’ because the metadata is based on the SI unit of ‘g/L’, however the CDISC data has SI unit of ‘mmol/L’. Please see `SI_UNIT_CHECK` variable in `{admiral}` metadata `atoxgr_criteria_ctcv4` or `atoxgr_criteria_ctcv5`, the metadata is in the data folder of `{admiral}`.

TERM | SI_UNIT_CHECK
--- | ---
Anemia | g/L
Leukocytosis | 10^9/L
CD4 lymphocytes decreased | 10^9/L
Cholesterol high | mmol/L
Fibrinogen decreased | g/L
Hemoglobin increased | g/L
Lymphocyte count decreased | 10^9/L
Lymphocyte count increased | 10^9/L
Neutrophil count decreased | 10^9/L
Platelet count decreased | 10^9/L

`{admiral}` also gives the option to combine `ATOXGRL` and `ATOXGRH` into one variable, namely `ATOXGR`. Grades held in `ATOXGRL` will be given a negative value in `ATOXGR` to distinguish between low and high values.

    adlb <- adlb %>%
      derive_var_atoxgr()

ATOXDSCL | ATOXDSCH | ATOXGRL | ATOXGRH | ATOXGR
--- | --- | --- | --- | ---
CD4 lymphocytes decreased | NA | 1 | NA | -1
Hypoalbuminemia | NA | 1 | NA | -1
Hypoalbuminemia | NA | 1 | NA | -1
Hypoalbuminemia | NA | 1 | NA | -1
Hypoalbuminemia | NA | 1 | NA | -1
Hypoalbuminemia | NA | 1 | NA | -1
Hypoalbuminemia | NA | 1 | NA | -1
Hypoalbuminemia | NA | 1 | NA | -1
Hypoalbuminemia | NA | 1 | NA | -1
Hypoalbuminemia | NA | 1 | NA | -1

# NCI-CTCAEV4 implementation

## Terms graded

Grading is implemented for those lab tests where a lab value is included in the grading definition, `{admiral}` does NOT try to read any other data to determine the grade, and only the ADLB VAD is used. The following CTCAE v4.0 SOC values were identified for grading, these are “Investigations”, “Metabolism and nutrition disorders” and “Blood and lymphatic system disorders”.

From these SOC values the following terms criteria is implemented in `{admiral}`

From SOC = “Investigations” there are 21 CTCAE v4.0 Terms:

- Activated partial thromboplastin time prolonged
- Alanine aminotransferase increased
- Alkaline phosphatase increased
- Aspartate aminotransferase increased
- Blood bilirubin increased
- CD4 lymphocytes decreased
- Cholesterol high
- CPK increased
- Creatinine increased
- Fibrinogen decreased
- GGT increased
- Haptoglobin decreased
- Hemoglobin increased
- INR increased
- Lipase increased
- Lymphocyte count decreased
- Lymphocyte count increased
- Neutrophil count decreased
- Platelet count decreased
- Serum amylase increased
- White blood cell decreased

From the SOC = “Metabolism and nutrition disorders” there are 14 CTCAE v4.0 Terms:

- Hypercalcemia
- Hyperglycemia
- Hyperkalemia
- Hypermagnesemia
- Hypernatremia
- Hypertriglyceridemia
- Hyperuricemia
- Hypoalbuminemia
- Hypocalcemia
- Hypoglycemia
- Hypokalemia
- Hypomagnesemia
- Hyponatremia
- Hypophosphatemia

From the SOC = “Blood and lymphatic system disorders” there are 2 CTCAE v4.0 Terms:

- Anemia
- Leukocytosis

## Updates made to TERM

For terms “Hypocalcemia” and “Hypercalcemia” the criteria is provided for Calcium and Ionized Calcium, therefore `{admiral}` created a row for each in the metadata, this is noted in the COMMENT variable of the metadata:

TERM | COMMENT
--- | ---
Hypercalcemia | Split Corrected Calcium and Ionized Calcium into 2 separate terms.
Hypercalcemia (Ionized) | Split Corrected Calcium and Ionized Calcium into 2 separate terms.
Hypocalcemia | Split Corrected Calcium and Ionized Calcium into 2 separate terms.
Hypocalcemia (Ionized) | Split Corrected Calcium and Ionized Calcium into 2 separate terms.

Similarly, there is criteria applicable to Fasting Glucose as well as non-Fasting Glucose for “Hyperglycemia” so again this was split into 2 rows, and noted in the COMMENT variable. Note “Hypoglycemia” does not require to be split into 2 rows:

TERM | COMMENT
--- | ---
Hyperglycemia (Fasting) | Split Fasting Glucose and Glucose into 2 separate terms.
Hyperglycemia | Split Fasting Glucose and Glucose into 2 separate terms.
Hypoglycemia | NA

## Assumptions made when grading

For term “INR Increased” there is the following criteria:

TERM | Grade_1
--- | ---
INR increased | >1 - 1.5 x ULN; >1 - 1.5 times above baseline if on anticoagulation

`{admiral}` assumed worst case and used both parts of the criteria for grading, so comparing lab value against ULN and also BASE. The decision made was put in the `COMMENT` field.

TERM | COMMENT
--- | ---
INR increased | Take worst case and assume “on anticoagulation”

For TERM “Hyperuricemia”, the criteria for Grade 1 and Grade 3 is the same with respect to the lab value, so worse case is assumed as grade 3. The decision made was put in the `COMMENT` field.

TERM | Grade_1 | Grade_3 | COMMENT
--- | --- | --- | ---
Hyperuricemia | >ULN - 10 mg/dL (0.59 mmol/L) without physiologic consequences | >ULN - 10 mg/dL (0.59 mmol/L) with physiologic consequences | Take worst case and assume “with physiologic consequences”

A similar approach was taken for TERM “Hypokalemia” where Grade 1 and Grade 2 criteria is the same with respect to the lab value, so worse case is assumed as grade 2. The decision made was put in the `COMMENT` field.

TERM | Grade_1 | Grade_2 | COMMENT
--- | --- | --- | ---
Hypokalemia | <LLN - 3.0 mmol/L | <LLN - 3.0 mmol/L; symptomatic; intervention indicated | Take worst case and assume “symptomatic OR intervention indicated”

# NCI-CTCAEV5 implementation

## Terms graded

Grading is implemented for those lab tests where a lab value is included in the grading definition, `{admiral}` does NOT try to read any other data to determine the grade, and only the ADLB VAD is used. The following CTCAE v5.0 SOC values were identified for grading, these are “Investigations”, “Metabolism and nutrition disorders” and “Blood and lymphatic system disorders”.

From these SOC values the following terms criteria is implemented in `{admiral}`

From SOC = “Investigations” there are 21 CTCAE v5.0 Terms:

- Activated partial thromboplastin time prolonged
- Alanine aminotransferase increased
- Alkaline phosphatase increased
- Aspartate aminotransferase increased
- Blood bilirubin increased
- CD4 lymphocytes decreased
- Cholesterol high
- CPK increased
- Creatinine increased
- Fibrinogen decreased
- GGT increased
- Haptoglobin decreased
- Hemoglobin increased
- INR increased
- Lipase increased
- Lymphocyte count decreased
- Lymphocyte count increased
- Neutrophil count decreased
- Platelet count decreased
- Serum amylase increased
- White blood cell decreased

Note: These are the same terms identified for NCI-CTCAEv4.

From the SOC = “Metabolism and nutrition disorders” there are 12 CTCAE v4.0 Terms:

- Hypercalcemia
- Hyperkalemia
- Hypermagnesemia
- Hypernatremia
- Hypertriglyceridemia
- Hyperuricemia
- Hypoalbuminemia
- Hypocalcemia
- Hypoglycemia
- Hypokalemia
- Hypomagnesemia
- Hyponatremia

Note: These are the same terms identified for NCI-CTCAEv4, except “Hypophosphatemia” and “Hyperglycemia” which are not in NCICTCAEv5 grading criteria.

From the SOC = “Blood and lymphatic system disorders” there are 2 CTCAE v4.0 Terms:

- Anemia
- Leukocytosis

Note: These are the same terms identified for NCI-CTCAEv4.

## Updates made to TERM

For terms “Hypocalcemia” and “Hypercalcemia” the criteria is provided for Calcium and Ionized Calcium, therefore `{admiral}` created a row for each in the metadata, this is noted in the COMMENT variable of the metadata:

TERM | COMMENT
--- | ---
Hypercalcemia | Split Corrected Calcium and Ionized Calcium into 2 separate terms.
Hypercalcemia (Ionized) | Split Corrected Calcium and Ionized Calcium into 2 separate terms.
Hypocalcemia | Split Corrected Calcium and Ionized Calcium into 2 separate terms.
Hypocalcemia (Ionized) | Split Corrected Calcium and Ionized Calcium into 2 separate terms.

## Assumptions made when grading

For term “INR Increased” there is the following criteria:

TERM | Grade_1
--- | ---
INR increased | >1.2 - 1.5 x ULN; >1 - 1.5 x baseline if on anticoagulation; monitoring only indicated

`{admiral}` assumed worst case and used both parts of the criteria for grading, so comparing lab value against ULN and also BASE. The decision made was put in the `COMMENT` field.

TERM | COMMENT
--- | ---
INR increased | Take worst case and assume “on anticoagulation”

Similarly, for terms “Lipase Increased” and “Serum amylase increased” there is the following criteria:

TERM | Grade_2 | Grade_3 | Grade_4
--- | --- | --- | ---
INR increased | >1.5 - 2.5 x ULN; >1.5 - 2.5 x baseline if on anticoagulation; dose adjustment indicated | >2.5 x ULN; >2.5 times above baseline if on anticoagulation | -
Serum amylase increased | >1.5 - 2.0 x ULN; >2.0 - 5.0 x ULN and asymptomatic | >2.0 - 5.0 x ULN with signs or symptoms; >5.0 x ULN and asymptomatic | >5.0 x ULN and with signs or symptoms

`{admiral}` assumed worst case and implemented highest grade possible. The decision made was put in the `COMMENT` field.

TERM | COMMENT
--- | ---
INR increased | Take worst case and assume “on anticoagulation”
Serum amylase increased | Take worst case and assume “signs and symptoms”

For TERM “Hyperuricemia”, the criteria for Grade 1 and Grade 3 is the same with respect to the lab value, so worse case is assumed as grade 3. The decision made was put in the `COMMENT` field.

TERM | Grade_1 | Grade_3 | COMMENT
--- | --- | --- | ---
Hyperuricemia | >ULN without physiologic consequences | >ULN with physiologic consequences | Take worst case and assume “with physiologic consequences”

A similar approach was taken for TERM “Hypokalemia” and “Hyponatremia”. For “Hypokalemia”, where Grade 1 and Grade 2 criteria is the same with respect to the lab value, then worse case is assumed as grade 2. For “Hyponatremia”, where Grade 2 and Grade 2 criteria is the same with respect to the lab value, then worse case is assumed as grade 3. The decision made was put in the `COMMENT` field.

TERM | Grade_1 | Grade_2 | Grade_3 | COMMENT
--- | --- | --- | --- | ---
Hypokalemia | <LLN - 3.0 mmol/L | Symptomatic with <LLN - 3.0 mmol/L; intervention indicated | <3.0 - 2.5 mmol/L; hospitalization indicated | Take worst case and assume “symptomatic”
Hyponatremia | <LLN - 130 mmol/L | 125-129 mmol/L and asymptomatic | 125-129 mmol/L symptomatic; 120-124 mmol/L regardless of symptoms | Take worst case and assume “symptomatic”

# Conclusion

With NCI-CTCAEv4 and NCI-CTCAEv5 now implemented, {admiral} may look to implement other industry standard grading criteria. Providing tools for users to easily interact with the metadata to update criteria, based on their companies needs will also be looked at. Ideally, users should be able to create their own metadata for company specific grading schemes.