Taming the Data Beast from “Cleaning Medical Data with R” workshop by Shannon Pileggi, Crystal Lewis and Peter Higgins presented at R/Medicine 2023. Illustrated by Allison Horst.
What is Coronary Artery Disease (CAD) ?
Coronary Artery Disease (CAD) happens when the coronary arteries from the heart become narrow or blocked by fatty deposits called plaque. This can lead to chest pain, shortness of breath or even heart attack.
Diagnosis of CAD includes invasive coronary angiography (right), or computerized tomography coronary angiogram (left).
Early detection and treatment of CAD can help improve the patient’s outcome.
Images from Latina et al. Radiology: Cardiothoracic Imaging 2021; 3(4):e210053 doi: 10.1148/ryct.2021210053.
What is Pretest Probability ?
Pretest probability is the estimated probability, given a set of risk factors, that a patient has a specific disease or condition before any diagnostic tests are performed.
It helps clinicians and doctors makes informed decision on which patients go for diagnostic tests, especially if the diagnostic test is expensive, invasive or time consuming to the patient.
# 30 female with symptom score of 3 and 0 risk factorscalculate_esc_2024_fig_4_ptp(age =30,sex ="female",chest_pain_type ="typical",have_dyspnoea ="no",have_family_history ="no",have_smoking_history ="no",have_dyslipidemia ="no",have_hypertension ="no",have_diabetes ="no",output ="percentage")
[1] "2%"
ESC 2024 guidelines from Vrints et al. European Heart journal 2024; 45(36):3415-3537 doi: 10.1093/eurheartj/ehae177.
Features of pretestcad
# 55 male with symptom score of 3 and 3 risk factors and 2 NAcalculate_esc_2024_fig_4_ptp(age =55,sex ="male",chest_pain_type ="typical",have_dyspnoea ="no",have_family_history =NA,have_smoking_history =NA,have_dyslipidemia ="yes",have_hypertension ="yes",have_diabetes ="yes",max_na_num_of_rf =2,output ="percentage")
[1] "27%"
ESC 2024 guidelines from Vrints et al. European Heart journal 2024; 45(36):3415-3537 doi: 10.1093/eurheartj/ehae177.
Features of pretestcad
patient_data <- tibble::tribble(~unique_id,~age, ~sex, ~chest_pain_type, ~have_dyspnoea, ~have_family_history, ~have_smoking_history, ~have_dyslipidemia, ~have_hypertension, ~have_diabetes,"45 year old male with typical chest pain, no dyspnoea, hypertension and diabetes",45, "male", "typical", "no", "no", "no", "no", "yes", "yes","70 year old female with no chest pain, dyspnoea, have smoking history (past or current smoker) and dyslipidemia",70, "female", "no chest pain", "yes", "no", "yes", "yes", "no", "no")risk_data <- patient_data |> dplyr::mutate(esc_2024_ptp_percent = purrr::pmap_chr(.l =list(age = .data[["age"]],sex = .data[["sex"]],chest_pain_type = .data[["chest_pain_type"]],have_dyspnoea = .data[["have_dyspnoea"]],have_family_history = .data[["have_family_history"]],have_smoking_history = .data[["have_smoking_history"]],have_dyslipidemia = .data[["have_dyslipidemia"]],have_hypertension = .data[["have_hypertension"]],have_diabetes = .data[["have_diabetes"]],output ="percentage" ),.f = pretestcad::calculate_esc_2024_fig_4_ptp ) ) |> dplyr::select(c("unique_id", "esc_2024_ptp_percent") )print(risk_data)
# A tibble: 2 × 2
unique_id esc_2024_ptp_percent
<chr> <chr>
1 45 year old male with typical chest pain, no dyspnoea, h… 20%
2 70 year old female with no chest pain, dyspnoea, have sm… 10%
Features of pretestcad
Applied this talk from useR! 2024 to write better error messages.
Error in `calculate_esc_2024_fig_4_ptp_simplfied()`:
! `sex` must be one of "female" or "male", not "ale".
ℹ Did you mean "male"?
Conclusion
Pretest probability for CAD is useful in patient management to ensure high-risk patients are diagnosed and treated early.
While there are many R packages developed to calculate risk of cardiovascular disease, there is currently no R package dedicated for calculating pretest probability for CAD.
R package pretestcad helps to ensure that these values can be calculated efficiently as number of patient increase and pretest probability models evolved over time.