| Title: | Region-Preserving Batch Correction for Paired Region-Resolved Single-Cell Data |
|---|---|
| Description: | Implements Region-Preserving Batch Correction (RPBC), an empirical-Bayes location-scale framework for paired region-resolved single-cell and spatial-omics data. RPBC preserves a patient-balanced population-average regional contrast while harmonizing patient-wide location shifts, patient-specific regional deviations, and patient-region scale heterogeneity. The package also provides Adaptive RPBC for group-size-dependent stabilization of patient-region scale variation and covariate-adjusted RPBC for preserving prespecified patient-level covariate-associated variation during harmonization. RPBC is designed to interoperate with Bioconductor data structures for single-cell and spatial experiments. |
| Authors: | Elizabeth B. Amona [aut, cre] (ORCID: <https://orcid.org/0000-0002-7575-788X>) |
| Maintainer: | Elizabeth B. Amona <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.0 |
| Built: | 2026-10-12 23:14:22 UTC |
| Source: | https://github.com/BiocStaging/RPBC |
A representative example dataset for demonstrating Region-Preserving Batch Correction (RPBC) using glioblastoma imaging mass cytometry (IMC) data. The dataset retains all seven patients and the paired Core/Edge design, with 30 cells sampled from each patient-region combination.
data(haley_gbm_example)data(haley_gbm_example)
A SpatialExperiment object with 10 markers (rows) and
420 cells (columns). The "counts" assay contains raw IMC intensities.
Cell-level metadata include:
Unique cell identifier.
Region-of-interest identifier.
Patient identifier.
Paired tumor region, coded as "Core" or "Edge".
Patient age.
Patient sex.
MGMT status.
The dataset contains 10 representative biological markers measured across
420 cells. Raw IMC intensities are stored in the "counts" assay, allowing
preprocessing transformations to be applied directly through rpbc().
This example dataset was constructed by sampling 30 cells from each patient-region combination while retaining all seven patients and both Core and Edge regions. It is intended for package examples, testing, and vignettes and does not represent the complete Haley GBM IMC dataset.
The 10 included markers are CD45, CD3, Cd8a, CD68, CD163, GFAP, Sox2, Olig2, Ki67, and Vimentin.
Haley MJ, et al. (2024). Hypoxia coordinates the spatial landscape of myeloid cells within glioblastoma to affect survival. Science Advances, 10(20), eadj3301. https://doi.org/10.1126/sciadv.adj3301
Haley M, Couper K. (2024). Imaging mass cytometry data from IDH wildtype glioblastomas. Dryad. https://doi.org/10.5061/dryad.2z34tmprw
Apply Region-Preserving Batch Correction (RPBC) to paired region-resolved single-cell or spatial data.
rpbc( object, patient, region, assay_name = "counts", transform = c("none", "asinh", "log1p"), cofactor = 5, covariates = NULL, adaptive = FALSE, output_assay = "rpbc", core_level = "Core", edge_level = "Edge", conv = 1e-04, max_iter = 100L, eps = 1e-08, delta_adaptive_k = 1, delta_bounds = c(0.5, 2), return_fit = FALSE )rpbc( object, patient, region, assay_name = "counts", transform = c("none", "asinh", "log1p"), cofactor = 5, covariates = NULL, adaptive = FALSE, output_assay = "rpbc", core_level = "Core", edge_level = "Edge", conv = 1e-04, max_iter = 100L, eps = 1e-08, delta_adaptive_k = 1, delta_bounds = c(0.5, 2), return_fit = FALSE )
object |
A |
patient |
Character string naming the column in |
region |
Character string naming the column in |
assay_name |
Character string naming the assay to use as input.
Default is |
transform |
Character string specifying the transformation applied
to the selected assay before RPBC harmonization. One of |
cofactor |
Positive numeric value used when
|
covariates |
Optional character vector naming patient-level
covariates in |
adaptive |
Logical. If |
output_assay |
Character string giving the name of the assay in which
the harmonized expression matrix will be stored. Default is |
core_level |
Character string identifying the Core region. |
edge_level |
Character string identifying the Edge region. |
conv |
Positive convergence tolerance for empirical-Bayes estimation. |
max_iter |
Positive integer giving the maximum number of empirical-Bayes iterations. |
eps |
Small positive numerical constant used for numerical stability. |
delta_adaptive_k |
Positive Adaptive RPBC stabilization constant.
The validated default is |
delta_bounds |
Numeric vector of length two giving the lower and
upper bounds for Adaptive RPBC patient-region variance multipliers.
The validated default is |
return_fit |
Logical. If |
RPBC harmonizes patient and patient-by-region nuisance variation while preserving the prespecified population-average regional effect.
The function supports:
ordinary RPBC;
covariate-adjusted RPBC; and
Adaptive RPBC.
Ordinary and covariate-adjusted RPBC use the same internal statistical engine. Adaptive RPBC uses a separate internal engine because its patient-region scale update includes group-size-dependent stabilization.
By default, the input object with the harmonized expression matrix
stored in output_assay. If return_fit = TRUE, a list containing
object and fit.
data("haley_gbm_example", package = "RPBC") # Ordinary RPBC example_ordinary <- rpbc( object = haley_gbm_example, patient = "patient_id", region = "region_type", assay_name = "counts", transform = "asinh", cofactor = 5, adaptive = FALSE, output_assay = "rpbc" ) # Adaptive RPBC example_adaptive <- rpbc( object = haley_gbm_example, patient = "patient_id", region = "region_type", assay_name = "counts", transform = "asinh", cofactor = 5, adaptive = TRUE, output_assay = "rpbc_adaptive" ) # Covariate-adjusted RPBC example_covariate <- rpbc( object = haley_gbm_example, patient = "patient_id", region = "region_type", assay_name = "counts", transform = "asinh", cofactor = 5, covariates = c("age", "sex"), adaptive = FALSE, output_assay = "rpbc_covariate" )data("haley_gbm_example", package = "RPBC") # Ordinary RPBC example_ordinary <- rpbc( object = haley_gbm_example, patient = "patient_id", region = "region_type", assay_name = "counts", transform = "asinh", cofactor = 5, adaptive = FALSE, output_assay = "rpbc" ) # Adaptive RPBC example_adaptive <- rpbc( object = haley_gbm_example, patient = "patient_id", region = "region_type", assay_name = "counts", transform = "asinh", cofactor = 5, adaptive = TRUE, output_assay = "rpbc_adaptive" ) # Covariate-adjusted RPBC example_covariate <- rpbc( object = haley_gbm_example, patient = "patient_id", region = "region_type", assay_name = "counts", transform = "asinh", cofactor = 5, covariates = c("age", "sex"), adaptive = FALSE, output_assay = "rpbc_covariate" )