Reputation: 21
I created this boxplot but need different stats method p values
using this code, namely the fucntion stat_compare_means BUt I would like to use mannwhitney/non-parametric p values instead as data is not normally distributed.
Also how can I see what options of stats methods there are to use? (help says use "method" within Stat_compare_means - I would like to be able to see a list of different methods that I can use for different tests in future
my_comparisons <- list (c("AA/AG","GG"))
df <- GDFSNP1_for_R
df %>%
drop_na(Genotype) %>%
pivot_longer(starts_with("GDF")) %>%
mutate(name = factor(name, c("GDFb", "GDFt6", "GDFt12"))) %>%
ggplot(. , aes(y = value, x = Genotype, group = Genotype, fill=Genotype)) +
facet_grid(~name, labeller = as_labeller(GDF_label)) +
geom_violin(width=0.9) +
geom_boxplot(width=0.1, alpha=0.2) +
stat_compare_means(comparisons = my_comparisons)
Upvotes: 0
Views: 3299
Reputation: 466
Not sure where it's documented, but if you source ggpubr:::.method_info
, you can get a look at the available methods.
{
if (is.null(method))
method = "wilcox.test"
allowed.methods <- list(t = "t.test", t.test = "t.test",
student = "t.test", wiloxon = "wilcox.test", wilcox = "wilcox.test",
wilcox.test = "wilcox.test", anova = "anova", aov = "anova",
kruskal = "kruskal.test", kruskal.test = "kruskal.test")
method.names <- list(t.test = "T-test", wilcox.test = "Wilcoxon",
anova = "Anova", kruskal.test = "Kruskal-Wallis")
if (!(method %in% names(allowed.methods)))
stop("Non-supported method specified. Allowed methods are one of: ",
.collapse(allowed.methods, sep = ", "))
method <- allowed.methods[[method]]
method.name <- method.names[[method]]
list(method = method, name = method.name)
}
It looks like the options for nonparametric methods are "wilcox.test"
and "kruskal.test"
. I believe that Wilcox is the same thing as Mann-Whitney.
Upvotes: 0