I have the following dataset:
beta pval Category_name
0.5 0.005 One
-0.3 0.6 Two
0.2 0.03 Three
-0.1 0.7 Four
I am trying to make a figure using pval (y axis) and Category_name (x axis). I would like to use shape 24 when beta is positive, and shape 25 when beta is negative, but still plotting pval.
My script looks like this:
library(ggplot2)
library(RColorBrewer)
colourCount <- length(unique(dup_categories_merged_allSNP$Category_name))
getPalette <- colorRampPalette(brewer.pal(9, "Set1"))
dup_categories_merged_allSNP$shape <- ifelse(dup_categories_merged_allSNP$beta > 0, 24, 25)
PheWAS_all <- ggplot(dup_categories_merged_allSNP, aes(x = Category_name, y = -log10(pval), shape = shape, colour = Category_name)) +
geom_point(size = 2) +
geom_jitter() +
theme_classic() +
scale_colour_manual(values = getPalette(colourCount)) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 0, size = 10),
axis.title.x = element_blank(),
legend.position = "none") +
labs(color = "Category_name", x = "", y = "-log10(pval)") +
geom_hline(yintercept = -log10(3.65E-09), color = "darkmagenta", linetype = "dashed", size = 1, alpha = 0.5) +
geom_hline(yintercept = -log10(0.000740457), color = "gray32", linetype = "dashed", size = 1, alpha = 0.5)
I get the following error message: Error in scale_f()
:! A continuous variable can not be mapped to shape.
Edit: Original figure:
Figure with the changes based on answer(linear on the y axis):
Subset of the data: