Creates box plots to visualize signature distributions across groups with optional statistical pairwise comparisons. Supports both data frames and Seurat objects for single-cell data visualization.
Usage
sig_box(
data,
signature,
variable,
palette = "nrc",
cols = NULL,
jitter = FALSE,
point_size = 5,
angle_x_text = 0,
hjust = 0.5,
show_pairwise_p = TRUE,
show_overall_p = FALSE,
return_stat_res = FALSE,
size_of_pvalue = 6,
size_of_font = 10,
assay = NULL,
slot = "scale.data",
scale = FALSE
)Arguments
- data
Data frame or Seurat object containing the signature and grouping variable.
- signature
Character string specifying the column name (or feature name in Seurat) for the signature values to plot on the y-axis.
- variable
Character string specifying the grouping variable column name for the x-axis.
- palette
Character string specifying the color palette name. Default is `"nrc"`.
- cols
Character vector of custom fill colors. If `NULL`, palette is used. Default is `NULL`.
- jitter
Logical indicating whether to add jittered points to the box plot. Default is `FALSE`.
- point_size
Numeric value specifying the size of jittered points. Default is 5.
- angle_x_text
Numeric value specifying the rotation angle for x-axis labels (in degrees). Default is 0.
- hjust
Numeric value specifying the horizontal justification of x-axis labels. Default is 0.5.
- show_pairwise_p
Logical indicating whether to display pairwise comparison p-values between groups. Default is `TRUE`.
- show_overall_p
Logical indicating whether to display the overall group difference p-value. Default is `FALSE`.
- return_stat_res
Logical indicating whether to return statistical test results instead of the plot. Default is `FALSE`.
- size_of_pvalue
Numeric value specifying the font size for p-values. Default is 6.
- size_of_font
Numeric value specifying the base font size. Default is 10.
- assay
Character string specifying the assay name (for Seurat objects). Default is `NULL`.
- slot
Character string specifying the slot name (for Seurat objects). Default is `"scale.data"`.
- scale
Logical indicating whether to scale signature values (z-score transformation). Default is `FALSE`.
Value
If `return_stat_res = FALSE`, returns a ggplot2 object. If `return_stat_res = TRUE`, returns a data frame containing statistical test results.
Examples
tcga_stad_pdata <- load_data("tcga_stad_pdata")
sig_box(
data = tcga_stad_pdata,
signature = "TMEscore_plus",
variable = "subtype",
jitter = TRUE,
palette = "jco"
)
#> Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
#> ℹ Please use the `linewidth` argument instead.
#> ℹ The deprecated feature was likely used in the IOBR package.
#> Please report the issue at <https://github.com/IOBR/IOBR/issues>.