Last updated: 2025-10-08
Checks: 7 0
Knit directory:
genomics_ancest_disease_dispar/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). 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.
Great job! The global environment was empty. Objects defined in the global environment 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.
The command set.seed(20220216) 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 81a7bd1. 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: .Rproj.user/
Ignored: data/.DS_Store
Ignored: data/gbd/.DS_Store
Ignored: data/gbd/IHME-GBD_2021_DATA-d8cf695e-1.csv
Ignored: data/gbd/ihme_gbd_2019_global_disease_burden_rate_all_ages.csv
Ignored: data/gbd/ihme_gbd_2019_global_paf_rate_percent_all_ages.csv
Ignored: data/gbd/ihme_gbd_2021_global_disease_burden_rate_all_ages.csv
Ignored: data/gbd/ihme_gbd_2021_global_paf_rate_percent_all_ages.csv
Ignored: data/gwas_catalog/
Ignored: data/icd/.DS_Store
Ignored: data/icd/IHME_GBD_2019_COD_CAUSE_ICD_CODE_MAP_Y2020M10D15.XLSX
Ignored: data/icd/IHME_GBD_2019_NONFATAL_CAUSE_ICD_CODE_MAP_Y2020M10D15.XLSX
Ignored: data/icd/IHME_GBD_2021_COD_CAUSE_ICD_CODE_MAP_Y2024M05D16.XLSX
Ignored: data/icd/IHME_GBD_2021_NONFATAL_CAUSE_ICD_CODE_MAP_Y2024M05D16.XLSX
Ignored: data/icd/UK_Biobank_master_file.tsv
Ignored: data/icd/cdc_valid_icd10_Sep_23_2025.xlsx
Ignored: data/icd/cdc_valid_icd9_Sep_23_2025.xlsx
Ignored: data/icd/manual_disease_icd10_mappings.xlsx
Ignored: data/icd/phecode_international_version_unrolled.csv
Ignored: data/icd/semiautomatic_ICD-pheno.txt
Ignored: data/icd/~$IHME_GBD_2019_COD_CAUSE_ICD_CODE_MAP_Y2020M10D15.XLSX
Ignored: data/icd/~$IHME_GBD_2019_NONFATAL_CAUSE_ICD_CODE_MAP_Y2020M10D15.XLSX
Ignored: data/who/
Ignored: diseases.txt
Ignored: manual_icd10_mappings.xlsx
Ignored: not_found_diseases.txt
Ignored: orig_phecode_map.csv
Ignored: original_phecodes_pheinfo.csv
Ignored: output/.DS_Store
Ignored: output/gwas_cat/
Ignored: output/gwas_study_info_cohort_corrected.csv
Ignored: output/gwas_study_info_trait_corrected.csv
Ignored: output/gwas_study_info_trait_ontology_info.csv
Ignored: output/gwas_study_info_trait_ontology_info_l1.csv
Ignored: output/gwas_study_info_trait_ontology_info_l2.csv
Ignored: output/icd_map/
Ignored: output/trait_ontology/
Ignored: renv/
Ignored: sup_table.xlsx
Ignored: zooma.tsv
Ignored: zooma_res.tsv
Untracked files:
Untracked: analysis/garbage_icd_codes.Rmd
Untracked: analysis/gwas_to_gbd.Rmd
Untracked: disease_mapping.R
Unstaged changes:
Modified: analysis/disease_inves_by_ancest.Rmd
Modified: analysis/gbd_data_plots.Rmd
Modified: analysis/index.Rmd
Modified: analysis/level_1_disease_group_non_cancer.Rmd
Modified: analysis/level_2_disease_group.Rmd
Modified: analysis/map_trait_to_icd10.Rmd
Modified: analysis/other_disease_filtering.Rmd
Modified: analysis/trait_ontology_categorization.Rmd
Modified: data/icd/README.md
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/grouping_infectious_diseases.Rmd) and HTML
(docs/grouping_infectious_diseases.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 | 81a7bd1 | IJbeasley | 2025-10-08 | No longer removing many infectious diseases |
library(dplyr)
library(data.table)
library(stringr)
source(here::here("code/get_term_descendants.R"))
gwas_study_info <- fread(here::here("output/gwas_cat/gwas_study_info_disease_trait_simplified.csv"))
diseases <- stringr::str_split(pattern = ", ",
gwas_study_info$collected_all_disease_terms[gwas_study_info$collected_all_disease_terms != ""]) |>
unlist() |>
stringr::str_trim()
length(unique(diseases))
[1] 2187
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms =
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("hiv-1 infection"),
"hiv infection"
))
tb_terms <- c("mycobacterium tuberculosis infection",
"pulmonary tuberculosis",
"extrapulmonary tuberculosis",
"meningeal tuberculosis")
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms =
stringr::str_replace_all(collected_all_disease_terms,
pattern = vec_to_grep_pattern(tb_terms),
"tuberculosis"
))
# in the case of acute / chronic bronchitis, we will remove only acute
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("acute bronchitis", `DISEASE/TRAIT`, ignore.case = T) &
grepl(vec_to_grep_pattern("bronchitis"),
collected_all_disease_terms,
ignore.case = T,
perl = T),
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("bronchitis"),
"acute bronchitis"),
collected_all_disease_terms
))
# if bronchitis is specified as chronic in DISEASE/TRAIT, replace bronchitis with chronic bronchitis
# in to collected_all_disease_terms
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("chronic bronchitis", `DISEASE/TRAIT`, ignore.case = T) &
grepl(vec_to_grep_pattern("bronchitis"),
collected_all_disease_terms,
ignore.case = T,
perl = T),
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("bronchitis"),
"chronic bronchitis"),
collected_all_disease_terms
))
# similar, for bronchiolitis, remove if acute
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("acute bronchiolitis", `DISEASE/TRAIT`, ignore.case = T) &
grepl(vec_to_grep_pattern("bronchiolitis"),
collected_all_disease_terms,
ignore.case = T,
perl = T),
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("bronchiolitis"),
"acute bronchiolitis"),
collected_all_disease_terms
))
# remove larygitis, if acute
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("acute laryngitis", `DISEASE/TRAIT`, ignore.case = T) &
grepl(vec_to_grep_pattern("laryngitis"),
collected_all_disease_terms,
ignore.case = T,
perl = T),
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("laryngitis"),
"acute laryngitis"),
collected_all_disease_terms
))
# if laryngitis is specified as acute in DISEASE/TRAIT, remove disease from collected_all_disease_terms
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("acute laryngitis", `DISEASE/TRAIT`, ignore.case = T) &
collected_all_disease_terms == "disease",
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("disease"),
"acute laryngitis"),
collected_all_disease_terms
))
# if laryngitis is specified as chronic in DISEASE/TRAIT, replace laryngitis with chronic laryngitis
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("chronic laryngitis", `DISEASE/TRAIT`, ignore.case = T) &
grepl(vec_to_grep_pattern("laryngitis"),
collected_all_disease_terms,
ignore.case = T,
perl = T),
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("laryngitis"),
"chronic laryngitis"),
collected_all_disease_terms
))
# for tonsillitis, remove if acute
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("acute tonsillitis|ICD10 J03", `DISEASE/TRAIT`, ignore.case = T) &
grepl(vec_to_grep_pattern("tonsillitis"),
collected_all_disease_terms,
ignore.case = T,
perl = T),
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("tonsillitis"),
"acute tonsillitis"),
collected_all_disease_terms
))
# remove disease, if DISEASE/TRAIT contains acute tonsillitis
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("acute tonsillitis", `DISEASE/TRAIT`, ignore.case = T) &
collected_all_disease_terms == "disease",
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("disease"),
"acute tonsillitis"),
collected_all_disease_terms
))
# for tonsillitis, if chronic in DISEASE/TRAIT, replace tonsillitis with chronic tonsillitis
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("chronic tonsillitis", `DISEASE/TRAIT`, ignore.case = T) &
grepl(vec_to_grep_pattern("tonsillitis"),
collected_all_disease_terms,
ignore.case = T,
perl = T),
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("tonsillitis"),
"chronic tonsillitis"),
collected_all_disease_terms
))
url <- "http://www.ebi.ac.uk/ols4/api/ontologies/doid/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FDOID_10754/descendants"
otitis_media_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 20
[1] "\n Some example terms"
[1] "chronic tubotympanic suppurative otitis media"
[2] "acute allergic sanguinous otitis media"
[3] "acute allergic mucoid otitis media"
[4] "acute allergic serous otitis media"
[5] "middle ear cholesterol granuloma"
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms =
stringr::str_replace_all(collected_all_disease_terms,
pattern = vec_to_grep_pattern(otitis_media_terms),
"otitis media"
))
# where collected_all_disease_terms==disease, and otitis media in DISEASE/TRAIT, remove disease
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("otitis media", `DISEASE/TRAIT`, ignore.case = T) &
collected_all_disease_terms == "disease",
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("disease"),
"otitis media"),
collected_all_disease_terms
))
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms =
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("influenza a \\(h1n1\\)"),
"influenza"
))
# if diarrhea is caused by IBS, add ibs to collected_all_disease_terms
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(grepl("IBS", `DISEASE/TRAIT`, ignore.case = T) &
grepl("diarrhea", collected_all_disease_terms, ignore.case = T),
paste0(collected_all_disease_terms, ", irritable bowel syndrome"),
collected_all_disease_terms
)
)
# remove dysentery
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms =
stringr::str_remove_all(collected_all_disease_terms,
pattern = vec_to_grep_pattern("dysentery")
)
)
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms =
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern(
c("plasmodium falciparum malaria",
"plasmodium vivax malaria"
)),
"malaria"
))
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms =
stringr::str_replace_all(collected_all_disease_terms,
pattern = vec_to_grep_pattern(c(
"visceral leishmaniasis",
"cutaneous leishmaniasis")
),
"leishmaniasis"
)
)
gwas_study_info =
gwas_study_info |>
mutate(collected_all_disease_terms =
stringr::str_replace_all(collected_all_disease_terms,
vec_to_grep_pattern("dengue hemorrhagic fever"),
"dengue"
))
gwas_study_info |>
filter(grepl("dengue", collected_all_disease_terms, ignore.case = T)) |>
select(`DISEASE/TRAIT`, collected_all_disease_terms)
DISEASE/TRAIT collected_all_disease_terms
<char> <char>
1: Dengue shock syndrome dengue
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms =
ifelse(`DISEASE/TRAIT` == "Acute hepatitis A infection",
stringr::str_replace_all(collected_all_disease_terms,
pattern = vec_to_grep_pattern("hepatitis a infection"),
"acute hepatitis a infection"
),
collected_all_disease_terms
)
)
gwas_study_info =
gwas_study_info |>
rowwise() |>
mutate(collected_all_disease_terms = paste0(sort(unique(unlist(strsplit(collected_all_disease_terms, ", ")))),
collapse = ", ")
) |>
ungroup()
gwas_study_info = gwas_study_info |>
mutate(collected_all_disease_terms = stringr::str_remove_all(collected_all_disease_terms, "^,|,$")
) |>
mutate(collected_all_disease_terms = stringr::str_trim(collected_all_disease_terms)
)
n_studies_trait = gwas_study_info |>
dplyr::filter(DISEASE_STUDY == T) |>
dplyr::select(collected_all_disease_terms, PUBMED_ID) |>
dplyr::distinct() |>
dplyr::group_by(collected_all_disease_terms) |>
dplyr::summarise(n_studies = dplyr::n()) |>
dplyr::arrange(desc(n_studies))
head(n_studies_trait)
# A tibble: 6 × 2
collected_all_disease_terms n_studies
<chr> <int>
1 type 2 diabetes mellitus 145
2 alzheimers disease 116
3 breast cancer 112
4 asthma 110
5 major depressive disorder 108
6 schizophrenia 103
dim(n_studies_trait)
[1] 3016 2
diseases <- stringr::str_split(pattern = ", ",
gwas_study_info$collected_all_disease_terms[gwas_study_info$collected_all_disease_terms != ""]) |>
unlist() |>
stringr::str_trim()
length(unique(diseases))
[1] 2167
fwrite(gwas_study_info,
here::here("output/gwas_cat/gwas_study_info_disease_trait_filtered.csv"))
sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 15.6.1
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: America/Los_Angeles
tzcode source: internal
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] jsonlite_2.0.0 httr_1.4.7 stringr_1.5.1 data.table_1.17.8
[5] dplyr_1.1.4 workflowr_1.7.1
loaded via a namespace (and not attached):
[1] compiler_4.3.1 renv_1.0.3 promises_1.3.3 tidyselect_1.2.1
[5] Rcpp_1.1.0 git2r_0.36.2 callr_3.7.6 later_1.4.2
[9] jquerylib_0.1.4 yaml_2.3.10 fastmap_1.2.0 here_1.0.1
[13] R6_2.6.1 generics_0.1.4 curl_6.4.0 knitr_1.50
[17] tibble_3.3.0 rprojroot_2.1.0 bslib_0.9.0 pillar_1.11.0
[21] rlang_1.1.6 utf8_1.2.6 cachem_1.1.0 stringi_1.8.7
[25] httpuv_1.6.16 xfun_0.52 getPass_0.2-4 fs_1.6.6
[29] sass_0.4.10 cli_3.6.5 withr_3.0.2 magrittr_2.0.3
[33] ps_1.9.1 digest_0.6.37 processx_3.8.6 rstudioapi_0.17.1
[37] lifecycle_1.0.4 vctrs_0.6.5 evaluate_1.0.4 glue_1.8.0
[41] whisker_0.4.1 rmarkdown_2.29 tools_4.3.1 pkgconfig_2.0.3
[45] htmltools_0.5.8.1