mapCodesToPhecodes: Map codes to phecodes

View source: R/mapCodesToPhecodes.R

mapCodesToPhecodesR Documentation

Map codes to phecodes

Description

This function takes a data frame with codes and maps them to phecodes. It can support aribitrary maps of codes to phecodes and phecode rollup maps. The included mappings are from ICD9CM and ICD10CM.

Usage

mapCodesToPhecodes(input, 
           vocabulary.map=PheWAS::phecode_map,
           rollup.map=PheWAS:::phecode_rollup_map,
           make.distinct=TRUE)

Arguments

input

Data frame containing vocabulary_id and code columns. These columns specify the vocabulary used in each row, eg ICD9CM or ICD10CM, and the code to be translated. code must be a character or factor to ensure proper conversion (ICD9CM codes lose specificity as numeric).

vocabulary.map

Data frame with columns vocabulary_id, code, and phecode. Each row represents a mapping from a specific vocabulary and code to a specific phecode. The default map PheWAS::phecode_map supports ICD9CM (map v1.2) and ICD10CM (map 2018 beta). If NULL, it will skip the mapping codes to phecodes step. This may be useful if one is seeking to expand or roll up an existing set of phecodes.

rollup.map

Data frame with columns code, and phecode_unrolled. Each row represents a mapping from a specific phecode to all parent phecodes. The default map PheWAS::phecode_rollup_map is the complete rollup map for phecode map v1.2. If NULL, it will skip the rollup step. This may be useful if one is seeking to only consider the directly mapped phecodes.

make.distinct

Boolean value. Should duplicate rows be removed during mapping? Default is TRUE. Useful to reduce data size, especially when another column, eg date of code, is provided.

Value

A data frame containing the columns in input, except the origial code and vocabulary_id columns have been replaced with phecode now containing the phecode as character.

Author(s)

Robert Carroll Laura Wiley

Examples

diabetes_billing=data.frame(id=1:3,vocabulary_id=c("ICD9CM","ICD9CM","ICD10CM"),code=c("250.00","250.01","E11.00"))
phecodes=mapCodesToPhecodes(diabetes_billing)
phecodes
addPhecodeInfo(phecodes)

PheWAS/PheWAS documentation built on July 3, 2023, 3:40 p.m.