Fix GWAS fine-mapping postprocessing export - #1401
Merged
Merged
Conversation
- pip_sum crashed on a GwasFineMappingResult (no context/trait column) for any region with signal; read identity fields NULL-safely so absent columns are NA. - export_top_loci produced a silent empty bed under --gwas: export_suffix stayed cis_results_db while step 1 writes block_results_db. Derive it from the gwas flag. - export_top_loci_3 combine now uses zcat -f so it doesn't abort on macOS once a non-empty bed exists to concatenate (no-op on Linux).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The GWAS path through
mnm_postprocessinghad three defects that only show up on a real GWAS region with signal, so the toy/empty-region tests never hit them.1.
pip_sumcrash on GWAS resultsfine_mapping_cis_db_export.Rbuilds thepip_sumtable by readingdb$contextanddb$trait. AGwasFineMappingResulthas neither column (it'sstudy, method, region_id, entry), sodb$contextisNULLandas.character(db$context[i])ischaracter(0)— length 0. On a region with signalgetPipreturns a real vector and the row hitsdata.frame(pip_sum = <len 1>, condition = character(0)), which errors with "arguments imply differing number of rows: 1, 0". Empty regions return early (getPipNULL), which is why it stayed hidden. The db and meta are written before this point, so onlypip_sumis lost — and the step fails at the very end.Fix: read each identity field NULL-safely, substituting
NAwhen the column is absent.getPipalready acceptscontext = NA.2.
export_top_locisilently empty under--gwasStep 1 writes
*.block_results_db.rdsin GWAS mode, butexport_top_loci_2hardcodedexport_suffix = 'cis_results_db.rds'. Under--gwasthe glob matches nothing,stop_ifskips gracefully, and step 3 combines over nothing and writes a 0-row.top_loci.bed.gzwith exit 0 — a silent empty result unless you knew to pass--export_suffix block_results_db.rdsby hand.Fix: default
export_suffixto empty and derive it from thegwasflag (block_results_db.rdsunder--gwas, elsecis_results_db.rds); an explicit--export_suffixstill overrides.3.
export_top_loci_3combine aborts on macOSThe combine ran
zcat "$f"without-fon its two emit lines; BSDzcatfails on.gzwithout-f, andset -euo pipefailaborts the step once fix #2 finally produces a non-empty bed to combine. Added-f, matching thezcat -fthe same block already uses in its guard. No-op on GNU/Linux.Validation
Real chr21 AD_Bellenguez FMRs, pecotmr 0.6.11 + susieR 0.16.6, full
sos run.pip_summatches an independentsum(getTopLoci(rds)$pip[pip>0])oracle on two GWAS objects (4.9979, 4.5563;condition=NA) and on a QTL result (9.8873; real context, unchanged).export_top_lociruns exit 0; combined bed is 24 rows for GWAS-default / QTL-default / explicit-override vs 0 rows for the unpatched baseline; combinedvariant_IDset matchesgetTopLoci(median05, 0.025)exactly.No pecotmr change; no change to fine-mapping numbers — this is the export layer only.
🤖 Generated with Claude Code