Last updated: 2022-02-22

Checks: 6 1

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.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

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 a42dc66. 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:    .DS_Store
    Ignored:    .Renviron
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    _targets/
    Ignored:    all_lkps_maps.db
    Ignored:    renv/library/
    Ignored:    renv/staging/
    Ignored:    tar_make.R
    Ignored:    ukbb_pan_ancestry-master/

Unstaged changes:
    Modified:   R/utils.R
    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/reformat_all_lkps_maps.Rmd) and HTML (public/reformat_all_lkps_maps.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
html 1df97df rmgpanw 2022-02-17 incorporate icd9 and icd10 to phecode maps
html 81047b4 rmgpanw 2022-02-17 setup for gitlab CI with pkgdown site and test coverage; start adding read3 to snomed mapping
html 5c2a3e3 Chuin Ying Ung 2022-02-17 update _targets.R (housekeeping) and phecode.Rmd
html 38fee6c rmgpanw 2021-12-15 update codes_starting_with function to escape ‘.’, and update tests also
Rmd 4478674 rmgpanw 2021-12-14 update documentation re icd10 codes in reformat_all_lkps_maps.Rmd
Rmd 9593d03 rmgpanw 2021-12-14 minor update to documentation re reformatting icd10_lkp sheet
html e829371 rmgpanw 2021-10-14 add update_code_selection function to utils.r
html f8d1889 rmgpanw 2021-10-09 icd10 codes now returned as ALT CODE; codemapper app includes self-reported codes
Rmd 919be0d rmgpanw 2021-10-07 renamed functions and made shiny app for selecting codes
html 919be0d rmgpanw 2021-10-07 renamed functions and made shiny app for selecting codes
Rmd d285b07 rmgpanw 2021-09-29 add analysis/reformat_all_lkps_maps.Rmd to _targets.R; start analysis/clinical_codes_lkps_and_mappings.Rmd
html d285b07 rmgpanw 2021-09-29 add analysis/reformat_all_lkps_maps.Rmd to _targets.R; start analysis/clinical_codes_lkps_and_mappings.Rmd
Rmd 5647f75 rmgpanw 2021-09-28 targets script working
html 5647f75 rmgpanw 2021-09-28 targets script working

Remove irrelevant rows

Last few rows of each sheet

2 columns shown only

bnf_lkp

BNF_Presentation_Code BNF_Presentation
23985859804 Mentor_Carshalton Urinary Diversion Set Triangular 32mm
23985859805 Mentor_Carshalton Urinary Diversion Set Triangular 38mm
23985859806 Mentor_Chiron Ileal Blad Apparatus
23990001111 Unspecified Manufacturer_Stoma/Incont
NA NA
BNF Code Information, NHSBSA Copyright 2019. This information is licenced under the terms of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

dmd_lkp

concept_id term
4450411000001101 Zyvox 600mg tablets (Pfizer Ltd) 10 tablet (product)
3862301000001107 Zyvox 600mg/300mL infusion solution
4827211000001109 Zyvox 600mg/300ml solution for injection bags (Pfizer Ltd) (product)
4827411000001108 Zyvox 600mg/300ml solution for injection bags (Pfizer Ltd) 10 bag 10 x 300ml bags (product)
NA NA
This material includes SNOMED Clinical Terms® (SNOMED CT®) which is used by permission of the International Health Terminology Standards Development Organisation (IHTSDO). All rights reserved. SNOMED CT®, was originally created by The College of American Pathologists. “SNOMED” and “SNOMED CT” are registered trademarks of the IHTSDO. NA

icd9_lkp

ICD9 DESCRIPTION_ICD9
V825 CHEMICAL POISONING AND OTHER CONTAMINATION
V826 MULTIPHASIC SCREENING
V828 OTHER
V829 UNSPECIFIED
NA NA
ICD-9 is in the public domain so there are no copyright restrictions over its use. WHO no longer publishes or distributes ICD-9. NA

icd10_lkp

ICD10_CODE ALT_CODE
U84.7 U847
U84.8 U848
U84.9 U849
U85 U85X
NA NA
ICD-10 codes, terms and text used by permission of WHO, from: International Statistical Classification of Diseases and Related Health Problems, Tenth Revision (ICD-10). Vols 1-3. Geneva, World Health Organization, 1992-2016. NA

icd9_icd10

ICD9 DESCRIPTION_ICD9
V468 OTHER ENABLING MACHINES
V468 OTHER ENABLING MACHINES
V469 UNSPECIFIED
NA NA
ICD-10 codes, terms and text used by permission of WHO, from: International Statistical Classification of Diseases and Related Health Problems, Tenth Revision (ICD-10). Vols 1-3. Geneva, World Health Organization, 1992-2016. NA
ICD-9 is in the public domain so there are no copyright restrictions over its use. WHO no longer publishes or distributes ICD-9. NA

read_v2_lkp

read_code term_code
Zw058 00
Zw059 00
Zw05A 00
Zw05B 00
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm” NA

read_v2_drugs_lkp

read_code term_description
yz4V. 2016-01-01 GRAMMEZA
yz4W. 2016-02-01 MARMARAS
yz4X. 2016-03-01 MATHRAKI
yz4Y. 2016-04-01 MEGANISI
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_v2_drugs_bnf

read_code bnf_code
m22S. 13.02.01.00
m22T. 13.02.01.00
pq3U. 00.00.00.00
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
BNF Code Information, NHSBSA Copyright 2019. This information is licenced under the terms of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_v2_icd9

read_code icd9_code
ZVu6Z V444
ZVy.. V01-V82
ZVz.. V01-V82
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
ICD-9 is in the public domain so there are no copyright restrictions over its use. WHO no longer publishes or distributes ICD-9. NA

read_v2_icd10

read_code icd10_code
ZVu6Z Z934
ZVy.. Z769
ZVz.. Z769
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
ICD-10 codes, terms and text used by permission of WHO, from: International Statistical Classification of Diseases and Related Health Problems, Tenth Revision (ICD-10). Vols 1-3. Geneva, World Health Organization, 1992-2016. NA

read_v2_opcs4

read_code opcs_4.2_code
7K1Lf W848+Y713
7K1Lg W848+Y713
7L119 X382+Y532
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
The OPCS Classification of Interventions and Procedures, codes, terms and text is Crown copyright (2016) published by Health and Social Care Information Centre, also known as NHS Digital and licensed under the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_v2_read_ctv3

CHAPTER READV2_CODE
Z Zw058
Z Zw059
Z Zw05A
Z Zw05B
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_ctv3_lkp

read_code term_description
x05f4 Gadovist 1mmol/mL solution for injection prefilled syringe
x05f5 Gadobutrol 1mmol/mL solution for injection prefilled syringe
yz… Read Code drugs administration
yz1.. Read Code drugs administration
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_ctv3_icd9

read_code icd9_code
ZVu6e V433
ZVu6k V438
ZVu6l V458
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
ICD-9 is in the public domain so there are no copyright restrictions over its use. WHO no longer publishes or distributes ICD-9. NA

read_ctv3_icd10

read_code icd10_code
ZVu6m Z998
ZVy.. Z769
ZVz.. Z769
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
ICD-10 codes, terms and text used by permission of WHO, from: International Statistical Classification of Diseases and Related Health Problems, Tenth Revision (ICD-10). Vols 1-3. Geneva, World Health Organization, 1992-2016. NA

read_ctv3_opcs4

read_code opcs4_code
XaexI X629
Xafdi X612
Xaff0 X629
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA
The OPCS Classification of Interventions and Procedures, codes, terms and text is Crown copyright (2016) published by Health and Social Care Information Centre, also known as NHS Digital and licensed under the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

read_ctv3_read_v2

READV3_CODE TERMV3_CODE
Zw058 YM0dp
Zw059 YM0dq
Zw05A YM0dr
Zw05B YM0ds
NA NA
Contains information from NHS Digital, licenced under the current version of the Open Government Licence available at www.nationalarchives.gov.uk/doc/open-government-licence/open-government-licence.htm NA

Cannot just remove NA in column 2

Sheet N rows raw N rows rm NAs in col 2 Difference
bnf_lkp 79829 79827 2
dmd_lkp 434951 434949 2
icd9_lkp 7973 7971 2
icd10_lkp 17936 17934 2
icd9_icd10 16163 9728 6435
read_v2_lkp 101883 101881 2
read_v2_drugs_lkp 67614 67612 2
read_v2_drugs_bnf 67615 58354 9261
read_v2_icd9 35664 35661 3
read_v2_icd10 36667 36664 3
read_v2_opcs4 14927 14924 3
read_v2_read_ctv3 108245 108243 2
read_ctv3_lkp 419098 419096 2
read_ctv3_icd9 67155 67152 3
read_ctv3_icd10 116377 116374 3
read_ctv3_opcs4 54321 54318 3
read_ctv3_read_v2 777522 777520 2

Instead, determine N rows to remove manually

Sheet N rows raw N rows reformatted Difference
bnf_lkp 79829 79827 2
dmd_lkp 434951 434949 2
icd9_lkp 7973 7971 2
icd10_lkp 17936 17934 2
icd9_icd10 16163 16160 3
read_v2_lkp 101883 101881 2
read_v2_drugs_lkp 67614 67612 2
read_v2_drugs_bnf 67615 67612 3
read_v2_icd9 35664 35661 3
read_v2_icd10 36667 36664 3
read_v2_opcs4 14927 14924 3
read_v2_read_ctv3 108245 108243 2
read_ctv3_lkp 419098 419096 2
read_ctv3_icd9 67155 67152 3
read_ctv3_icd10 116377 116374 3
read_ctv3_opcs4 54321 54318 3
read_ctv3_read_v2 777522 777520 2

bnf_lkp

BNF codes in the UK Biobank linked primary care dataset are of variable length (see UKB resource 591).

extend_bnf_lkp() creates all possible versions for BNF codes in bnf_lkp. This facilitates selecting all drugs under a certain chapter/section/etc e.g. to get all BNF codes for all medications in the ‘Treatment Of Glaucoma’ section (i.e. BNF codes starting with 1106). This table shows the results for the first drug in this section:

bnf_read2

All BNF codes in the bnf_code col are 8 digits long. Digit 7 corresponds to BNF sub paragraph - this is expanded to 2 digits by prefixing with a 0 in bnf_code.

Note that there are a number of Read 2 codes that have not been mapped to BNF (NA in the table below):

Digits 7 and 8, bnf_code col n
00 55068
01 1436
02 913
03 877
04 53
05 7
NA 9258

…in most cases, BNF_Paragraph = BNF_Subparagraph. For an example of where these can differ, see BNF paragraph Renin-Angiotensin System Drugs.

extend_read_v2_drugs_bnf() appends Read 2 and BNF descriptions to the read_v2_drugs_bnf table, the first few rows are shown below:

bnf_dmd

This is downloaded from the NHSBSA website. There are no ‘extra’ rows that need removing at the bottom.

To map BNF codes to DM+D:

Note: There are 184 out of 354 glaucoma medication codes that are not present in bnf_dmd

# A tibble: 6 × 11
  presentation_pack_level vmp_vmpp_amp_ampp bnf_code        bnf_name snomed_code
  <chr>                   <chr>             <chr>           <chr>    <chr>      
1 Presentation            VMP               1106000L0AAAAAA Latanop… 330729005  
2 Pack                    VMPP              1106000L0AAAAAA Latanop… 1075711000…
3 Presentation            AMP               1106000L0BBAAAA Xalatan… 3656110000…
4 Pack                    AMPP              1106000L0BBAAAA Xalatan… 1381911000…
5 Presentation            AMP               1106000L0AAAAAA Latanop… 1984741100…
6 Pack                    AMPP              1106000L0AAAAAA Latanop… 1984751100…
# … with 6 more variables: dm_d_product_description <chr>, strength <dbl>,
#   unit_of_measure <chr>, dm_d_product_and_pack_description <chr>, pack <dbl>,
#   sub_pack <chr>

icd10_lkp

For 254 codes where the 3 character category is undivided, ‘X’ is appended in the ALT_CODE column. These are listed below:

UK Biobank ICD-10 codes are recorded as per the ALT_CODE format, but does not append ‘X’ for these undivided 3 character category codes.

The ‘X’ is therefore removed when looking up codes from the icd_10 lookup sheet with argument standardise_output = TRUE. However, the ‘X’ is retained in the icd10_lkp sheet ALT_CODE column.

[1] TRUE
[1] TRUE

There are no ICD-10 codes with values for both MODIFIER_4 AND MODIFIER_5.

Examples of codes with modifiers: E10 and I70.0. For the latter, note that I70.0 in ICD10_CODE format can have (i) no modifier (ii) ‘without gangrene’ modifier, or (iii) ‘with gangrene’ modifier. In ALT_CODE format, these appear as I700, I7000 and I7001 respectively.

opcs4_lkp

There is no lookup sheet for OPCS4 codes in UK Biobank resource 592. This is therefore created instead from the UK Biobank codings file (coding 240


R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.2

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/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 testthat_3.0.4        ukbwranglr_0.0.0.9000
 [4] targets_0.8.0         crosstalk_1.1.1       readxl_1.3.1         
 [7] reactable_0.2.3       forcats_0.5.1         stringr_1.4.0        
[10] dplyr_1.0.7           purrr_0.3.4           readr_2.0.2          
[13] tidyr_1.1.4           tibble_3.1.4          ggplot2_3.3.5        
[16] tidyverse_1.3.1       workflowr_1.6.2      

loaded via a namespace (and not attached):
 [1] fs_1.5.0            usethis_2.0.1       fontawesome_0.2.2  
 [4] bit64_4.0.5         lubridate_1.7.10    devtools_2.4.2     
 [7] httr_1.4.2          rprojroot_2.0.2     tools_4.1.2        
[10] backports_1.2.1     bslib_0.3.0         utf8_1.2.2         
[13] R6_2.5.1            DBI_1.1.1           colorspace_2.0-2   
[16] withr_2.4.2         tidyselect_1.1.1    prettyunits_1.1.1  
[19] processx_3.5.2      bit_4.0.4           compiler_4.1.2     
[22] git2r_0.28.0        cli_3.0.1           rvest_1.0.1        
[25] xml2_1.3.2          desc_1.3.0          sass_0.4.0         
[28] scales_1.1.1        callr_3.7.0         shinyFeedback_0.4.0
[31] digest_0.6.28       rmarkdown_2.11      ini_0.3.1          
[34] pkgconfig_2.0.3     htmltools_0.5.2     sessioninfo_1.1.1  
[37] dbplyr_2.1.1        fastmap_1.1.0       highr_0.9          
[40] htmlwidgets_1.5.4   rlang_0.4.11        RSQLite_2.2.8      
[43] rstudioapi_0.13     shiny_1.7.0         jquerylib_0.1.4    
[46] generics_0.1.0      configr_0.3.5       jsonlite_1.7.2     
[49] magrittr_2.0.1      Rcpp_1.0.7          munsell_0.5.0      
[52] fansi_0.5.0         lifecycle_1.0.1     stringi_1.7.4      
[55] whisker_0.4         yaml_2.2.1          pkgbuild_1.2.0     
[58] blob_1.2.2          grid_4.1.2          promises_1.2.0.1   
[61] RcppTOML_0.1.7      crayon_1.4.1        haven_2.4.3        
[64] hms_1.1.1           knitr_1.34          ps_1.6.0           
[67] pillar_1.6.3        igraph_1.2.6        codetools_0.2-18   
[70] pkgload_1.2.2       reprex_2.0.1        glue_1.4.2         
[73] evaluate_0.14       remotes_2.4.0       data.table_1.14.2  
[76] renv_0.13.2         modelr_0.1.8        vctrs_0.3.8        
[79] tzdb_0.1.2          httpuv_1.6.3        cellranger_1.1.0   
[82] gtable_0.3.0        reactR_0.4.4        assertthat_0.2.1   
[85] cachem_1.0.6        xfun_0.24           mime_0.12          
[88] xtable_1.8-4        broom_0.7.9         later_1.3.0        
[91] memoise_2.0.0       ellipsis_0.3.2