looOmics: leave-one-out sensitivity analysis for omics differential models

Purpose

Differential-analysis results on high-dimensional omics data (gene expression, microbiome abundance tables) can be driven by a small number of samples. looOmics quantifies this by refitting the model once per left-out sample and measuring how much the coefficients move.

This is a sensitivity analysis, not a bad-sample detector. An influential sample may reflect genuine biological heterogeneity — a real subgroup, an extreme but valid responder. Flagged samples should be inspected, not automatically removed.

The package reruns the relevant pipeline for every leave-one-out fit where appropriate: for the DESeq2 engine, for example, size factors and dispersions are re-estimated for every fit.

Quick start

The recommended interface is a SummarizedExperiment. The first example uses a simulated matrix to introduce the workflow; subsequent examples show Bioconductor-native inputs.

library(looOmics)

We simulate 200 features, 16 samples, a two-level condition effect on the first 30 features, and one planted influential sample (S09):

set.seed(42)
n_feat <- 200
samples <- sprintf("S%02d", 1:16)
condition <- factor(rep(c("A", "B"), each = 8))
batch <- factor(rep(c("kit1", "kit2"), times = 8))

assay <- matrix(rnorm(n_feat * 16), n_feat, 16,
                dimnames = list(paste0("g", 1:n_feat), samples))
assay[1:30, condition == "B"] <- assay[1:30, condition == "B"] + 1.2

# planted influential sample: S09 (group B) has extreme values on g1-g20
assay[1:20, "S09"] <- assay[1:20, "S09"] + 6

col_data <- data.frame(
    condition = condition, batch = batch,
    depth = round(rnorm(16, mean = 5e6, sd = 4e5)),
    extraction = factor(rep(c("good", "good", "good", "bad"), times = 4)),
    row.names = samples
)

Run the leave-one-out analysis

res <- loo_sensitivity(assay, ~ condition + batch, col_data = col_data)
res
#> LOOResult (engine: lm)
#>   features: 200 | samples: 16 | terms: (Intercept), conditionB, batchkit2 
#>   flags: not computed (see flag_influential())
#>   profiles: not computed (see profile_flags())

Bioconductor input interoperability

looOmics uses SummarizedExperiment as its primary Bioconductor input interface. The assay stores features in rows and samples in columns, while colData stores the biological and technical sample metadata used both in the differential model and in downstream influence profiling.

se <- SummarizedExperiment::SummarizedExperiment(
    assays = list(logcounts = assay),
    colData = S4Vectors::DataFrame(col_data)
)
res_se <- loo_sensitivity(
    se, ~ condition + batch, engine = "lm",
    assay_name = "logcounts", parallel = FALSE
)
res_se
#> LOOResult (engine: lm)
#>   features: 200 | samples: 16 | terms: (Intercept), conditionB, batchkit2 
#>   flags: not computed (see flag_influential())
#>   profiles: not computed (see profile_flags())

For count-based RNA-seq analyses, use raw non-negative integer counts with the DESeq2 engine. The engine reconstructs and refits the DESeq2 workflow for each omitted sample, re-estimating size factors and dispersions rather than rounding or reusing normalized values.

set.seed(21)
count_samples <- sprintf("C%02d", 1:12)
count_condition <- factor(rep(c("control", "treated"), each = 6),
                          levels = c("control", "treated"))
count_meta <- data.frame(condition = count_condition,
                         row.names = count_samples)
count_matrix <- matrix(
    rnbinom(100 * 12, mu = 100, size = 10), nrow = 100,
    dimnames = list(paste0("gene", 1:100), count_samples)
)
count_matrix[1:20, count_condition == "treated"] <-
    count_matrix[1:20, count_condition == "treated"] + 80L
se_counts <- SummarizedExperiment::SummarizedExperiment(
    assays = list(counts = count_matrix),
    colData = S4Vectors::DataFrame(count_meta)
)
res_deseq2 <- loo_sensitivity(
    se_counts, ~ condition, engine = "deseq2",
    assay_name = "counts", parallel = FALSE, fitType = "mean"
)
res_deseq2
#> LOOResult (engine: deseq2)
#>   features: 100 | samples: 12 | terms: conditiontreated 
#>   flags: not computed (see flag_influential())
#>   profiles: not computed (see profile_flags())

The shifts table records, for every feature, model term, and left-out sample, the full-sample coefficient, the LOO coefficient, the raw shift (delta), the standardized deletion shift (dfbetas), full and LOO p-values, BH-adjusted q-values, within-term feature ranks, rank changes, and whether the feature’s significance status flipped. A positive rank_change means the feature moved to a numerically larger (weaker) rank after sample deletion:

head(tidy(res, what = "shifts"))
#> # A tibble: 6 × 16
#>   feature term       sample   beta    se   delta dfbetas p_full q_full rank_full
#>   <chr>   <chr>      <chr>   <dbl> <dbl>   <dbl>   <dbl>  <dbl>  <dbl>     <int>
#> 1 g1      (Intercep… S01     1.10  0.925  0.0623  0.0674  0.193  0.952        40
#> 2 g2      (Intercep… S01     0.338 1.07  -0.208  -0.194   0.724  0.983       144
#> 3 g3      (Intercep… S01     0.638 1.00  -0.0634 -0.0632  0.476  0.977        94
#> 4 g4      (Intercep… S01     0.865 0.953 -0.0535 -0.0561  0.314  0.952        66
#> 5 g5      (Intercep… S01    -0.174 1.07   0.133   0.124   0.855  0.983       171
#> 6 g6      (Intercep… S01     0.817 1.06  -0.213  -0.200   0.396  0.965        81
#> # ℹ 6 more variables: p_loo <dbl>, q_loo <dbl>, rank_loo <dbl>,
#> #   rank_change <dbl>, sig_flip <lgl>, error <lgl>

For ordinary linear models dfbetas coincides with classical DFBETAS; for other engines it is the analogous deletion-based standardized shift.

Flag influential samples

res <- flag_influential(res, method = "topk", k = 2)
res
#> LOOResult (engine: lm)
#>   features: 200 | samples: 16 | terms: (Intercept), conditionB, batchkit2 
#>   flagged influential samples:2/16 (topk)
#>   profiles: not computed (see profile_flags())

The planted sample S09 is recovered as the most influential sample:

flags <- tidy(res, what = "flags")
flags[order(-flags$score), ]
#> # A tibble: 16 × 5
#>    sample score metric      method flagged
#>    <chr>  <dbl> <chr>       <chr>  <lgl>  
#>  1 S09    3.24  max_dfbetas topk   TRUE   
#>  2 S05    2.24  max_dfbetas topk   TRUE   
#>  3 S01    1.62  max_dfbetas topk   FALSE  
#>  4 S03    1.53  max_dfbetas topk   FALSE  
#>  5 S16    1.53  max_dfbetas topk   FALSE  
#>  6 S07    1.52  max_dfbetas topk   FALSE  
#>  7 S02    1.29  max_dfbetas topk   FALSE  
#>  8 S11    1.19  max_dfbetas topk   FALSE  
#>  9 S15    1.15  max_dfbetas topk   FALSE  
#> 10 S10    0.945 max_dfbetas topk   FALSE  
#> 11 S06    0.932 max_dfbetas topk   FALSE  
#> 12 S12    0.930 max_dfbetas topk   FALSE  
#> 13 S13    0.912 max_dfbetas topk   FALSE  
#> 14 S14    0.833 max_dfbetas topk   FALSE  
#> 15 S04    0.802 max_dfbetas topk   FALSE  
#> 16 S08    0.708 max_dfbetas topk   FALSE

Per-term influence scores show which model terms drive each sample’s score:

head(influence_by_term(res))
#>          term sample max_abs_shift n_sig_flips
#> 1 (Intercept)    S01     1.6218963           0
#> 2 (Intercept)    S02     0.7641205           0
#> 3 (Intercept)    S03     1.5319187           0
#> 4 (Intercept)    S04     0.4743768           0
#> 5 (Intercept)    S05     2.2414967           0
#> 6 (Intercept)    S06     0.5512234           0

Profile flags against metadata

res <- profile_flags(res, model_covariates = c("condition", "batch"))
profiles(res)
#> FlagProfile: influential-sample metadata profiling
#>   flagged: 2 | not flagged: 14 
#> 
#> Univariate tests (BH-adjusted):
#>   covariate             test   p_value     p_adj     effect in_model
#>   condition fisher_simulated 1.0000000 1.0000000  0.0000000     TRUE
#>       batch fisher_simulated 0.4666667 0.9333333  0.3779645     TRUE
#>       depth           wilcox 0.2000000 0.8000000 -0.3689640    FALSE
#>  extraction fisher_simulated 1.0000000 1.0000000  0.2182179    FALSE
#> 
#> Multivariable model note: too few flagged or unflagged samples for adjusted logistic regression (at least five in each group are required)

The profile evaluates associations between flagged status and all selected sample metadata, including the original model variables (condition and batch) as well as technical variables (depth and extraction). In-model variables are explicitly labeled. P-values are BH-adjusted across the univariate family; an adjusted logistic model is fit only when the sample size and design support it. Covariates that cannot be tested are reported with reasons rather than silently dropped.

Plot

plot(res)

Bar plot of per-sample influence scores; the planted sample S09 stands out.

Relationship to existing Bioconductor tools

limma and DESeq2 provide established differential-expression modeling frameworks (Ritchie et al., 2015; Love et al., 2014). looOmics does not replace either package: it repeatedly refits these engines after omitting one sample at a time, then compares coefficients, standard errors, adjusted p-values, and within-term feature rankings. It also connects sample influence to biological and technical metadata. This provides an additional sensitivity-analysis layer around existing differential-analysis workflows.

For limma, users should supply appropriately normalized and log-transformed expression values. For DESeq2, users should supply raw integer counts. The package deliberately does not silently convert normalized or transformed values into counts.

Parallel execution

looOmics never changes the future plan itself; users control it:

future::plan(future::multisession, workers = 4)
res <- loo_sensitivity(se, ~ condition + batch, engine = "lm")
future::plan(future::sequential)

References

  • Love, M. I., Huber, W., and Anders, S. (2014). Moderated estimation of fold change and dispersion for RNA-seq data with DESeq2. Genome Biology, 15, 550. doi:10.1186/s13059-014-0550-8.
  • Ritchie, M. E., Phipson, B., Wu, D., Hu, Y., Law, C. W., Shi, W., and Smyth, G. K. (2015). limma powers differential expression analyses for RNA-sequencing and microarray studies. Nucleic Acids Research, 43(7), e47. doi:10.1093/nar/gkv007.

Session information

sessionInfo()
#> R version 4.6.2 (2026-10-29)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] future_1.82.0    looOmics_0.99.0  BiocStyle_2.41.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] SummarizedExperiment_1.43.0 gtable_0.3.6               
#>  [3] xfun_0.62                   bslib_0.12.0               
#>  [5] ggplot2_4.0.4               Biobase_2.73.2             
#>  [7] lattice_0.23-1              vctrs_0.7.3                
#>  [9] tools_4.6.2                 generics_0.1.4             
#> [11] stats4_4.6.2                parallel_4.6.2             
#> [13] tibble_3.3.1                pkgconfig_2.0.3            
#> [15] Matrix_1.7-6                RColorBrewer_1.1-3         
#> [17] S7_0.2.2                    S4Vectors_0.51.10          
#> [19] lifecycle_1.0.5             compiler_4.6.2             
#> [21] farver_2.1.2                DESeq2_1.53.7              
#> [23] Seqinfo_1.3.2               codetools_0.2-20           
#> [25] htmltools_0.5.9             sys_3.4.3                  
#> [27] buildtools_1.0.0            sass_0.4.10                
#> [29] yaml_2.3.12                 pillar_1.11.1              
#> [31] jquerylib_0.1.4             tidyr_1.3.2                
#> [33] BiocParallel_1.47.0         cachem_1.1.0               
#> [35] DelayedArray_0.39.8         abind_1.4-8                
#> [37] parallelly_1.50.0           locfit_1.5-9.12            
#> [39] tidyselect_1.2.1            digest_0.6.39              
#> [41] dplyr_1.2.1                 purrr_1.2.2                
#> [43] listenv_1.1.0               labeling_0.4.3             
#> [45] maketools_1.3.2             fastmap_1.2.0              
#> [47] grid_4.6.2                  cli_3.6.6                  
#> [49] SparseArray_1.13.5          magrittr_2.0.5             
#> [51] S4Arrays_1.13.2             utf8_1.2.6                 
#> [53] broom_1.0.13                future.apply_1.21.0        
#> [55] withr_3.0.3                 scales_1.4.0               
#> [57] backports_1.5.1             rmarkdown_2.32             
#> [59] XVector_0.53.0              matrixStats_1.5.0          
#> [61] globals_0.20.0              otel_0.3.0                 
#> [63] evaluate_1.0.5              knitr_1.52                 
#> [65] GenomicRanges_1.65.4        IRanges_2.47.5             
#> [67] rlang_1.3.0                 Rcpp_1.1.2                 
#> [69] glue_1.8.1                  BiocManager_1.30.27        
#> [71] BiocGenerics_0.59.13        jsonlite_2.0.0             
#> [73] R6_2.6.1                    MatrixGenerics_1.25.0