sccomp Models Repeated Single-Cell Composition Data in Cancer Biopsies

Oct 29, 2026 885 views

This analysis matters because single-cell composition data become harder to interpret when samples are repeated within patients. A tissue microarray may contain several tumour cores from one person; a treatment study may collect biopsies at several timepoints. Averaging those samples to one patient-level proportion and testing each cell type separately can hide both the dependence between observations and the fact that cell proportions must sum to one.

That’s the problem sccomp is designed to address. It models mixed-effect compositional data, estimates outliers probabilistically, tests whether cell-type variability differs across conditions, and accounts for unwanted effects. Its input is a long tibble with one row per sample and cell type, a count, and design variables. The functions sccomp_estimate(), sccomp_test(), and sccomp_predict() return tibbles that work with dplyr, tidyr, and ggplot2.

The original article appeared on tidyomicsBlog and was contributed to R-bloggers. The page links to R-bloggers’ contact form for content issues, and invites readers to submit a blog or use r-posts.com if they don’t have one. The contributor is Pierre-Paul Axisa, a researcher at CBMR in Copenhagen, Denmark.

The NeoTRIP data and its nested samples

The example applies sccomp to NeoTRIP, a phase III trial of early high-risk triple-negative breast cancer (TNBC). In the study by Wang et al. (2023), patients were randomized 1:1 to eight three-week neoadjuvant cycles of carboplatin plus nab-paclitaxel (C), either alone or with atezolizumab (C&I), before surgery. The trial identifier is NCT02620280.

Wang and colleagues used imaging mass cytometry (IMC) to study how the spatial organization of cells in TNBC relates to response to neoadjuvant immunotherapy. Research FFPE biopsies were collected at baseline (243 patients), on the first day of cycle 2 (207), and at surgery after treatment (210). A 43-marker panel profiled tissue at subcellular resolution. Deep-learning segmentation and semi-supervised clustering identified 17 epithelial phenotypes and 20 tumour-microenvironment (TME) phenotypes. Researchers imaged multiple regions of interest (ROIs) in each biopsy.

The structure of those samples is the point: ROIs sit inside biopsies, and biopsies sit inside patients. Consider patient NT193, who received chemotherapy and had residual disease. The study imaged 10 ROIs at baseline, 10 during treatment, and three at surgery. In the sccomp model, each ROI is a compositional sample, while patient identity defines the repeated-measures group.

Tree for patient NT193. The patient sits at the top and three biopsy timepoints branch underneath. Each timepoint ends in the imaged regions of interest, drawn as spatial tiles: magenta M2 macrophages, yellow PD-L1-positive antigen-presenting cells, and green other immune cells. There are 10 tiles at baseline, 10 on-treatment, and 3 post-treatment.
Figure 1. Patient NT193 and the ROIs sampled at each timepoint.

Across the per-protocol cohort, the analysis includes 257 patients and 1,740 ROI-level immune samples. It covers 15 immune-cell phenotypes, with a median of seven ROIs per patient. Wang et al. connected cell densities, spatial interactions, and proliferative fractions with pathological complete response (pCR). They also reported that immunotherapy changes tissue composition over time, with immune-infiltration patterns that vary by response, including the compositional trajectories in Figure 5.

Why model the ROI counts directly?

Wang et al. summarized longitudinal composition as mean phenotype proportions per patient, then compared treatment arms, timepoints, and response groups using Wilcoxon tests, Z-scored trend plots, and weighted binomial generalized linear models for each phenotype. Those analyses make the data easier to summarize, but they treat phenotypes one at a time and average ROIs to the patient before inference. That leaves the sum-to-one constraint and the nested sampling structure out of the model.

sccomp instead models ROI-level counts on a latent log-ratio scale, with mixed effects for both the mean and variability. Each ROI is identified as a sample with sample = "ROI_id" in sccomp_estimate(). The model also records biopsy phase and includes a patient random intercept, (1 | PatientID), to account for patient-level differences and share information across the cohort.

Analysis input

The article’s reproducible tidyverse analysis uses the immune TME compartment, ROI-level samples, and a patient random intercept. Its long-format tibble has one row per ROI and immune phenotype, with ROI_id, a count, the design variables Arm, BiopsyPhase, and pCR, and the patient grouping variable PatientID. Multiple ROIs can belong to the same biopsy phase.

Preparing the cell counts for modeling

The analysis turns on a long-format table that keeps each region of interest (ROI) and immune phenotype as its own record. It contains 1,740 ROIs and 15 immune phenotypes, with counts linked to patient, biopsy phase, treatment arm and response. That structure matters: the model can compare cell composition across treatment and time while accounting for multiple ROIs from the same patient. The data are read from `sccomp_long_tme_immune_roi.csv`. The sample field becomes `ROI_id`, counts are converted to integers, and the categories are ordered explicitly: Baseline, On-treatment, then Post-treatment; C, then C&I; RD, then pCR. The preview shows the first five records for ROI `NTImg0011`, patient `NT031`, at Baseline in the C&I arm with residual disease. Its listed counts include 19 CD8⁺ T cells and 71 PD-L1⁺IDO⁺ APCs in a later example from ROI `NTImg1889`, patient `NT091`, during On-treatment. Those rows illustrate the layout; they don’t summarize the full dataset.

Estimating composition effects

The fitted `sccomp` model uses a multi-beta-binomial family and a composition formula with interactions among `Arm`, `BiopsyPhase` and `pCR`, plus a patient-level random intercept. Variability is modeled with an intercept only. Hamiltonian Monte Carlo supplies the inference, using the machine’s detected core count; `ROI_id`, `cell_group` and `count` identify the sample, phenotype and abundance fields. The reported fit covers 1,740 samples and 15 cell groups, with 4,035 parameter rows. The printed diagnostics include effective sample sizes and split-chain R-hat values; the excerpted rows show R-hat values of 1.00. That’s reassuring for those displayed estimates, though the abbreviated output doesn’t let us assess every parameter from the table alone. The model output also reports effects, intervals, null-hypothesis probabilities and false-discovery-rate adjusted values. A proportional fold change offers a more readable comparison between conditions, but it’s descriptive. Statistical evidence still comes from `sccomp_test()`. The example compares post-treatment C&I samples with residual disease against those with pathological complete response, holding arm and visit constant. It’s a useful way to frame the contrast; the excerpt provides no fold-change results, so it doesn’t establish which immune phenotypes differ or by how much.

What the post-treatment mix suggests

The clearest shift is in natural killer cells: their share rises 1.6-fold, from 0.0808 to 0.1269, in the C&I post-treatment comparison of patients with pCR versus residual disease. Regulatory T cells move sharply the other way, falling 3.4-fold, from 0.0275 to 0.0081. That contrast is more striking than the modest changes elsewhere, though the table alone can’t establish what drives it. Other populations shift less. CD20+B cells decline from 0.0645 to 0.0496 (1.3-fold), CD4+PD1+T cells from 0.0439 to 0.0275 (1.6-fold), and CD4+TCF1+T cells from 0.0918 to 0.0834 (1.1-fold). CD79a+ plasma cells rise from 0.0721 to 0.0816 (1.1-fold). If you’re interpreting these results, keep the scale in view: these are changes in proportions, and the table’s average uncertainty varies by group.

Model checks

The model’s reported sampling diagnostics look strong overall. Across 4,035 composition parameters, median R̂ is 1.001 and the maximum is 1.014; median bulk effective sample size is 4,837, with a minimum of 495, while tail effective sample size has a median of 2,850 and a minimum of 923. The variability terms are phenotype-specific intercepts. For those 15 coefficients, maximum R̂ is 1.003, minimum bulk effective sample size is 3,404, and minimum tail effective sample size is 2,451. Those checks support good convergence for the variability terms; the lower minimum bulk ESS among composition parameters is the figure to watch when judging the least well-sampled estimates.
Source: Stefano Mangiola · www.r-bloggers.com

Comments

Sign in to comment.
No comments yet. Be the first to comment.

Related Articles

Modelling cell-type proportions in repeated-measures desi...