Skip to contents

Visualizes the composition of stat.by within each level of group.by as a polar bar (rose) chart. Each petal of the rose corresponds to a group.by level; the petal is split by color into stat.by proportions or counts.

When facet.by is supplied, native facet_wrap is used so each panel shows its own rose. Plot margins are auto-expanded based on the longest group.by label.

Usage

PlotRose(
  data,
  stat.by,
  group.by,
  donor.by = NULL,
  facet.by = NULL,
  ncol_facet = NULL,
  stat_type = "percent",
  colors = NULL,
  alpha = 0.85,
  label = TRUE,
  label_size = 2.5,
  min_label_pct = 2,
  keep_empty = FALSE,
  output_dir = NULL,
  object_name = "",
  pdf_width = 7,
  pdf_height = 7
)

Arguments

data

A Seurat object or a plain data.frame/tibble.

stat.by

Character. Variable whose levels become the fill color (e.g. "Sample" or "CERAD").

group.by

Character. Variable that defines the x-axis petals before polar transformation (e.g. "Assignment" or "BraakStage").

donor.by

Character or NULL. Column identifying the donor / patient. When supplied, metadata is first deduplicated to one row per donor so petal sizes reflect donor counts - appropriate for patient-level neuropathological or clinical variables. Default NULL.

facet.by

Character or NULL. Metadata column to facet by - one rose panel per level. Default NULL.

ncol_facet

Integer or NULL. Number of facet columns when facet.by is used. Auto-computed (max 3) if NULL.

stat_type

Character. "percent" (default) plots the fraction of stat.by within each group.by level; "count" plots raw counts.

colors

Named character vector for stat.by levels. Auto-assigned if NULL.

alpha

Numeric. Fill transparency. Default 0.85.

label

Logical. Show proportion/count labels on each segment. Default TRUE.

label_size

Numeric. Label text size. Default 2.5.

min_label_pct

Numeric. Minimum percentage below which labels are suppressed (avoids clutter in tiny slices). Default 2.

keep_empty

Logical. Include group.by × stat.by combinations with zero observations. Default FALSE.

output_dir

Directory to save a PDF. NULL = no save.

object_name

Label prefix for the output filename.

pdf_width, pdf_height

PDF dimensions per panel in inches. Scales with number of facet panels. Default 7 x 7.

Value

A ggplot2 object (invisibly).