Last updated: 2022-03-10
Checks: 5 2
Knit directory: codemapper/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.
The global environment had objects present when the code in the R Markdown file was run. These objects can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment. Use wflow_publish or wflow_build to ensure that the code is always run in an empty environment.
The following objects were defined in the global environment when these results were created:
| Name | Class | Size |
|---|---|---|
| install_codemapper | function | 1.2 Kb |
The command set.seed(20210923) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version e5c5381. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Renviron
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: _targets/
Ignored: all_lkps_maps.db
Ignored: all_lkps_maps.db.gz
Ignored: renv/library/
Ignored: renv/staging/
Ignored: tar_make.R
Unstaged changes:
Modified: _targets.R
Modified: analysis/icd10_lkp.Rmd
Modified: analysis/read3_icd10_mapping.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/icd10_lkp.Rmd) and HTML (public/icd10_lkp.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.
| File | Version | Author | Date | Message |
|---|---|---|---|---|
| Rmd | e5c5381 | rmgpanw | 2022-03-10 | update mainly icd10-related codes. |
| Rmd | a64a35e | rmgpanw | 2022-03-10 | change arg quiet = TRUE to unrecognised_codes = “error”. Also updated tests (passing) |
library(tidyverse)
library(reactable)
library(readxl)
library(crosstalk)
library(targets)
library(codemapper)
tar_load(all_lkps_maps_raw)
ALT_CODE format, however an ‘X’ filler is not appended for codes where the 3 character category is undivided. For example, the ICD10 code for Scarlet fever, A38, is recorded as A38X under ALT_CODE in the ICD10 lookup table, but recorded as A38 in UK Biobank data.ICD10_CODE and ALT-CODEICD10 codes are recorded in 2 formats in UK Biobank resource 592 ICD10_CODE and ALT_CODE. The documentation states:
- ICD10_CODE = ICD10 code
- ALT_CODE = This form strips the decimal point from the code and appends the filler X where the 3 character category is undivided.
In UK Biobank data, ICD10 codes are recorded in the
ALT_CODEformat, however an ‘X’ filler is not appended for codes where the 3 character category is undivided. For example, the ICD10 code for Scarlet fever,A38, is recorded asA38XunderALT_CODEin the ICD10 lookup table, but recorded asA38in UK Biobank data:
all_lkps_maps_raw$icd10_lkp %>%
filter(ICD10_CODE == "A38") %>%
select(ICD10_CODE:DESCRIPTION) %>%
knitr::kable()
| ICD10_CODE | ALT_CODE | USAGE | USAGE_UK | DESCRIPTION |
|---|---|---|---|---|
| A38 | A38X | DEFAULT | 3 | Scarlet fever |
A full list of undivided 3 character ICD10 codes is listed below:
alt_code_ends_x <- all_lkps_maps_raw$icd10_lkp %>%
filter(str_detect(ALT_CODE,
".X$"))
alt_code_ends_x %>%
reactable(filterable = TRUE,
resizable = TRUE,
searchable = TRUE,
showPageSizeOptions = TRUE,
pageSizeOptions = c(5, 10, 25, 50, 100, 200),
paginationType = "jump",
defaultPageSize = 5)
While some ICD10 codes end with ‘X’ (e.g. M45.X), only undivided 3 character codes end with ‘X’ in ALT_CODE format:
alt_code_ends_x %>%
mutate(ICD10_CODE_length = str_length(ICD10_CODE)) %>%
count(ICD10_CODE_length,
name = "n_ALT_CODEs_ending_with_X") %>%
knitr::kable()
| ICD10_CODE_length | n_ALT_CODEs_ending_with_X |
|---|---|
| 3 | 254 |
There are also some other differences between the ICD10_CODE and ALT_CODE formats. In some cases, the same ICD10_CODE can have multiple descriptions that are differentiated by MODIFIER_5. For example, S27.9 describes ‘Injury unspecified intrathoracic organ’, which can be further modified as follows:
all_lkps_maps_raw$icd10_lkp %>%
filter(ICD10_CODE == "S27.9") %>%
select(ICD10_CODE:MODIFIER_5) %>%
knitr::kable()
| ICD10_CODE | ALT_CODE | USAGE | USAGE_UK | DESCRIPTION | MODIFIER_4 | MODIFIER_5 |
|---|---|---|---|---|---|---|
| S27.9 | S279 | DEFAULT | 3 | Injury of unspecified intrathoracic organ | NA | NA |
| S27.9 | S2790 | DEFAULT | 3 | Injury of unspecified intrathoracic organ | NA | without open wound into thoracic cavity |
| S27.9 | S2791 | DEFAULT | 3 | Injury of unspecified intrathoracic organ | NA | with open wound into thoracic cavity |
Simply removing the ‘.’ from ICD10-CODE will not capture all codes in these cases. Note also that in some cases, removing the ‘.’ will not capture any codes used inn UK Biobank:
all_lkps_maps_raw$icd10_lkp %>%
filter(ICD10_CODE == "M45.X") %>%
select(ICD10_CODE:MODIFIER_5) %>%
knitr::kable()
| ICD10_CODE | ALT_CODE | USAGE | USAGE_UK | DESCRIPTION | MODIFIER_4 | MODIFIER_5 |
|---|---|---|---|---|---|---|
| M45.X | M45X0 | DEFAULT | 3 | Ankylosing spondylitis | NA | Multiple sites in spine |
| M45.X | M45X1 | DEFAULT | 3 | Ankylosing spondylitis | NA | Occipito-atlanto-axial region |
| M45.X | M45X2 | DEFAULT | 3 | Ankylosing spondylitis | NA | Cervical region |
| M45.X | M45X3 | DEFAULT | 3 | Ankylosing spondylitis | NA | Cervicothoracic region |
| M45.X | M45X4 | DEFAULT | 3 | Ankylosing spondylitis | NA | Thoracic region |
| M45.X | M45X5 | DEFAULT | 3 | Ankylosing spondylitis | NA | Thoracolumbar region |
| M45.X | M45X6 | DEFAULT | 3 | Ankylosing spondylitis | NA | Lumbar region |
| M45.X | M45X7 | DEFAULT | 3 | Ankylosing spondylitis | NA | Lumbosacral region |
| M45.X | M45X8 | DEFAULT | 3 | Ankylosing spondylitis | NA | Sacral and sacrococcygeal region |
| M45.X | M45X9 | DEFAULT | 3 | Ankylosing spondylitis | NA | Site unspecified |
The number of ICD10 codes with multiple descriptions is summarised by the following table. Note that these all have a MODIFIER_5 description.
n_non_unique_icd10_code_df <- all_lkps_maps_raw$icd10_lkp %>%
group_by(ICD10_CODE) %>%
summarise(n = n(),
n_MODIFIER_5_not_na = sum(!is.na(MODIFIER_5)),
n_MODIFIER_4_not_na = sum(!is.na(MODIFIER_4))) %>%
filter(n > 1) %>%
# select(ICD10_CODE:MODIFIER_5,
# contains("not_na")) %>%
arrange(n_MODIFIER_5_not_na)
list(
n_non_unique_icd10_code = nrow(n_non_unique_icd10_code_df),
n_with_modifier_5 = sum(n_non_unique_icd10_code_df$n_MODIFIER_5_not_na > 0),
n_with_modifier_4 = sum(n_non_unique_icd10_code_df$n_MODIFIER_4_not_na > 0)
) %>%
as_tibble() %>%
knitr::kable()
| n_non_unique_icd10_code | n_with_modifier_5 | n_with_modifier_4 |
|---|---|---|
| 498 | 498 | 0 |
ICD10 codes with MODIFIER_4 descriptions are differentiated by their 4th digit. For example:
all_lkps_maps_raw$icd10_lkp %>%
filter(str_detect(ICD10_CODE,
"^E10")) %>%
select(ICD10_CODE:MODIFIER_5) %>%
knitr::kable()
| ICD10_CODE | ALT_CODE | USAGE | USAGE_UK | DESCRIPTION | MODIFIER_4 | MODIFIER_5 |
|---|---|---|---|---|---|---|
| E10 | E10 | DEFAULT | 3 | Type 1 diabetes mellitus | NA | NA |
| E10.0 | E100 | DEFAULT | 3 | Type 1 diabetes mellitus | With coma | NA |
| E10.1 | E101 | DEFAULT | 3 | Type 1 diabetes mellitus | With ketoacidosis | NA |
| E10.2 | E102 | DAGGER | 4 | Type 1 diabetes mellitus | With renal complications | NA |
| E10.3 | E103 | DAGGER | 4 | Type 1 diabetes mellitus | With ophthalmic complications | NA |
| E10.4 | E104 | DAGGER | 4 | Type 1 diabetes mellitus | With neurological complications | NA |
| E10.5 | E105 | DEFAULT | 3 | Type 1 diabetes mellitus | With peripheral circulatory complications | NA |
| E10.6 | E106 | DEFAULT | 3 | Type 1 diabetes mellitus | With other specified complications | NA |
| E10.7 | E107 | DEFAULT | 3 | Type 1 diabetes mellitus | With multiple complications | NA |
| E10.8 | E108 | DEFAULT | 3 | Type 1 diabetes mellitus | With unspecified complications | NA |
| E10.9 | E109 | DEFAULT | 3 | Type 1 diabetes mellitus | Without complications | NA |
Note, there are no ICD10 codes with values for both MODIFIER_4 AND MODIFIER_5.
More documentation from UK Biobank resource 592:
- USAGE = Dagger / Asterisk indication
- USAGE_UK = Dagger / Asterisk indication
- DESCRIPTION = Longest preferred rubric
- MODIFIER_4 = 4th character modifier suffix
- MODIFIER_5 = 5th character modifier suffix
- QUALIFIERS = Dual classification (asterisk codes)
- GENDER_MASK = Gender mask: Identifies single sex conditions
- MIN_AGE = Minimum age that applies to this code
- MAX_AGE = Max age that applies to this code
- TREE_DESCRIPTION = This data field also contains descriptions that are functional in the context of the 3 character descriptions of their parent category, and are thus suitable for presentation where that context is available. For example:
C00 Malignant neoplasm of lip
C00.0 External upper lip
C00.1 External lower lip
C00.2 External lip, unspecified
Describes different combinations of USAGE, MODIFIER_4, MODIFIER_5 and QUALIFIERS.
all_lkps_maps_raw$icd10_lkp %>%
filter(!is.na(USAGE_UK)) %>%
pull(USAGE_UK) %>%
unique() %>%
set_names() %>%
map( ~ all_lkps_maps_raw$icd10_lkp %>%
filter(USAGE_UK == .x) %>%
head()) %>%
iwalk( ~ {
cat("### ", .y, "\n\n")
flextable::flextable(.x) %>%
flextable::autofit() %>%
flextable::flextable_to_rmd()
cat("\n\n")
})
ICD10_CODE | ALT_CODE | USAGE | USAGE_UK | DESCRIPTION | MODIFIER_4 | MODIFIER_5 | QUALIFIERS | GENDER_MASK | MIN_AGE | MAX_AGE | TREE_DESCRIPTION |
A00 | A00 | DEFAULT | 3 | Cholera | |||||||
A00.0 | A000 | DEFAULT | 3 | Cholera due to Vibrio cholerae 01, biovar cholerae | |||||||
A00.1 | A001 | DEFAULT | 3 | Cholera due to Vibrio cholerae 01, biovar eltor | |||||||
A00.9 | A009 | DEFAULT | 3 | Cholera, unspecified | |||||||
A01 | A01 | DEFAULT | 3 | Typhoid and paratyphoid fevers | |||||||
A01.0 | A010 | DEFAULT | 3 | Typhoid fever |
ICD10_CODE | ALT_CODE | USAGE | USAGE_UK | DESCRIPTION | MODIFIER_4 | MODIFIER_5 | QUALIFIERS | GENDER_MASK | MIN_AGE | MAX_AGE | TREE_DESCRIPTION |
A06.4 | A064 | DAGGER | 1 | Amoebic liver abscess | K77.0 | ||||||
A06.5 | A065 | DAGGER | 1 | Amoebic lung abscess | J99.8 | ||||||
A06.6 | A066 | DAGGER | 1 | Amoebic brain abscess | G07 | ||||||
A17.0 | A170 | DAGGER | 1 | Tuberculous meningitis | G01 | ||||||
A17.1 | A171 | DAGGER | 1 | Meningeal tuberculoma | G07 | ||||||
A17.9 | A179 | DAGGER | 1 | Tuberculosis of nervous system, unspecified | G99.8 |
ICD10_CODE | ALT_CODE | USAGE | USAGE_UK | DESCRIPTION | MODIFIER_4 | MODIFIER_5 | QUALIFIERS | GENDER_MASK | MIN_AGE | MAX_AGE | TREE_DESCRIPTION |
A17 | A17 | DAGGER | 4 | Tuberculosis of nervous system | |||||||
A17.8 | A178 | DAGGER | 4 | Other tuberculosis of nervous system | |||||||
A18.0 | A180 | DAGGER | 4 | Tuberculosis of bones and joints | |||||||
A32.1 | A321 | DAGGER | 4 | Listerial meningitis and meningoencephalitis | |||||||
A39.5 | A395 | DAGGER | 4 | Meningococcal heart disease | |||||||
A52.0 | A520 | DAGGER | 4 | Cardiovascular syphilis |
ICD10_CODE | ALT_CODE | USAGE | USAGE_UK | DESCRIPTION | MODIFIER_4 | MODIFIER_5 | QUALIFIERS | GENDER_MASK | MIN_AGE | MAX_AGE | TREE_DESCRIPTION |
D63 | D63 | ASTERIS | 2 | Anaemia in chronic diseases classified elsewhere | |||||||
D63.0 | D630 | ASTERIS | 2 | Anaemia in neoplastic disease | |||||||
D63.8 | D638 | ASTERIS | 2 | Anaemia in other chronic diseases classified elsewhere | |||||||
D77 | D77X | ASTERIS | 2 | Other disorders of blood and blood-forming organs in diseases classified elsewhere | |||||||
E35 | E35 | ASTERIS | 2 | Disorders of endocrine glands in diseases classified elsewhere | |||||||
E35.0 | E350 | ASTERIS | 2 | Disorders of thyroid gland in diseases classified elsewhere |
ICD10_CODE | ALT_CODE | USAGE | USAGE_UK | DESCRIPTION | MODIFIER_4 | MODIFIER_5 | QUALIFIERS | GENDER_MASK | MIN_AGE | MAX_AGE | TREE_DESCRIPTION |
V01 | V01 | DEFAULT | 0 | Pedestrian injured in collision with pedal cycle | |||||||
V01.0 | V010 | DEFAULT | 0 | Pedestrian injured in collision with pedal cycle | Nontraffic accident | ||||||
V01.1 | V011 | DEFAULT | 0 | Pedestrian injured in collision with pedal cycle | Traffic accident | ||||||
V01.9 | V019 | DEFAULT | 0 | Pedestrian injured in collision with pedal cycle | Unspecified whether traffic or nontraffic accident | ||||||
V02 | V02 | DEFAULT | 0 | Pedestrian injured in collision with two- or three-wheeled motor vehicle | |||||||
V02.0 | V020 | DEFAULT | 0 | Pedestrian injured in collision with two- or three-wheeled motor vehicle | Nontraffic accident |
all_lkps_maps_raw$icd10_lkp %>%
filter(!is.na(QUALIFIERS) | !is.na(USAGE) | !is.na(USAGE_UK)) %>%
reactable(filterable = TRUE,
searchable = TRUE,
sortable = TRUE,
showPageSizeOptions = TRUE)
sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] codemapper_0.0.0.9000 ukbwranglr_0.0.0.9000 targets_0.8.0
[4] crosstalk_1.1.1 readxl_1.3.1 reactable_0.2.3
[7] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7
[10] purrr_0.3.4 readr_2.0.2 tidyr_1.1.4
[13] tibble_3.1.4 ggplot2_3.3.5 tidyverse_1.3.1
[16] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] fs_1.5.0 lubridate_1.7.10 httr_1.4.2 rprojroot_2.0.2
[5] tools_4.1.0 backports_1.2.1 bslib_0.3.1 utf8_1.2.2
[9] R6_2.5.1 DBI_1.1.1 colorspace_2.0-2 withr_2.4.3
[13] tidyselect_1.1.1 processx_3.5.2 compiler_4.1.0 git2r_0.28.0
[17] cli_3.0.1 rvest_1.0.1 flextable_0.6.10 xml2_1.3.2
[21] officer_0.4.1 sass_0.4.0 scales_1.1.1 callr_3.7.0
[25] systemfonts_1.0.4 digest_0.6.28 rmarkdown_2.11 base64enc_0.1-3
[29] pkgconfig_2.0.3 htmltools_0.5.2 dbplyr_2.1.1 fastmap_1.1.0
[33] highr_0.9 htmlwidgets_1.5.4 rlang_0.4.11 rstudioapi_0.13
[37] shiny_1.7.0 jquerylib_0.1.4 generics_0.1.0 jsonlite_1.7.2
[41] zip_2.2.0 magrittr_2.0.1 Rcpp_1.0.7 munsell_0.5.0
[45] fansi_0.5.0 gdtools_0.2.4 lifecycle_1.0.1 stringi_1.7.4
[49] whisker_0.4 yaml_2.2.1 grid_4.1.0 promises_1.2.0.1
[53] crayon_1.4.1 haven_2.4.3 hms_1.1.1 knitr_1.34
[57] ps_1.6.0 pillar_1.6.3 uuid_0.1-4 igraph_1.2.6
[61] codetools_0.2-18 reprex_2.0.1 glue_1.4.2 evaluate_0.14
[65] data.table_1.14.2 renv_0.13.2 modelr_0.1.8 vctrs_0.3.8
[69] tzdb_0.1.2 httpuv_1.6.3 cellranger_1.1.0 gtable_0.3.0
[73] reactR_0.4.4 assertthat_0.2.1 xfun_0.24 mime_0.12
[77] xtable_1.8-4 broom_0.7.9 later_1.3.0 ellipsis_0.3.2