add_test_pvalue | R Documentation |
Add statistical test
add_test_pvalue(
plot,
padding_top = 0.15,
method = "t_test",
p.adjust.method = "none",
ref.group = NULL,
label = "{format_p_value(p.adj, 0.0001)}",
label.size = 7/ggplot2::.pt,
step.increase = 0.15,
vjust = -0.25,
bracket.nudge.y = 0.1,
hide.ns = FALSE,
p.adjust.by = "panel",
symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, Inf), symbols = c("***", "**",
"*", "ns")),
hide_info = FALSE,
...
)
add_test_asterisks(
plot,
padding_top = 0.1,
method = "t_test",
p.adjust.method = "none",
ref.group = NULL,
label = "p.adj.signif",
label.size = 10/ggplot2::.pt,
step.increase = 0.2,
vjust = 0.3,
bracket.nudge.y = 0.15,
hide.ns = TRUE,
p.adjust.by = "panel",
symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, Inf), symbols = c("***", "**",
"*", "ns")),
hide_info = FALSE,
...
)
plot |
A |
padding_top |
Extra padding above the data points to accommodate the statistical comparisons. |
method |
a character string indicating which method to be used for
pairwise comparisons. Default is |
p.adjust.method |
method for adjusting p values (see
|
ref.group |
a character string or a numeric value specifying the reference group. If specified, for a given grouping variable, each of the group levels will be compared to the reference group (i.e. control group).
Allowed values can be:
|
label |
character string specifying label. Can be:
. |
label.size |
change the size of the label text |
step.increase |
numeric vector with the increase in fraction of total height for every additional comparison to minimize overlap. |
vjust |
move the text up or down relative to the bracket. |
bracket.nudge.y |
Vertical adjustment to nudge brackets by (in fraction of the total height). Useful to move up or move down the bracket. If positive value, brackets will be moved up; if negative value, brackets are moved down. |
hide.ns |
can be logical value ( |
p.adjust.by |
possible value is one of |
symnum.args |
a list of arguments to pass to the function
In other words, we use the following convention for symbols indicating statistical significance:
|
hide_info |
Whether to hide details about the statistical testing as caption. Defaults to |
... |
Arguments passed on to |
add_test_pvalue()
and add_test_asterisks()
use ggpubr::geom_pwc()
.
Check there for additional arguments.
A tidyplot
object.
study |>
tidyplot(x = dose, y = score, color = group) |>
add_mean_dash() |>
add_sem_errorbar() |>
add_data_points() |>
add_test_pvalue()
# Change stat methods
study |>
tidyplot(x = dose, y = score, color = group) |>
add_mean_dash() |>
add_sem_errorbar() |>
add_data_points() |>
add_test_pvalue(method = "wilcoxon", p.adjust.method = "BH")
# Define reference group to test against
study |>
tidyplot(x = treatment, y = score, color = treatment) |>
add_mean_dash() |>
add_sem_errorbar() |>
add_data_points() |>
add_test_pvalue(ref.group = "A")
# hide non-significant p values
gene_expression |>
# filter to one gene
dplyr::filter(external_gene_name == "Apol6") |>
# start plotting
tidyplot(x = condition, y = expression, color = sample_type) |>
add_mean_dash() |>
add_sem_errorbar() |>
add_data_points() |>
add_test_pvalue(hide.ns = TRUE)
# Adjust top padding for statistical comparisons
study |>
tidyplot(x = treatment, y = score, color = treatment) |>
add_mean_dash() |>
add_sem_errorbar() |>
add_data_points() |>
add_test_pvalue(padding_top = 0.08)
# Hide stats information
study |>
tidyplot(x = dose, y = score, color = group) |>
add_mean_dash() |>
add_sem_errorbar() |>
add_data_points() |>
add_test_pvalue(hide_info = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.