
UMAP with Pie Charts at Cluster Centroids
PlotPieUMAP.RdOverlays proportional pie charts on a UMAP (or any 2D reduction) - one pie
per level of group.by - where each slice shows the fraction of cells
from each level of split.by (e.g. sample composition per cluster).
Uses ggforce::geom_arc_bar for stable pie rendering that works
correctly with ggplot2 >= 3.4 (unlike the old coord_polar approach).
Usage
PlotPieUMAP(
seurat_object,
group.by,
split.by,
reduction = "umap",
pie_scale = 1,
bg_color = "lightgray",
bg_alpha = 0.3,
pt.size = 0.4,
split_colors = NULL,
label = TRUE,
label_size = 3,
output_dir = NULL,
object_name = "",
subset_name = "",
file_name = NULL,
width = NULL,
height = NULL,
timestamp = FALSE
)Arguments
- seurat_object
A Seurat object.
- group.by
Metadata column defining the groups/clusters. One pie chart is placed at each group's centroid in the reduction space.
- split.by
Metadata column whose level proportions define the pie slices (e.g.
"Sample"shows how much of each cluster is each sample).- reduction
Dimensionality reduction to use. Default
"umap".- pie_scale
Scaling multiplier for pie radius (1 = auto-sized). Increase for larger pies, decrease if pies overlap. Default
1.- bg_color
Background scatter point color. Default
"lightgray".- bg_alpha
Background scatter point transparency. Default
0.3.- pt.size
Background scatter point size. Default
0.4.- split_colors
Named character vector of colors for
split.bylevels. Auto-assigned from PrepObject orNour_palifNULL.- label
Logical. Add cluster labels at centroids. Default
TRUE.- label_size
Font size for cluster labels. Default
3.- output_dir
Directory to save a PDF.
NULL= no save.- object_name
Label prefix for output file names.
- subset_name
Optional subset label.
- file_name
Character or
NULL. Base name (no extension) for the saved PDF.NULL(default) auto-deduces fromobject_name,subset_name,group.by, andsplit.by.- width, height
Numeric or
NULL. Override the auto-calculated PDF dimensions in inches.NULL(default) uses a fixed 7 x 6 in panel.- timestamp
Logical. When
TRUE, append a_YYYYMMDD-HHMMSSstamp to the saved file name so repeated runs are versioned instead of overwriting the previous PDF. DefaultFALSE.