reformat_caliber_for_ukb: Reformat and map CALIBER codes for use with UK Biobank data

View source: R/caliber.R

reformat_caliber_for_ukbR Documentation

Reformat and map CALIBER codes for use with UK Biobank data

Description

Reformats Read 2, ICD10 and OPCS4 CALIBER codes to match the format in UK Biobank data, and also maps from Read 2 to Read 3, as well as from ICD10 to ICD9. See vignette("caliber") for further details.

Usage

reformat_caliber_for_ukb(
  caliber,
  all_lkps_maps,
  col_filters = default_col_filters(),
  overlapping_disease_categories = "error",
  overlapping_disease_categories_csv = default_overlapping_disease_categories_csv()
)

Arguments

caliber

A named list of data frames, created by read_caliber_raw().

all_lkps_maps

Either a named list of lookup and mapping tables (either data frames or tbl_dbi objects), or the path to a SQLite database containing these tables (see also build_all_lkps_maps() and all_lkps_maps_to_db()). If NULL, will attempt to connect to an SQLite database named 'all_lkps_maps.db' in the current working directory, or to a a SQLite database specified by an environmental variable named 'ALL_LKPS_MAPS_DB' (see here for how to set environment variables using a .Renviron file). The latter method will be used in preference.

col_filters

A named list where each name in the list refers to the name of a lookup or mapping table. Each item is also a named list, where the names refer to column names in the corresponding table, and the items are vectors of values to filter for. For example, ⁠list(my_lookup_table = list(colA = c("A", "B"))⁠ will result in my_lookup_table being filtered for rows where colA is either 'A' or 'B'. Uses default_col_filters() by default. Set to NULL to remove all filters.

overlapping_disease_categories

If 'error' (default), raises an error if any overlapping disease categories are present after mapping. Specify 'warning' to raise a warning instead.

overlapping_disease_categories_csv

File path to a csv containing codes that are listed under more than one disease category within a disease. This should have the same format as ukbwranglr::example_clinical_codes(), with the author column set to 'caliber' for all rows, plus an additional 'keep' column with 'Y' values indicating which rows to keep. By default, this is set to default_overlapping_disease_categories_csv().

Value

A named list of data frames.

See Also

Other CALIBER: default_overlapping_disease_categories_csv(), download_caliber_repo(), get_caliber_categories_mapping(), read_caliber_raw()

Examples

# read local copy of CALIBER repository into a named list
caliber_raw <- read_caliber_raw(dummy_caliber_dir_path())

# build dummy all_lkps_maps
all_lkps_maps <- build_all_lkps_maps_dummy()

# reformat CALIBER codes for UK Biobank
caliber_ukb <- suppressWarnings(reformat_caliber_for_ukb(caliber_raw,
  all_lkps_maps = all_lkps_maps
))

# view first few rows
head(caliber_ukb)

rmgpanw/codemapper documentation built on Aug. 30, 2023, 4:07 p.m.