varf <- read.table(text = "sID variable value
SP_SA036,SA040 CM0001 0.492537313
SP_SA036,SA040 CM0001 0.479564033
SP_SA036,SA040 CM0001 0.559139785
SP_SA036,SA040 CM0002 0.526806527
SP_SA036,SA040 CM0002 0.009049774
SP_SA036,SA040 CM0002 0.451612903", header = T)
anot <- read.table(text = "category annotation
CM0001 HG4450
CM0002 HG3288", header = T)
varf <- merge(varf, anot, by.x = "variable", by.y = "category", all.x = T)
library(data.table)
quants <- data.table(varf)[, list(quant = as.numeric(quantile(value)[3])), by = variable]
ggplot(varf, aes(x = variable, y = value, fill = variable)) +
geom_boxplot() +
geom_text(data = quants, aes(x = variable, y = quant, label = variable), size = 10)