sccomp Models Repeated Single-Cell Composition Data in Cancer Biopsies
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.
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.