Skip to contents

Generate differential-abundance plots based on results from RunProportionTest. Supports both legacy storage and method-layer storage from the multi-method proportion-test workflow.

Usage

ProportionTestPlot(
  srt,
  comparison = NULL,
  proportion_method = NULL,
  result_level = c("group"),
  plot_type = c("effect", "umap"),
  umap_mode = c("discrete", "continuous"),
  reduction = "UMAP",
  projection_args = list(),
  FDR_threshold = 0.05,
  log2FD_threshold = log2(1.5),
  order_by = c("value", "name"),
  palette = "RdBu",
  palcolor = NULL,
  group_palette = "Chinese",
  group_palcolor = NULL,
  pt.size = 1,
  pt.alpha = 1,
  cols.sig = "red",
  cols.ns = "grey",
  cols.increase = "#d7301f",
  cols.decrease = "#2b8cbe",
  effect_color_mode = c("directional", "classic"),
  nlabel = 5,
  features_label = NULL,
  label = FALSE,
  label.fg = "black",
  label.bg = "white",
  label.bg.r = 0.1,
  label.size = 4,
  aspect.ratio = NULL,
  xlab = "Cell Type",
  ylab = "log2 (FD)",
  theme_use = "theme_scop",
  theme_args = list(),
  legend.position = "bottom",
  legend.direction = "vertical",
  legend.title = "Significance",
  combine = TRUE,
  nrow = NULL,
  ncol = NULL,
  byrow = TRUE,
  seed = 11
)

Arguments

srt

A Seurat object containing proportion-test results.

comparison

A character string specifying which comparison to plot. If NULL, plots all comparisons.

proportion_method

Optional method to select from srt@tools[['ProportionTest']][['methods']]. If NULL, uses the active/most recent method.

result_level

Result level to draw. Currently only "group" is used.

plot_type

Plot type. One of "effect" or "umap".

umap_mode

UMAP projection mode for plot_type = "umap". "discrete" maps cells to DA direction categories; "continuous" maps cells to group-level obs_log2FD.

reduction

Reduction name used by UMAP projection.

projection_args

Additional arguments passed to CellDimPlot (umap_mode = "discrete") or FeatureDimPlot (umap_mode = "continuous").

FDR_threshold

FDR value cutoff for significance.

log2FD_threshold

Absolute value of log2FD cutoff for significance.

order_by

Method to order clusters. Options: "name" (alphabetical), "value" (by log2FD value).

palette

Color palette name for continuous effect coloring.

palcolor

Custom colors for palette.

group_palette

Palette for cluster/group coloring.

group_palcolor

Custom colors for group_palette.

pt.size

The size of the points.

pt.alpha

Point transparency.

cols.sig

Color for significant/credible points and intervals.

cols.ns

Color for non-significant points and intervals.

cols.increase

Default color for increased DA groups.

cols.decrease

Default color for decreased DA groups.

effect_color_mode

Coloring mode for plot_type = "effect". Use "directional" (default) for increased/decreased/NS colors, or "classic" for legacy significant/non-significant coloring.

nlabel

Number of labels added when label = TRUE and features_label = NULL.

features_label

Character vector specifying points to label.

label

Whether to add labels.

label.fg

Label foreground color.

label.bg

Label background color.

label.bg.r

Label background radius.

label.size

Label text size.

aspect.ratio

Aspect ratio of the panel.

xlab

A character string specifying the x-axis label. For plot_type = "umap", this is forwarded to the projection plot when set.

ylab

A character string specifying the y-axis label. For plot_type = "umap", this is forwarded to the projection plot when set.

theme_use

Theme used. Can be a character string or a theme function. Default is "theme_scop".

theme_args

Other arguments passed to the theme_use. Default is list().

legend.position

The position of legends, one of "none", "left", "right", "bottom", "top".

legend.direction

The direction of the legend in the plot. Can be one of "vertical" or "horizontal".

legend.title

Title of the legend.

combine

Combine plots into a single patchwork object. If FALSE, return a list of ggplot objects.

nrow

Number of rows in the combined plot. Default is NULL, which means determined automatically based on the number of plots.

ncol

Number of columns in the combined plot. Default is NULL, which means determined automatically based on the number of plots.

byrow

Whether to arrange the plots by row in the combined plot. Default is TRUE.

seed

Random seed for reproducibility. Default is 11.

Examples

data(pancreas_sub)
pancreas_sub <- standard_scop(pancreas_sub)
#>  [2026-05-14 06:46:23] Start standard processing workflow...
#>  [2026-05-14 06:46:24] Checking a list of <Seurat>...
#> ! [2026-05-14 06:46:24] Data 1/1 of the `srt_list` is "unknown"
#>  [2026-05-14 06:46:24] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on 1/1 of `srt_list`...
#>  [2026-05-14 06:46:25] Perform `Seurat::FindVariableFeatures()` on 1/1 of `srt_list`...
#>  [2026-05-14 06:46:26] Use the separate HVF from `srt_list`
#>  [2026-05-14 06:46:26] Number of available HVF: 2000
#>  [2026-05-14 06:46:26] Finished check
#>  [2026-05-14 06:46:26] Perform `Seurat::ScaleData()`
#>  [2026-05-14 06:46:26] Perform pca linear dimension reduction
#>  [2026-05-14 06:46:27] Use stored estimated dimensions 1:20 for Standardpca
#>  [2026-05-14 06:46:27] Perform `Seurat::FindClusters()` with `cluster_algorithm = 'louvain'` and `cluster_resolution = 0.6`
#>  [2026-05-14 06:46:27] Reorder clusters...
#>  [2026-05-14 06:46:28] Skip `log1p()` because `layer = data` is not "counts"
#>  [2026-05-14 06:46:28] Perform umap nonlinear dimension reduction
#>  [2026-05-14 06:46:28] Perform umap nonlinear dimension reduction using Standardpca (1:20)
#>  [2026-05-14 06:46:33] Perform umap nonlinear dimension reduction using Standardpca (1:20)
#>  [2026-05-14 06:46:38] Standard processing workflow completed
pancreas_sub <- RunProportionTest(
  pancreas_sub,
  group.by = "CellType",
  split.by = "Phase",
  proportion_method = "permutation"
)
#>  [2026-05-14 06:46:38] Start proportion test ("permutation")
#>  [2026-05-14 06:46:38] Running comparison: "S" vs "G1"
#>  [2026-05-14 06:46:40] Running comparison: "G2M" vs "G1"
#>  [2026-05-14 06:46:42] Running comparison: "G2M" vs "S"
#>  [2026-05-14 06:46:42] Running comparison: "G1" vs "S"
#>  [2026-05-14 06:46:42] Running comparison: "G1" vs "G2M"
#>  [2026-05-14 06:46:43] Running comparison: "S" vs "G2M"
#>  [2026-05-14 06:46:43] Proportion test completed ("permutation")

ProportionTestPlot(pancreas_sub)


ProportionTestPlot(
 pancreas_sub,
 reduction = "UMAP",
 plot_type = "umap",
 xlab = "UMAP_1",
 ylab = "UMAP_2"
)