Repository navigation
fix: skip gene-set testing when no methods are given - #564
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
@BigomicsYoda please review with pr-agent |
computePGX died with 'subscript out of bounds' when a dataset was computed with include_default_gmt: false and gset.methods: []. Species GO sets are still added, so compute_testGenesets() reached gset.fitContrastsWithAllMethods() with an empty method vector: no method ran, Q stayed empty, and indexing the first result list failed. An empty methods vector also broke the "*" check (methods[1] is NA there). Guard both layers: return early in gset.fitContrastsWithAllMethods() so direct API and SDK callers get empty gene-set results, and skip the genesets step in compute_testGenesets() so the pgx object keeps empty gene-set results. NULL and "*" still mean all supported methods. Adds tests/testthat/test-gset-meta.R covering the empty-methods path (no error, no gene-set statistics) plus the unsupported-method-names path, and pins the gene-set statistics for a small fixture so the guard cannot silently change results when methods are given.
1540211 to
936d1ba
Compare
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This is by an automated agent, not a human.
Reported in #563:
computePGXcrashes withsubscript out of boundswhen a dataset is computed withinclude_default_gmt: falseandgset.methods: [].Cause
Species GO sets are still added, so the gene-set matrix is not empty and
compute_testGenesets()callsgset.fitContrastsWithAllMethods(methods = character(0)). No method runs,Qstays empty, andmethods <- colnames(Q[[1]])inR/gset-meta.rraisessubscript out of bounds. With a pristine checkout the same input fails even earlier:if (is.null(methods) || methods[1] == "*")evaluatesNAfor an empty vector, so the condition errors withmissing value where TRUE/FALSE needed.Fix
gset.fitContrastsWithAllMethods(): only expand"*"whenmethodsis non-empty, and return empty gene-set results (meta,sig.counts,outputs,matricesas empty lists,timingsas a 0 x 5 matrix) as soon as the intersected method vector is empty. This also protects direct API/SDK callers;NULLand"*"still mean all supported methods.compute_testGenesets(): skip the gene-set step whentest.methodsis an empty vector (returnspgxunchanged, so gene-set results stay empty), and keep results empty if none of the requested methods is supported instead of failing on the empty timings matrix. This matches the expected behaviour in the issue: skip testing, leave gene-set results empty, return without an error..Rdwording for bothtest.methodsandmethodsupdated to state the empty-vector behaviour.Downstream already tolerates missing gene-set results (
compute_prepare4display()guards withif (!is.null(geneSets))), so no caller changes were needed. The siblingngs.fitContrastsWithAllMethods()is not on this path and was left untouched.Tests
New
tests/testthat/test-gset-meta.Ron a small deterministic fixture (200 genes, 6 samples, 4 gene sets):methods = character(0)-> no error, empty result structure, no gene-set statistics.compute_testGenesets(pgx, test.methods = character(0))-> no error,gset.meta/gsetXstayNULL, expression matrix and gene sets untouched.camera+fryandspearman, so the early return cannot silently change results when methods are given.Verification
HEAD, then confirmed the patched code returns empty results with no error formethods = character(0)and fortest.methods = character(0).camera+fry,spearman, andcamera+fry+spearmanon the fixture.tests/testthat/test-gset-meta.R(4 tests, 32 assertions) andtests/testthat/test-gset-rankcor.Rpass locally;test-pgx-compute.Ris skipped by its own high-memory guard in this environment.Limitation: the full local suite could not be run here (
devtools::load_all()stops because theBorutadependency listed inDESCRIPTIONis not installed in this environment), so verification ran against the installedplaybase4.1.3 namespace with the two patched functions injected. The CI unittest build runs the fulldevtools::test().CI status
The
unittestcheck is red, but not because of this change. In the run for this head (46012964512) the gene-set contexts pass (gset-meta: 32 assertions in 12.4 s,gset-rankcor: 4), and the only failures are[ FAIL 2 | WARN 3 | SKIP 8 | PASS 356 ], both insidetests/testthat/test-wgcna-improvements.R, which arrived ondevelwith PR #556:test-wgcna-improvements.R:138—local_mocked_bindings(ai.ask = ...)fails withCan't find binding for ai.ask.ai.askwas removed from playbase incdc23cb10("superseded by omicsai"), yetwgcna.create_module_titles()still calls it bare, so the mock has no binding to replace.test-wgcna-improvements.R:116— the mockedgraphics::plot.defaultnever runs, socapturedisNULLinstead of the expected layout positions.The same two failures appear unchanged in the unittest run of the WGCNA branch itself (run
43435521605,feat-clust-wgcna@dbdfcdc8b,[ FAIL 2 | WARN 3 | SKIP 8 | PASS 315 ]), so thedeveltest suite is already red before this PR. Repairing it means changing the WGCNA/AI module, which is outside this ticket's scope.