Documentation Index
Fetch the complete documentation index at: https://mintlify.com/satijalab/seurat-wrappers/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Reduced-dimension plots (UMAP, PCA, tSNE) are essential for single-cell analysis, but as dataset sizes grow, cells overlap and obscure information — even with transparency settings. schex addresses this by binning cells into hexagons and plotting a summary statistic for each bin instead of individual points. Benefits:- Eliminates overplotting in large datasets
- Preserves the visual structure of the embedding
- Supports plotting metadata, cluster labels, and gene expression per bin
- Works seamlessly with Seurat objects
Citation: Saskia Freytag (2019). schex: Hexagonal binning for single cell data. R package.Original biology reference: Delile, Julien et al. Single cell transcriptomics reveals spatial and temporal dynamics of gene expression in the developing mouse spinal cord. doi: 10.1242/dev.173807Source: SaskiaFreytag/schex
Installation
Key functions
| Function | Description |
|---|---|
make_hexbin() | Computes hexagon bin assignments for each cell |
plot_hexbin_density() | Plots cell count per hexagon bin |
plot_hexbin_meta() | Colors hexagons by a metadata variable |
plot_hexbin_gene() | Colors hexagons by gene expression |
make_hexbin_label() | Computes label positions for factor variables |
Complete workflow
Compute hexagon bin representation
make_hexbin() assigns each cell to a hexagon bin in the specified embedding. The nbins parameter controls the number of bins along the x-axis:Choose
nbins based on dataset size. More cells generally require a higher nbins value to avoid bins that are too coarse. Start with 20–40 for datasets under 10k cells; increase for larger datasets. The density plot in the next step helps you assess whether bins are evenly populated.Plot bin density
Check how many cells fall into each hexagon. Bins should be relatively evenly populated; if one bin has far more cells than others, increase
nbins:Plot metadata in hexagon representation
Color hexagons by a metadata column. Use Add cluster labels with
action to specify how to summarize the column within each bin:ggrepel for readability:action parameter reference
The action parameter in plot_hexbin_meta() and plot_hexbin_gene() controls how values are summarized within each bin:
| Action | Use case |
|---|---|
"median" | Numeric metadata (e.g., nCount_RNA, percent.mt) |
"mean" | Gene expression values |
"majority" | Factor/categorical metadata (e.g., cluster labels) |
Choosing nbins
The nbins parameter in make_hexbin() specifies how many bins divide the x-axis range. Adjust it based on dataset size:
| Dataset size | Suggested nbins |
|---|---|
| < 5,000 cells | 20–30 |
| 5,000–20,000 cells | 30–50 |
| > 20,000 cells | 50+ |
plot_hexbin_density() after changing nbins to confirm bins are not over- or under-populated.