Compute p-value x and y positions for plotting significance levels.

get_y_position(data, formula, fun = "max", ref.group = NULL,
comparisons = NULL, step.increase = 0.12, y.trans = NULL)

add_y_position(test, fun = "max", step.increase = 0.12, data = NULL,
formula = NULL, ref.group = NULL, comparisons = NULL,
y.trans = NULL)

add_x_position(test, x = NULL, dodge = 0.8)

add_xy_position(test, x = NULL, dodge = 0.8, fun = "max",
step.increase = 0.12, ...)

Arguments

data a data.frame containing the variables in the formula. a formula of the form x ~ group where x is a numeric variable giving the data values and group is a factor with one or multiple levels giving the corresponding groups. For example, formula = TP53 ~ cancer_group. summary statistics function. Possible values include: "max", "mean", "mean_sd", "mean_se", "mean_ci", "median", "median_iqr", "median_mad". "max" is suitable when you want to add, for example, p-value on box plots. The remaining functions are suitable for bar plots and line plots showing mean plots +/- error bars. a character string 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). A list of length-2 vectors specifying the groups of interest to be compared. For example to compare groups "A" vs "B" and "B" vs "C", the argument is as follow: comparisons = list(c("A", "B"), c("B", "C")) numeric vector with the increase in fraction of total height for every additional comparison to minimize overlap. a function for transforming y axis scale. Value can be log2, log10 and sqrt. Can be also any custom function that can take a numeric vector as input and retourne a numeric vector, example: y.trans = function(x){log2(x+1)} an object of class rstatix_test as returned by t_test(), wilcox_test(), sign_test(), tukey_hsd(), dunn_test(). variable on x axis. dodge width for grouped ggplot/test. Default is 0.8. Used only when x specified. other arguments to be passed to the function t.test.

Functions

• get_y_position: compute the p-value y positions

• add_y_position: add p-value y positions to an object of class rstatix_test

• add_x_position: compute and add p-value x positions.

• add_xy_position: compute and add both x and y positions.

Examples

# Data preparation
#::::::::::::::::::::::::::::::::::::
df <- ToothGrowth
df$dose <- as.factor(df$dose)
df\$group <- factor(rep(c(1, 2), 30))
#> 1  4.2   VC  0.5     1
#> 2 11.5   VC  0.5     2
#> 3  7.3   VC  0.5     1
#> 4  5.8   VC  0.5     2
#> 5  6.4   VC  0.5     1
#> 6 10.0   VC  0.5     2
# Stat tests
#::::::::::::::::::::::::::::::::::::
stat.test <- df %>%
t_test(len ~ dose)
stat.test#> # A tibble: 3 x 10
}