| Title: | Conformalized differential expression analysis of multi-condition single-cell data |
|---|---|
| Description: | conformeR provides conformal prediction layers for the cell neighborhood construction step of the LEMUR framework. It implements two complementary approaches, conformal clustering and conformal selection, to quantify uncertainty in the resulting cell neighborhoods, together with tools for visualizing and interpreting the resulting uncertainty sets. |
| Authors: | Justine Leclerc [cre, aut] (ORCID: <https://orcid.org/0009-0002-5667-0778>), Christof Seiler [aut] (ORCID: <https://orcid.org/0000-0001-8802-3642>), Digital Society Initiative - University of Zurich [fnd] (RAI - Reliable AI for Biomedicine) |
| Maintainer: | Justine Leclerc <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.4 |
| Built: | 2026-12-02 04:49:04 UTC |
| Source: | https://github.com/bioc/conformeR |
Runs a LEMUR analysis, identifies differential-expression neighborhoods,
and applies conformal procedures to a set of genes of interest.
The data are split into training, calibration, and test sets based on the
covariates specified in the LEMUR design formula. The results are added
to the input SingleCellExperiment, which is returned with its
original data and annotations preserved.
conformeR( sce, design_lemur = ~1, contrast_column, contrast_levels = NULL, n_embedding = 60, use_assay = "logcounts", test_fraction_lemur = 0.2, cp_train_frac = 0.5, cp_cal_frac = 0.25, cp_alpha = 0.05, genes_of_interest, what = c("conf_selection", "conf_clustering"), BPPARAM = BiocParallel::SerialParam(), verbose = TRUE )conformeR( sce, design_lemur = ~1, contrast_column, contrast_levels = NULL, n_embedding = 60, use_assay = "logcounts", test_fraction_lemur = 0.2, cp_train_frac = 0.5, cp_cal_frac = 0.25, cp_alpha = 0.05, genes_of_interest, what = c("conf_selection", "conf_clustering"), BPPARAM = BiocParallel::SerialParam(), verbose = TRUE )
sce |
A |
design_lemur |
A formula specifying the design used by LEMUR. All
variables must be columns of |
contrast_column |
A column name of |
contrast_levels |
|
n_embedding |
Number of dimensions in the LEMUR embedding. |
use_assay |
Character string specifying the assay to use. |
test_fraction_lemur |
Fraction of cells used as the LEMUR test set. |
cp_train_frac |
Fraction of cells used for conformal training (the remaining cells form the conformal test set). |
cp_cal_frac |
Fraction of the training cells set aside for conformal calibration. |
cp_alpha |
Error level of the conformal procedures, in (0, 1): target
false discovery rate for conformal selection and miscoverage level for
conformal clustering (target coverage |
genes_of_interest |
Character vector containing the names of genes
to include in the conformal analysis. They need to correspond to the
row names of |
what |
Character vector specifying the conformal procedure(s) to run:
|
BPPARAM |
A
|
verbose |
Logical indicating whether to display progress information. |
The conformal procedures are applied to a subset of genes of
interest. Genes are processed in chunks of five, which are distributed
over the workers of BPPARAM.
The input SingleCellExperiment with its original assays,
rowData, colData and reduced dimensions retained, enriched
with:
colData(sce)$conformeR_splitFactor with levels
"train", "cal" and "test" giving the set each cell
was assigned to. Conformal results are only defined for test cells.
reducedDim(sce, "LEMUR")The aligned LEMUR embedding
(cells x n_embedding).
reducedDim(sce, "LEMUR_UMAP"), reducedDim(sce,
"LEMUR_aligned_UMAP")
UMAPs of the LEMUR embedding before and after Harmony alignment.
altExp(sce, "conformeR")A SingleCellExperiment
with one row per gene of interest and the same columns as sce.
Its assays are:
DENumeric, the LEMUR predicted differential expression for every cell.
lemur_neighborhoodLogical, TRUE if the test cell
belongs to the LEMUR differential-expression neighborhood of the gene.
conf_selectionLogical, TRUE if the test cell is
selected by conformal selection, i.e. confidently belongs to the
neighborhood at FDR level cp_alpha (only if
"conf_selection" is in what).
conf_clustering_inside, conf_clustering_outside
Logical, TRUE if the label "inside the neighborhood"
(respectively "outside") belongs to the conformal prediction set of the
test cell (only if "conf_clustering" is in what).
conf_set_sizeInteger in {0, 1, 2}, the size of the
conformal clustering prediction set. Size 1 means an unambiguous
assignment; sizes 0 and 2 mean the assignment is ambiguous at level
cp_alpha.
All logical and set-size assays are NA for training and
calibration cells. The rowData contains the LEMUR neighborhood
statistics of the test set (prefixed with lemur_), the number of
cells in the LEMUR neighborhood (n_lemur_neighborhood), the number
of conformally selected cells (n_conf_selection), the score
quantile of conformal clustering (conf_quantile) and
cp_alpha.
metadata(sce)$conformeRA list with the analysis parameters, the contrast and the number of cells in each split.
Because all results are stored in the object, they stay synchronized when the object is subset.
cp_alpha
cp_alpha is an error level, not a coverage level: the target
coverage is .
cp_alpha is the target false discovery
rate (FDR). Conformal p-values are computed for every test cell and the
Benjamini-Hochberg procedure is applied at level cp_alpha. The
expected proportion of selected cells that do not truly belong to the
LEMUR neighborhood is at most cp_alpha. With
cp_alpha = 0.05, at most 5 percent of the selected cells are
expected to be false inclusions.
cp_alpha is the miscoverage level of
the prediction sets. For a new cell, the prediction set (inside and/or
outside the neighborhood) contains the true neighborhood label with
probability at least (marginal coverage).
With cp_alpha = 0.05, the prediction sets have 95 percent coverage.
Smaller values of cp_alpha give more conservative results: fewer
selected cells and larger (more often ambiguous) prediction sets.
plotter_conformal_selection,
plotter_conformal_clustering, lemur
data("sce_reduced") sce_conformer <- conformeR(sce_reduced, design_lemur = ~ patient_id + condition, contrast_column = "condition", n_embedding = 15, genes_of_interest = c( "ENSG00000163453", "ENSG00000163734" ) ) sce_conformer ## conformal results SingleCellExperiment::altExp(sce_conformer, "conformeR") SummarizedExperiment::rowData( SingleCellExperiment::altExp(sce_conformer, "conformeR") ) ## number of conformally selected test cells per gene rowSums(SummarizedExperiment::assay( SingleCellExperiment::altExp(sce_conformer, "conformeR"), "conf_selection" ), na.rm = TRUE)data("sce_reduced") sce_conformer <- conformeR(sce_reduced, design_lemur = ~ patient_id + condition, contrast_column = "condition", n_embedding = 15, genes_of_interest = c( "ENSG00000163453", "ENSG00000163734" ) ) sce_conformer ## conformal results SingleCellExperiment::altExp(sce_conformer, "conformeR") SummarizedExperiment::rowData( SingleCellExperiment::altExp(sce_conformer, "conformeR") ) ## number of conformally selected test cells per gene rowSums(SummarizedExperiment::assay( SingleCellExperiment::altExp(sce_conformer, "conformeR"), "conf_selection" ), na.rm = TRUE)
Visualizes gene-level differential expression and conformal clustering results on the aligned LEMUR UMAP embedding. Each gene gets two panels, stacked in an "Inside" and an "Outside" row. In each row, the cells of the LEMUR neighborhood (respectively outside it) are colored by their predicted differential expression. The conformal prediction sets are overlaid in two groups:
Prediction set of size 1 matching the row, i.e. confidently inside (or outside) the neighborhood.
Prediction set of size 0 or 2: the
assignment is uncertain at level cp_alpha. They are the same in
both rows.
A group is drawn as density contours when it has at least
min_cells_contour cells, and as circled cells otherwise. Contours
are scaled by the number of cells, so their size and number of levels can
be compared between the two groups of a panel. The number of cells in
each group is given in each panel title.
plotter_conformal_clustering( conformer_output, genes_to_plot, min_cells_contour = 30 )plotter_conformal_clustering( conformer_output, genes_to_plot, min_cells_contour = 30 )
conformer_output |
A |
genes_to_plot |
Character vector specifying the genes to plot. They
must be among the |
min_cells_contour |
Minimum number of cells in a group (confident or
ambiguous) before it is drawn as density contours rather than individual
cells (default 30). Use |
A single combined ggplot/cowplot object: the
"Inside" panel row stacked above the "Outside" panel row, each row
labeled accordingly, with one shared "Prediction set" legend (black =
confident, set size 1; grey = ambiguous, set size 0 or 2) below the
combined grid.
data("sce_reduced") sce_conformer <- conformeR(sce_reduced, design_lemur = ~ patient_id + condition, contrast_column = "condition", n_embedding = 15, genes_of_interest = c( "ENSG00000163453", "ENSG00000163734" ) ) plotter_conformal_clustering(sce_conformer, genes_to_plot = c( "ENSG00000163453", "ENSG00000163734" ) )data("sce_reduced") sce_conformer <- conformeR(sce_reduced, design_lemur = ~ patient_id + condition, contrast_column = "condition", n_embedding = 15, genes_of_interest = c( "ENSG00000163453", "ENSG00000163734" ) ) plotter_conformal_clustering(sce_conformer, genes_to_plot = c( "ENSG00000163453", "ENSG00000163734" ) )
Visualizes gene-level differential expression and conformal selection
results on the aligned LEMUR UMAP embedding. For each gene, the cells of
the LEMUR neighborhood are colored by their predicted differential
expression. When a gene has at least min_cells_contour selected
cells, green density contours show where the selected cells concentrate.
The number of selected cells is given in each panel title.
plotter_conformal_selection( conformer_output, genes_to_plot, min_cells_contour = 30 )plotter_conformal_selection( conformer_output, genes_to_plot, min_cells_contour = 30 )
conformer_output |
A |
genes_to_plot |
Character vector specifying the genes to plot. They
must be among the |
min_cells_contour |
Minimum number of selected cells for a gene
before density contours are drawn (default 30). Use |
Density contours are normalized to their maximum, so they look the same whether they summarise six cells or six hundred. They are therefore only drawn for genes with enough selected cells; for the other genes only the number of selected cells is reported.
A single combined ggplot/cowplot object showing
differential expression and conformal selection results for all
requested genes on the aligned LEMUR UMAP embedding. When contours are
drawn, a shared legend is added below the grid of gene panels.
data("sce_reduced") sce_conformer <- conformeR(sce_reduced, design_lemur = ~ patient_id + condition, contrast_column = "condition", n_embedding = 15, genes_of_interest = c( "ENSG00000163453", "ENSG00000163734" ) ) plotter_conformal_selection(sce_conformer, genes_to_plot = c( "ENSG00000163453", "ENSG00000163734" ) )data("sce_reduced") sce_conformer <- conformeR(sce_reduced, design_lemur = ~ patient_id + condition, contrast_column = "condition", n_embedding = 15, genes_of_interest = c( "ENSG00000163453", "ENSG00000163734" ) ) plotter_conformal_selection(sce_conformer, genes_to_plot = c( "ENSG00000163453", "ENSG00000163734" ) )
A small SingleCellExperiment object used to demonstrate the conformeR workflow. Random subset from a real dataset (see source). Code for reproducing from original dataset at: https://github.com/juslecl/conformeR-paper/tree/main/data_preparation 3k cells and 100 genes for 2 patients, 2 conditions, 3 cell-types.
data("sce_reduced")data("sce_reduced")
A SingleCellExperiment object.
This object is a subset of the dataset from Zhao et al. (2021), processed for use as an example dataset in conformeR.
Zhao, W., Dovas, A., Spinazzi, E., et al. (2021). Deconvolution of cell type-specific drug responses in human tumor tissue with single-cell RNA-seq. Genome Medicine, 13, 82. GEO accession: GSE148842.