do_BoxPlot() | Box-and-whisker plots

Box plots provide a statistical summary of distributions: median, quartiles, and outliers. Use them to compare gene expression or other continuous values across groups with optional statistical testing.


Basic usage

p <- SCpubr::do_BoxPlot(sample = sample,
                        feature = "nCount_RNA",
                        flip = TRUE,
                        order = TRUE)
p


Split by condition

p <- SCpubr::do_BoxPlot(sample = sample,
                        feature = "nCount_RNA",
                        group.by = "subtype",
                        split.by = "technology",
                        flip = TRUE)
p


Statistical testing

Add significance annotations between groups:

p <- SCpubr::do_BoxPlot(sample = sample,,
                        feature = "nFeature_RNA",
                        group.by = "subtype",
                        flip = TRUE,
                        order = TRUE,
                        use_test = TRUE,
                        comparisons = list(c("ATRT-TYR", "ATRT-SHH")),
                        test = "wilcox.test")
p

Note

use_test cannot be combined with split.by.

Customize significance display

p <- SCpubr::do_BoxPlot(sample = sample,
                        feature = "nFeature_RNA",
                        group.by = "subtype",
                        flip = TRUE,
                        order = TRUE,
                        use_test = TRUE,
                        comparisons = list(c("ATRT-TYR", "ATRT-SHH")),
                        test = "wilcox.test",
                        map_signif_level = c("***" = 0.0001, 
                                             "**" = 0.001, 
                                             "*" = 0.05))
p


Silhouette style

Color borders instead of fill:

p <- SCpubr::do_BoxPlot(sample = sample,
                        feature = "nFeature_RNA",
                        group.by = "subtype",
                        flip = TRUE,
                        use_silhouette = TRUE)
p


Parameter reference

Note

For parameters shared across many functions (color palettes, typography, legend styling, grid), see Shared features.

Core parameters

Parameter Description Default
feature Feature to plot

Statistical testing

Parameter Description Default
use_test Add significance testing FALSE
comparisons List of group pairs to compare NULL
test Test method "wilcox.test"
map_signif_level P-value to symbol mapping See defaults

Appearance

Parameter Description Default
use_silhouette Color borders instead of fill FALSE
boxplot.line.color Border color "black"
boxplot.linewidth Border width 0.5
boxplot.width Box width NULL
outlier.color Outlier dot color "black"
outlier.alpha Outlier transparency 0.5
order Order groups by median FALSE

See also