knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(codemapper)
library(dplyr)

all_lkps_maps_dummy <- build_all_lkps_maps_dummy()

Introduction

A phenome-wide association study analyses associations between a single genetic (or non-genetic) exposure across a number of phenotypes. One way to perform this is by using phecodes.[@denny2016; @wu2019]

This vignette outlines one approach for mapping UK Biobank clinical codes to phecodes.

Map UK Biobank clinical events to phecodes

A UK Biobank clinical events table created by ukbwranglr::tidy_clinical_events() may be mapped to Phecodes using map_clinical_events_to_phecodes():

# dummy clinical events data frame
dummy_clinical_events <- dummy_clinical_events_tidy()

# map to Phecodes
dummy_clinical_events_phecodes <- map_clinical_events_to_phecodes(clinical_events = dummy_clinical_events,
                                                            all_lkps_maps = all_lkps_maps_dummy,
                                                            min_date_only = FALSE)

dummy_clinical_events_phecodes

ICD10 codes are mapped directly to phecodes, while non-ICD10 sources are mapped to phecodes via ICD10. Use the col_filters argument to determine which code mappings to include (see vignette(map_codes) for further details).

The following data sources (if present in the clinical events data frame) are included in the mapping:

ukbwranglr::clinical_events_sources() %>% 
  filter(source %in% codemapper:::CLINICAL_EVENTS_SOURCES_MAPPED_TO_PHECODES) %>% 
  knitr::kable()

The the output from map_clinical_events_to_phecodes() may be reformatted for running a phenome-wide association study using the PheWAS package as follows:

dummy_clinical_events_phecodes %>%
               select(eid,
                      phecode,
                      date) %>%
               mutate(date = TRUE) %>%
               # ensure one phecode only per eid
               distinct() %>%
               tidyr::pivot_wider(names_from = phecode,
                           values_from = date,
                           values_fill = FALSE)

Reverse mapping

Ideally all Read and ICD9 code to phecode mappings should be manually checked prior to their use. At the very least, any findings of interest should be manually reviewed to ascertain exactly which clinical codes were used. Use make_phecode_reverse_map() to achieve this

make_phecode_reverse_map(clinical_events_phecodes = dummy_clinical_events_phecodes,
                           all_lkps_maps = all_lkps_maps_dummy) %>% 
  knitr::kable()

References



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