Last updated: 2025-09-09

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 9c64867. 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/gwas_catalog/
    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/trait_ontology/
    Ignored:    renv/

Untracked files:
    Untracked:  analysis/disease_burden.qmd
    Untracked:  data/gbd/
    Untracked:  data/who/

Unstaged changes:
    Modified:   analysis/disease_inves_by_ancest.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/level_2_disease_group.Rmd) and HTML (docs/level_2_disease_group.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 9c64867 IJbeasley 2025-09-09 Minor fixing of disease trait categorisation
html fa509c0 IJbeasley 2025-09-08 Build site.
Rmd c9602c7 IJbeasley 2025-09-08 More grouping to match GBD

1 Set up

library(dplyr)
library(data.table)
library(ggplot2)
library(stringr)
gwas_study_info <- fread(here::here("output/gwas_study_info_trait_ontology_info_l1.csv"))

1.1 Grouping - level 2 set up

gwas_study_info = gwas_study_info |>
  mutate(l2_all_disease_terms = l1_all_disease_terms)

1.2 Ontology help - for getting disease subtypes

library(httr)
library(jsonlite)


get_descendants <- function(url){
  
  terms <- c()

repeat {
  res <- GET(url)
  stop_for_status(res)
  data <- fromJSON(content(res, as = "text", encoding = "UTF-8"))
  
  terms <- c(terms, data$`_embedded`$terms$label)
  
  # check if there is a next page
  if (!is.null(data$`_links`$`next`$href)) {
    url <- data$`_links`$`next`$href
  } else {
    break
  }
}
  
terms = unlist(terms)
terms = stringr::str_trim(tolower(terms))
terms = unique(terms)
  
print("Number of terms collected:")
print(length(terms))

print("\n Some example terms")
print(terms[1:5])

return(terms)


}

1.3 Acne vulgaris

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "acne",
                                   "acne vulgaris"
                          )  
        )

1.4 ADHD

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "adhd",
                                   "attention-deficit/hyperactivity disorder"
                          )  
        )

1.6 Alcohol use disorders

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "alcohol-related disorders|alcohol and nicotine codependence",
                                   "alcohol use disorders"
                          )  
        )

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "alcohol use disorder",
                                   "alcohol use disorders"
                          )  
        )

1.7 Alzheimer’s disease and other dementias

dementia <- c("aids dementia",
              "dementia",
              "frontotemporal dementia",
              "lewy body dementia",
              "vascular dementia",
              "alzheimers disease"
)

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = paste0(dementia, collapse = "|"),
                                   "alzheimer's disease and other dementias"
                          )  
        )

1.8 Anxiety disorders

url <- "http://www.ebi.ac.uk/ols4/api/ontologies/mesh/terms/http%253A%252F%252Fid.nlm.nih.gov%252Fmesh%252FD001008/descendants"

anxiety_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 15
[1] "\n Some example terms"
[1] "panic disorder"                "obsessive-compulsive disorder"
[3] "neurotic disorders"            "neurocirculatory asthenia"    
[5] "phobic disorders"             
gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = paste0(anxiety_terms, collapse = "|"),
                                   "anxiety disorders"
                          )  
        ) |>
   mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "anxiety disorder|anxiety measurement",
                                   "anxiety disorders"
                          )  
        ) |>
     mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "anxiety",
                                   "anxiety disorders"
                          )  
        )

1.9 Atrial fibrillation & flutter

afib_terms <- c("atrial fibrillation",
                "atrial flutter",
                "post-operative atrial fibrillation")

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = paste0(afib_terms, collapse = "|"),
                                   "atrial fibrillation and flutter"
                          )  
        )

1.10 Amphetamine use disorders

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "methamphetamine",
                                   "amphetamine"
                          )  
        )

1.11 Aortic aneurysm

url <- "http://www.ebi.ac.uk/ols4/api/ontologies/cvdo/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FDOID_3627/descendants"

aortic_aneurysm_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 6
[1] "\n Some example terms"
[1] "abdominal aortic aneurysm"          "ruptured aortic aneurysm"          
[3] "thoracic aortic aneurysm"           "ruptured thoracic aortic aneurysm" 
[5] "ruptured abdominal aortic aneurysm"
gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = paste0(aortic_aneurysm_terms, collapse = "|"),
                                   "aortic aneurysm"
                          )  
        )

1.12 Autism spectrum disorders

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms,
                                  pattern = "autism",
                                   "autism spectrum disorders"
                          )  
        )

1.13 Blindness and vision loss

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "blindness|color vision disorder|vision disorder|myopia|refractive error|hyperopia|astigmatism|corneal astigmatism|presbyopia|anisometropia|esotropia|on-accomodative esotropia|ccommodative esotropia",
                                   "blindness and vision loss"
                          )  
        )

1.14 Cannabis use disorders

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "cannabis dependence",
                                   "cannabis use disorders"
                          )  
        )

1.14.1 Cancers

1.14.1.1 Bladder cancer

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "urinary bladder cancer, disease progression measurement|b;adder tumor",
                                   "bladder cancer"
                          )  
        )

1.14.1.2 Colon and rectum cancer

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "colorectal cancer",
                                   "colon and rectum cancer"
                          )  
        )

1.14.1.3 Eye cancer

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "ocular melanoma|ocular cancer",
                                   "eye cancer"
                          )  
        )

1.14.1.4 Hodgkins lymphoma

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "hodgkins lymphoma",
                                   "hodgkin lymphoma"
                          )  
        )

1.14.1.5 Non-hodgkin lymphoma

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "non-hodgkins lymphoma",
                                   "non-hodgkin lymphoma"
                          )  
        )

1.14.2 Tracheal, bronchus, and lung cancer

resp_cancer_terms = c("lung cancer",
                      "bronchus cancer",
                      "respiratory system cancer"
                        )

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = paste0(resp_cancer_terms, collapse = "|"),
                                   "tracheal, bronchus, and lung cancer"
                          )  
        )

1.15 Cirrhosis & other chronic liver diseases

url <- "http://www.ebi.ac.uk/ols4/api/ontologies/snomed/terms/http%253A%252F%252Fsnomed.info%252Fid%252F328383001/descendants"

chronic_liver_disease_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 114
[1] "\n Some example terms"
[1] "chronic necrosis of liver"                                               
[2] "chronic nonalcoholic liver disease"                                      
[3] "chronic hepatitis"                                                       
[4] "progressive intrahepatic cholestasis"                                    
[5] "pulmonary fibrosis, hepatic hyperplasia, bone marrow hypoplasia syndrome"
gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms,
                                  pattern = paste0(chronic_liver_disease_terms, collapse = "|"),
                                   "cirrhosis and other chronic liver diseases"
                          )  
        )

1.16 Cocaine use disorders

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "cocaine-related disorders",
                                   "cocaine use disorders"
                          )  
        )

1.17 Depressive disorders

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "depressive symptom measurement|major depressive disorder",
                                   "depressive disorders"
                          )  
        ) |>
   mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "depressive disorder",
                                   "depressive disorders"
                          )  
        )

1.18 Gallbladder and biliary diseases

gal_bile_terms = c("gallbladder disease",
                   "bile duct disorder",
                   "biliary tract disease")


gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms,
                                  pattern = paste0(gal_bile_terms, collapse = "|"),
                                   "gallbladder and biliary diseases"
                          )  
        )

1.19 Gynecological diseases

diseases <- stringr::str_split(pattern = ", ", 
                               gwas_study_info$l2_all_disease_terms)  |> 
            unlist() |>
            stringr::str_trim()


pregnancy_terms <- grep("pregnancy", diseases, value = T)

gyno_terms <- c("endometriosis","placenta disease", pregnancy_terms)


gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms,
                                  pattern = paste0(gyno_terms, collapse = "|"),
                                   "gynecological diseases"
                          )  
        )

1.20 Eating disorders

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "bulimia nervosa|anorexia nervosa|binge eating|eating disorder",
                                  "eating disorders"
                          )  
        ) |>
   mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "anorexia",
                                  "eating disorders"
                          )  
        )

1.21 Headache disorders

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms,
                                  pattern = "headache disorder|cluster headache|migraine",
                                   "headache disorders"
                          )  
        )

1.22 Ischemic heart disease

== coronary artery disease (https://www.ncbi.nlm.nih.gov/books/NBK209964/)

gwas_study_info = gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms,
                                  pattern = "coronary artery disease",
                                   "ischemic heart disease"
                          )  
        )

1.23 Opioid use disorders

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "opioid dependence|opioid use disorder",
                                   "opioid use disorders"
                          )  
        )

1.24 Parkinsons disease

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "parkinsons disease",
                                   "parkinson's disease"
                          )  
        )

1.25 Other drug use disorders

gwas_study_info = 
gwas_study_info |> 
 mutate(l2_all_disease_terms  = 
          stringr::str_replace_all(l2_all_disease_terms ,
                                  pattern = "heroin dependence|drug dependence|nictone dependence|substance abuse|drug misuse|alcohol use disorders delirium",
                                   "other drug use disorders"
                          )  
        )

3 Malignant skin melanoma

and remove alz, parks, dementia

4 Other mental disorders

5 Check compatibility with gbd data

gbd_data <- data.table::fread(here::here("data/gbd/IHME-GBD_2021_DATA-aa22a7fd-1.csv"))

diseases <- stringr::str_split(pattern = ", ", 
                               gwas_study_info$l2_all_disease_terms)  |> 
            unlist() |>
            stringr::str_trim()

gbd_data$cause[!tolower(gbd_data$cause) %in% unique(diseases)] |> sort()
 [1] "Acute glomerulonephritis"                              
 [2] "Alopecia areata"                                       
 [3] "Bacterial skin diseases"                               
 [4] "Brain and central nervous system cancer"               
 [5] "Cardiomyopathy and myocarditis"                        
 [6] "Drug use disorders"                                    
 [7] "Endocrine, metabolic, blood, and immune disorders"     
 [8] "Fungal skin diseases"                                  
 [9] "Gallbladder and biliary tract cancer"                  
[10] "Hemoglobinopathies and hemolytic anemias"              
[11] "Idiopathic developmental intellectual disability"      
[12] "Idiopathic epilepsy"                                   
[13] "Inguinal, femoral, and abdominal hernia"               
[14] "Interstitial lung disease and pulmonary sarcoidosis"   
[15] "Lower extremity peripheral arterial disease"           
[16] "Malignant neoplasm of bone and articular cartilage"    
[17] "Malignant skin melanoma"                               
[18] "Nasopharynx cancer"                                    
[19] "Neuroblastoma and other peripheral nervous cell tumors"
[20] "Non-rheumatic valvular heart disease"                  
[21] "Oral disorders"                                        
[22] "Other cardiovascular and circulatory diseases"         
[23] "Other chronic respiratory diseases"                    
[24] "Other digestive diseases (internal)"                   
[25] "Other malignant neoplasms"                             
[26] "Other mental disorders"                                
[27] "Other musculoskeletal disorders"                       
[28] "Other neoplasms"                                       
[29] "Other neurological disorders"                          
[30] "Other sense organ diseases"                            
[31] "Other skin and subcutaneous diseases"                  
[32] "Paralytic ileus and intestinal obstruction"            
[33] "Pulmonary Arterial Hypertension"                       
[34] "Scabies"                                               
[35] "Soft tissue and other extraosseous sarcomas"           
[36] "Sudden infant death syndrome"                          
[37] "Tracheal, bronchus, and lung cancer"                   
[38] "Upper digestive system diseases"                       
[39] "Urinary diseases and male infertility"                 
[40] "Vascular intestinal disorders"                         
[41] "Viral skin diseases"                                   
diseases <- stringr::str_split(pattern = ", ", 
                               gwas_study_info$l2_all_disease_terms)  |> 
            unlist() |>
            stringr::str_trim()

length(unique(diseases))
[1] 1957
# make frequency table
freq <- table(as.factor(diseases))

# sort in decreasing order
freq_sorted <- sort(freq, decreasing = TRUE)

# show top N, e.g. top 10
head(freq_sorted, 10)

                                                         chronic kidney disease 
                                 106889                                   10828 
                           hypertension                type 2 diabetes mellitus 
                                   7093                                     922 
                  depressive disorderss                  ischemic heart disease 
                                    607                                     514 
                          breast cancer alzheimer's disease and other dementias 
                                    402                                     377 
                          schizophrenia                                  asthma 
                                    356                                     355 

5.0.1 Save the updated gwas_study_info with harmonized disease terms

gwas_study_info <- fwrite(gwas_study_info,
                          here::here("output/gwas_study_info_trait_ontology_info_l2.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     ggplot2_3.5.2    
[5] data.table_1.17.8 dplyr_1.1.4       workflowr_1.7.1  

loaded via a namespace (and not attached):
 [1] gtable_0.3.6       compiler_4.3.1     renv_1.0.3         promises_1.3.3    
 [5] tidyselect_1.2.1   Rcpp_1.1.0         git2r_0.36.2       callr_3.7.6       
 [9] later_1.4.2        jquerylib_0.1.4    scales_1.4.0       yaml_2.3.10       
[13] fastmap_1.2.0      here_1.0.1         R6_2.6.1           generics_0.1.4    
[17] curl_6.4.0         knitr_1.50         tibble_3.3.0       rprojroot_2.1.0   
[21] RColorBrewer_1.1-3 bslib_0.9.0        pillar_1.11.0      rlang_1.1.6       
[25] cachem_1.1.0       stringi_1.8.7      httpuv_1.6.16      xfun_0.52         
[29] getPass_0.2-4      fs_1.6.6           sass_0.4.10        cli_3.6.5         
[33] withr_3.0.2        magrittr_2.0.3     ps_1.9.1           grid_4.3.1        
[37] digest_0.6.37      processx_3.8.6     rstudioapi_0.17.1  lifecycle_1.0.4   
[41] vctrs_0.6.5        evaluate_1.0.4     glue_1.8.0         farver_2.1.2      
[45] whisker_0.4.1      rmarkdown_2.29     tools_4.3.1        pkgconfig_2.0.3   
[49] htmltools_0.5.8.1