Last updated: 2025-09-10
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 934b11f. 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_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/trait_ontology/
Ignored: renv/
Untracked files:
Untracked: code/get_term_descendants.R
Untracked: data/gbd/
Untracked: data/who/
Unstaged changes:
Modified: analysis/disease_inves_by_ancest.Rmd
Modified: analysis/index.Rmd
Deleted: analysis/level_1_disease_group.Rmd
Modified: analysis/level_2_disease_group.Rmd
Deleted: analysis/non_ontology_trait_collapse.Rmd
Deleted: analysis/trait_ontology_collapse.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_1_disease_group_non_cancer.Rmd
) and HTML
(docs/level_1_disease_group_non_cancer.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 | 934b11f | IJbeasley | 2025-09-10 | workflowr::wflow_publish("analysis/level_1_disease_group_non_cancer.Rmd") |
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"))
Level 1 disease grouping: - collapse disease causes, e.g. contact dermatitis due to nickel to contact dermatitis - collapse disease subtypes, e.g. bipolar I and bipolar II to bipolar disorder - collapse disease onset times, e.g. early-onset alzheimers disease and late-onset alzheimers disease to alzheimers disease - collapse disease stages
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms = 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] 3083 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] 2196
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"chronic kidney disease stage 5|chronic kidney disease stage 4",
"chronic kidney disease"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"stage 5 chronic kidney disease",
"chronic kidney disease"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"contact dermatitis due to nickel",
"contact dermatitis"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"habitual abortion|abortion|spontaneous loss of pregnancy|incomplete loss of pregnancy",
"loss of pregnancy"
))
# exact synonyms (to avoid partial matches
# https://www.ebi.ac.uk/ols4/ontologies/efo/classes/http%253A%252F%252Fwww.ebi.ac.uk%252Fefo%252FEFO_1001491?lang=en
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"asparaginase-induced acute pancreatitis",
"acute pancreatitis"
))
url<- "http://www.ebi.ac.uk/ols4/api/ontologies/mondo/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMONDO_0004907/descendants"
alopecia_terms <- get_descendants(url)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(alopecia_terms, collapse = "(?=,|$)|\\b"),
"alopecia"
))
alchol_use_disorder_terms <- c("alcohol dependence",
"alcohol withdrawal",
"alcohol withdrawal delirium",
"alcohol abuse",
"alcohol-related disorders delirium",
"alcohol use disorder",
"addictive alcohol use"
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
paste0(alchol_use_disorder_terms, collapse = "(?=,|$)|\\b"),
"alcohol-related disorders"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
paste0(alchol_use_disorder_terms, collapse = "(?=,|$)|\\b"),
"alcohol-related disorders"
))
alcoholic_liver_disease_terms <- c("alcoholic liver cirrhosis",
"alcoholic fatty liver disease",
"alcoholic hepatitis"
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
paste0(alcoholic_liver_disease_terms, collapse = "(?=,|$)|\\b"),
"alcoholic liver disease"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"early-onset alzheimers disease|late-onset alzheimers disease",
"alzheimers disease"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"allergic contact dermatitis of eyelid",
"allergic contact dermatitis"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"seasonal allergic rhinitis",
"allergic rhinitis"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"corneal astigmatism",
"astigmatism"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"atopic asthma|chronic obstructive asthma",
"asthma"
)) |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"childhood onset asthma|adult onset asthma|aspirin-induced asthma",
"asthma"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"autoimmune pancreatitis type 1",
"autoimmune pancreatitis"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"low back pain",
"back pain"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"bipolar ii disorder|bipolar i disorder",
"bipolar disorder"
))
gwas_study_info =
gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = "refractory celiac disease",
"celiac disease"
)
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"thiopurine immunosuppressant-induced pancreatitis|non-alcoholic pancreatitis",
"chronic pancreatitis"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"chronic rhinosinusitis with nasal polyps",
"chronic rhinosinusitis"
))
url <- "http://www.ebi.ac.uk/ols4/api/ontologies/efo/terms/http%253A%252F%252Fwww.ebi.ac.uk%252Fefo%252FEFO_0001645/descendants"
coronary_artery_disease_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 16
[1] "\n Some example terms"
[1] "non-obstructive coronary artery disease"
[2] "myocardial ischemia"
[3] "intermediate coronary syndrome"
[4] "coronary thrombosis"
[5] "coronary aneurysm"
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(coronary_artery_disease_terms, collapse = "(?=,|$)|\\b"),
"coronary artery disease"
))
congestive_heart_failure_terms <- c("systolic heart failure",
"diastolic heart failure",
"cor pulmonale",
"congenital heart disease",
"chronic pulmonary heart disease"
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(congestive_heart_failure_terms, collapse = "(?=,|$)|\\b"),
"congestive heart failure"
))
dental_caries_terms <- c("pit and fissure surface dental caries",
"smooth surface dental caries",
"primary dental caries",
"enamel caries",
"permanent dental caries"
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(dental_caries_terms, collapse = "(?=,|$)|\\b"),
"dental caries"
)
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"beta-lactam allergy",
"drug allergy"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"peanut allergy|milk allergy|egg allergy|wheat allergic reaction",
"food allergy"
))
url <- "http://www.ebi.ac.uk/ols4/api/ontologies/mondo/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMONDO_0003664/descendants"
hemolytic_anemia_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 76
[1] "\n Some example terms"
[1] "paroxysmal nocturnal hemoglobinuria"
[2] "non-autoimmune hemolytic anemia"
[3] "6-phosphogluconate dehydrogenase deficiency"
[4] "hereditary stomatocytosis"
[5] "autoimmune hemolytic anemia"
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(hemolytic_anemia_terms, collapse = "(?=,|$)|\\b"),
"hemolytic anemia"
))
gwas_study_info =
gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = "herpes simplex infection",
"herpesviridae infectious disease"
)
)
url <- "http://www.ebi.ac.uk/ols4/api/ontologies/efo/terms/http%253A%252F%252Fwww.ebi.ac.uk%252Fefo%252FEFO_0000537/descendants"
hypertension_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 46
[1] "\n Some example terms"
[1] "secondary hypertension" "treatment-resistant hypertension"
[3] "ocular hypertension" "malignant hypertension"
[5] "intracranial hypertension"
hypertension_terms = c("primary hypertension",
hypertension_terms
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(hypertension_terms, collapse = "(?=,|$)|\\b"),
"hypertension"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"hiv-1 infection",
"hiv infection"
))
hyperlipidemia_terms <- c("hypercholesterolemia",
"familial hypercholesterolemia",
"familial hyperlipidemia"
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(hyperlipidemia_terms, collapse = "(?=,|$)|\\b"),
"hyperlipidemia"
))
inborn_error_metab <- c("inborn disorder of amino acid metabolism",
"inborn disorder of amino acid transport",
"inborn disorder of porphyrin metabolism",
"inborn carbohydrate metabolic disorder",
"familial lipoprotein lipase deficiency",
"lactose intolerance",
"hereditary hemochromatosis",
"alpha 1-antitrypsin deficiency",
"urea cycle disorder",
"gaucher disease",
"plasma protein metabolism disease",
"disorder of metabolite absorption and transport")
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(inborn_error_metab, collapse = "(?=,|$)|\\b"),
"inborn errors of metabolism"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"bacterial meningitis|pneumococcal meningitis|viral meningitis",
"infectious meningitis"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"tubal factor infertility",
"female infertility"
)) |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"azoospermia",
"male infertility"
) )
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"influenza a \\(h1n1\\)",
"influenza"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms ,
"systemic juvenile idiopathic arthritis|oligoarticular juvenile idiopathic arthritis|
polyarticular juvenile idiopathic arthritis",
"juvenile idiopathic arthritis")
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"lewy body attribute",
"lewy body dementia"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"plasmodium falciparum malaria|plasmodium vivax malaria",
"malaria"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"methamphetamine dependence|methamphetamine-induced psychosis",
"methamphetamine use disorders"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"migraine disorder|migraine with aura|migraine without aura",
"migraine"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"relapsing-remitting multiple sclerosis",
"multiple sclerosis"
))
url <- "http://www.ebi.ac.uk/ols4/api/ontologies/efo/terms/http%253A%252F%252Fwww.ebi.ac.uk%252Fefo%252FEFO_0000612/descendants"
myocardial_infarction_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 7
[1] "\n Some example terms"
[1] "inferior myocardial infarction"
[2] "anterolateral myocardial infarction"
[3] "subsequent st elevation (stemi) and non-st elevation (nstemi) myocardial infarction"
[4] "acute myocardial infarction"
[5] "acute anterolateral myocardial infarction"
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(myocardial_infarction_terms, collapse = "(?=,|$)|\\b"),
"myocardial infarction"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"phototoxic dermatitis|skin sensitivity to sun",
"photosensitivity disease")
)
url <- "http://www.ebi.ac.uk/ols4/api/ontologies/efo/terms/http%253A%252F%252Fwww.ebi.ac.uk%252Fefo%252FEFO_1001908/descendants"
phobic_disorder_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 11
[1] "\n Some example terms"
[1] "specific phobia" "social anxiety disorder"
[3] "agoraphobia" "nosophobia"
[5] "flying phobia"
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(phobic_disorder_terms, collapse = "(?=,|$)|\\b"),
"phobic disorder"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"hereditary hemochromatosis type 1",
"hereditary hemochromatosis"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"late-onset myasthenia gravis",
"myasthenia gravis"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"aqp4-igg-negative neuromyelitis optica|aqp4-igg-positive neuromyelitis optica",
"neuromyelitis optica"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"neurofibromatosis type 1|neurofibromatosis type 2",
"neurofibromatosis"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"non-alcoholic steatohepatitis|non-alcoholic liver disease",
"non-alcoholic fatty liver disease"
))
gwas_study_info =
gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = "morbid obesity|metabolically healthy obesity",
"obesity"
)
)
pericardium_disorder_terms <- c("pericarditis",
"pericardial effusion"
)
psoriasis_terms <- c("psoriasis vulgaris",
"psoriasis area and severity index",
"cutaneous psoriasis",
"psoriatic arthritis",
"parapsoriasis")
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(psoriasis_terms, collapse = "(?=,|$)|\\b"),
"psoriasis")
)
ra_terms <- c("acpa-positive rheumatoid arthritis",
"acpa-negative rheumatoid arthritis")
gwas_study_info =
gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(ra_terms, collapse = "(?=,|$)|\\b"),
"rheumatoid arthritis"
)
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"adolescent idiopathic scoliosis",
"scoliosis")
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"sickle cell anemia",
"sickle cell disease and related diseases")
)
sleep_apnea_terms <- c("sleep apnea measurement during non-rem sleep",
"sleep apnea measurement during rem sleep",
"obstructive sleep apnea")
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(sleep_apnea_terms, collapse = "(?=,|$)|\\b"),
"sleep apnea")
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"methicillin-resistant staphylococcus aureus infection",
"staphylococcus aureus infection"
))
hemorrhage_terms <- c("intracerebral hemorrhage",
"non-lobar intracerebral hemorrhage",
"lobar intracerebral hemorrhage")
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(hemorrhage_terms, collapse = "(?=,|$)|\\b"),
"hemorrhagic stroke")
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"stroke outcome|large artery stroke|small vessel stroke|ischemic stroke|stroke disorder|cardioembolic stroke",
"stroke")
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"post-operative stroke",
"post-operative, stroke")
)
url <- "http://www.ebi.ac.uk/ols4/api/ontologies/efo/terms/http%253A%252F%252Fwww.ebi.ac.uk%252Fefo%252FEFO_0000717/descendants"
scleroderma_terms <- get_descendants(url)
[1] "Number of terms collected:"
[1] 5
[1] "\n Some example terms"
[1] "limited scleroderma"
[2] "anti-topoisomerase-i-antibody-positive systemic scleroderma"
[3] "anti-centromere-antibody-positive systemic scleroderma"
[4] "diffuse scleroderma"
[5] "limited cutaneous systemic sclerosis"
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(scleroderma_terms, collapse = "(?=,|$)|\\b"),
"systemic scleroderma"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"stenosing tenosynovitis",
"tenosynovitis")
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"latent autoimmune diabetes in adults",
"type 1 diabetes mellitus"
))
thrombocytopenia_terms <- c("thrombocytopenia 4",
"acquired thrombocytopenia",
"primary thrombocytopenia"
)
tinea_terms <- c("tinea pedis",
"tinea unguium",
"dermatophytosis"
)
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
pattern = paste0(tinea_terms, collapse = "(?=,|$)|\\b"),
"tinea"
))
gwas_study_info = gwas_study_info |>
mutate(l1_all_disease_terms =
stringr::str_replace_all(l1_all_disease_terms,
"vitamin b12 deficiency",
"vitamin b deficiency"
))
n_studies_trait = gwas_study_info |>
dplyr::filter(DISEASE_STUDY == T) |>
dplyr::select(l1_all_disease_terms, PUBMED_ID) |>
dplyr::distinct() |>
dplyr::group_by(l1_all_disease_terms) |>
dplyr::summarise(n_studies = dplyr::n()) |>
dplyr::arrange(desc(n_studies))
head(n_studies_trait)
# A tibble: 6 × 2
l1_all_disease_terms n_studies
<chr> <int>
1 type 2 diabetes mellitus 145
2 asthma 131
3 alzheimers disease 124
4 breast cancer 112
5 major depressive disorder 108
6 schizophrenia 103
dim(n_studies_trait)
[1] 2925 2
diseases <- stringr::str_split(pattern = ", ",
gwas_study_info$l1_all_disease_terms[gwas_study_info$l1_all_disease_terms != ""]) |>
unlist() |>
stringr::str_trim()
test <- data.frame(trait = unique(diseases))
length(unique(diseases))
[1] 2052
# 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 hypertension type 2 diabetes mellitus
10835 7093 922
coronary artery disease major depressive disorder alzheimers disease
514 471 422
asthma schizophrenia covid-19
357 356 305
breast cancer
270
fwrite(gwas_study_info,
here::here("output/gwas_cat/gwas_study_info_group_l1.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