Skip to content

Commit e2aebee

Browse files
committed
Avoid profile likelihood fits in Firth models
1 parent 2657719 commit e2aebee

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
- Hardened `plot_pca()`: errors early on duplicated sample names, an all-missing matrix, or too few samples instead of returning `NULL` (which broke `pca_plotly()`); joins scores to annotation with an explicit `by`; makes `prcomp(center = TRUE, scale. = FALSE)` explicit.
1414
- Hardened abundance heatmaps for sparse significant-feature subsets: when row or column distances are non-finite because of missing values, `plot_heatmap()` now falls back to the input order instead of returning a `ComplexHeatmap` object that fails during drawing.
1515
- `LFQDataPlotter$heatmap()` now shows only the `top_n` most variable features (default 1000), ranked by the prolfqua per-feature statistic (CV for untransformed data, sd for transformed, via `LFQDataStats`). Row clustering uses `stats::hclust`, which errors above 65536 features, so peptide-list / entrapment searches with tens of thousands of degenerate protein groups no longer crash the QC heatmap. Pass `top_n = NULL` (or `Inf`) to keep every feature.
16+
- `StrategyLogistf` now uses Wald confidence intervals instead of profiling every coefficient, preventing `firth_nested`
17+
analyses from stalling for days on proteins with hundreds or thousands of peptides.
1618

1719
# prolfqua 1.6.1
1820

R/logistf.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ StrategyLogistf <- R6::R6Class(
365365
DFT <- x |>
366366
dplyr::group_by(dplyr::across(dplyr::all_of(predictor_vars))) |>
367367
dplyr::summarize(Freq = dplyr::n(), .groups = "drop")
368-
tryCatch(logistf::logistf(self$formula, data = DFT, weights = Freq), error = .error_handler)
368+
tryCatch(logistf::logistf(self$formula, data = DFT, weights = Freq, pl = FALSE), error = .error_handler)
369369
},
370370

371371
#' @description Check if model is singular (NA coefficients or df < 2)

tests/testthat/test-Model.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ test_that("ModelFirth", {
102102
expect_s3_class(cv$plot, "ggplot")
103103
})
104104

105+
test_that("StrategyLogistf avoids coefficient-wise profile likelihood fits", {
106+
data <- data.frame(
107+
bin_resp = c(1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L),
108+
condition = rep(c("A", "B"), each = 4)
109+
)
110+
111+
fit <- strategy_logistf("bin_resp ~ condition")$model_fun(data)
112+
113+
expect_setequal(fit$method.ci, "Wald")
114+
})
115+
105116
test_that("build_model_glm_protein and build_model_glm_peptide return ModelFirth", {
106117
prot <- sim_lfq_data_protein_config(Nprot = 10, with_missing = TRUE, weight_missing = 0.5, seed = 7)
107118
prot_lfq <- LFQData$new(prot$data, prot$config)

0 commit comments

Comments
 (0)