I have the following script to create a figure:
histogram_endo_cases_controls <- ggplot(prs_data, aes(x = normalized, fill = as.factor(endometriosis))) +
geom_histogram(position = "identity", alpha = 0.5, binwidth = 0.2, color = "black") +
scale_fill_manual(values = c("blue", "yellow"),
labels = c("Controls", "Cases"),
name = "Group") +
labs(title = "Histogram of Polygenic Risk Scores",
x = "PRS",
y = "Frequency") +
theme_minimal()
The data I am plotting are scores for two groups, cases and controls. Cases are coded as 1, and controls are coded as 0.
I would like to plot the percentage of individuals experiencing the same score both in cases and controls, because I have a big difference in the numbers (significantly more controls). So the plot would look like the attached example (y axis having a percentage so the histograms have the same height).