make_phecode_reverse_map: Reverse map from phecodes to Read and ICD 9

View source: R/clinical_events_to_phecodes.R

make_phecode_reverse_mapR Documentation

Reverse map from phecodes to Read and ICD 9

Description

Requires the output from map_clinical_events_to_phecodes(), which maps UK Biobank clinical events from Read 2, Read 3 and ICD-9 to ICD-10, then uses Phecode Map 1.2 with ICD-10 Codes (beta) to map these ICD-10 equivalents (and any actual ICD-10 records) to Phecodes. This function uses the output from map_clinical_events_to_phecodes() to reverse map from phecodes to Read 2, Read 3, ICD-9 and ICD-10. This is useful for checking which raw clinical codes have been used in any phecode-defined phenotypes.

Usage

make_phecode_reverse_map(clinical_events_phecodes, all_lkps_maps)

Arguments

clinical_events_phecodes

A data frame created by map_clinical_events_to_phecodes().

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.

Value

A data frame with columns "phecode", "phecode_description", "data_coding", "code" "description", "icd10_equivalent" and "icd10_description". Column 'code' contains the original 'raw' UK clinical codes, with code type indicated by the 'data_coding' column.

Examples

# build dummy all_lkps_maps
all_lkps_maps_dummy <- build_all_lkps_maps_dummy()

# map dummy clinical events df to phecodes
clinical_events_phecodes_dummy <- map_clinical_events_to_phecodes(
  clinical_events = dummy_clinical_events_tidy(),
  all_lkps_maps = all_lkps_maps_dummy,
  min_date_only = FALSE
)

# create reverse map
make_phecode_reverse_map(
  clinical_events_phecodes = clinical_events_phecodes_dummy,
  all_lkps_maps = all_lkps_maps_dummy
)

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