# Define color palette
col_pce <- rev(brewer.pal(10, "Paired"))
col_p <- c(
col_pce[1:3], col_pce[5], col_pce[4], col_pce[c(6, 10)], "black",
col_pce[9], "turquoise", col_pce[7]
)
# Plot HR
hr_ukb_all <- haz %>%
filter(variable %in% c("Diabetes mellitus", "Smoking", "Polygenic risk score", "HDL cholesterol", "Systolic blood pressure", "Total cholesterol")) %>%
ggplot(aes(x = age, y = value, colour = variable, fill = variable)) +
stat_smooth(method = "loess", span = 1) +
scale_color_manual(values = col_p, drop = TRUE, breaks = factor_levels) +
scale_fill_manual(values = col_p, drop = TRUE, breaks = factor_levels, guide = "none") +
labs(y = "Hazard Ratio of Coronary Artery Disease", x = "Age of Risk Assessment", colour = "Risk Factor") +
theme_classic(base_size = 20) +
ylim(0.35, 5)
# Plot R2
r2_ukb_all <- r2s %>%
filter(variable %in% c("Diabetes mellitus", "Smoking", "Polygenic risk score", "HDL cholesterol", "Systolic blood pressure", "Total cholesterol")) %>%
ggplot(aes(x = age, y = round(value, 2), colour = variable, fill = variable)) +
stat_smooth(method = "loess", span = 1) +
scale_color_manual(values = col_p, drop = TRUE, breaks = factor_levels) +
scale_fill_manual(values = col_p, drop = TRUE, breaks = factor_levels, guide = "none") +
labs(y = "Proportion of Variation Explained", x = "Age of Risk Assessment", colour = "Risk Factor") +
theme_classic(base_size = 20) +
ylim(0, 0.18)
# Save plots
# saveRDS(hr_ukb_all, "output/hall_withPC.rds")
# saveRDS(r2_ukb_all, "output/r2_withPC.rds")