Hi @rensa,
I'm trying to define a stat that given a sample of p-values, it generates a qqplot for diagnostics (see code bellow). I was able to change the axis label to expected and observed using the code, but I was looking to define it as "Expected log[10] P" and "Observed log[10] P" to reduce my later presentation work.
-
P.S. I've also made a custom geom (which I was referencing) that plots not only the dots, but also a regression line and confidence interval lines.
-
P.S.S Its a fringe use case, but I need it quite frequently
StatQQPval <- ggproto("StatQQPval", Stat,
required_aes = c("sample"),
default_aes = aes(x = ..expected.., y = ..observed..),
compute_group = function(data, scales) {
n <- nrow(data)
transform(data,
observed = -log10(sort(sample)),
expected = -log10(1:n/n))
})
@mara idea was great but not quite what I was looking for, because I need to group my sample (e.g. by color).
-
P.S.S.S. Also, I can move any further discussion to stack overflow if it would make community more comfortable.