feat(fine-mapping): planner for fine-map study combinations.#1265
Conversation
| ) | ||
|
|
||
|
|
||
| class HasMappedTrait(MethodConstraint): |
There was a problem hiding this comment.
I don't understand this function. Isn't it always present? And why not to use DiseaseIDs?
Is it happening before study index validation?
There was a problem hiding this comment.
This checks if the traitFromSourceMappedIds are in the studyIndex. In the staging bucket there are a few cases where the study does not have any efos. Examples below.
+--------------+--------------------------+
| studyId | traitFromSourceMappedIds |
+--------------+--------------------------+
| GCST90667999 | NULL |
| GCST90727244 | NULL |
| GCST90668000 | NULL |
| GCST90667998 | NULL |
+--------------+--------------------------+
I raised it to GWAS Catalog a new months ago, but the staging still has these issues on the slack with them
| STUDY ACCESSION | DISEASE/TRAIT | MAPPED_TRAIT |
|-----------------|-----------------------------------------|--------------|
| GCST90727244 | Peripheral venous and lymphatic disease | NULL |
| GCST90667998 | Kidney cortex volume | NULL |
| GCST90667999 | Kidney medulla volume | NULL |
| GCST90668000 | Kidney sinus volume | NULL |
AS to your other question, we can not use DIseaseIds, as these are populated only after the study validation step, which is part of the Pipeline run every 3 months, but this process shall be decoupled from that, as I do not want to run the fine-mapping during Pipeline (this would increase release process way too much). The clear scenario is to use traitFromSourceMappedIds at this stage and later determine which credible sets are derived from truely correct efo term studies during validation.
604180c to
faa7ee1
Compare
| StudyQualityCheck.SMALL_NUMBER_OF_SNPS, | ||
| StudyQualityCheck.SUMSTATS_NOT_AVAILABLE, | ||
| ], | ||
| relative_sample_size_threshold=0.95, |
There was a problem hiding this comment.
Is it the same we used in SuSiE?
✨ Context
FineMappingPlanGeneratorStepreads the study index and emits aFineMappingPlannerdataset that routes each study to a fine-mapping method based on a set of per-study eligibility constraints. This PR implements the constraint model, the MultiSuSiE constraint set, and the step itself, wired into the Hydra config surface.🛠 What does this PR implement
MethodConstraintmodel (method/fine_mapping/constraint.py): aProtocol-based per-study constraint abstraction (IsAllowedStudyType,HasSumstats,HasMappedTrait,PassSumstatQC,HasAllowedAnalysisFlags,HasAllowedMajorAncestry), each annotating aStudyIndexwith a boolean verdict viaConstraintResult.MultiSuSiEConstraintSet(method/fine_mapping/constraint_set.py): composes the constraints above, resolves per-study eligibility, selects one representative study per (trait, major ancestry) group by effective sample size, and groups eligible studies sharing a trait across ancestries into a deterministicrunIdfor multi-ancestry runs.resolve()is decomposed into named, independently-readable stages (constraint resolution, n_eff/major-ancestry derivation, representative-study selection, run-id assignment) instead of one long chained expression.runIdassignment: an unbounded window aggregation was evaluated over the (large) null-runIdpartition unnecessarily; scoping it to non-null rows only cut a real-data run from ~12-15 minutes to ~23 seconds.studyId) that raises if resolution ever drops or duplicates studies.FineMappingPlannerdataset (dataset/fine_mapping.py): the output schema (studyId,runId,constraints,route), plusFineMappingRouteand aunionByName-based__add__for combining multiple constraint sets' plans (documented as unique per(studyId, route), notstudyIdalone).FineMappingPlanGeneratorStep(finemapping_planner.py): reads a study index, resolves the registered constraint set(s), and writes the combined plan as parquet partitioned byroute, sorted by(route, runId, studyId).FineMappingPlanGeneratorConfigregistered inconfig.pyso the step is runnable via the standard CLI (step=fine_mapping_plan_generator).common/spark.py'sall_struct_fields_in_arraybuilt invalid SQL via f-string-interpolatedColumnobjects; its own doctest was failing at HEAD.study_index.py: minor validation fixes surfaced while buildingvalidate_ccs()-dependent tests.docs/python_api/datasets/fine_mapping.md,docs/python_api/methods/fine_mapping_constraints.md,docs/python_api/steps/fine_mapping_plan_generator.md.MultiSuSiEConstraintSet.resolve()'s grouping/run-id logic, a fast unit test of the step's orchestration, and a mocked integration test exercising the real Spark write path end-to-end.🙈 Missing
MultiSuSiEroute is implemented; PICS and SuSiE-inf routes are separate future work.🚦 Before submitting
devbranch?make test)?uv run pre-commit run --all-files)?Note: the "branch up-to-date with dev" checkbox is left unchecked — worth verifying/rebasing before merge, since I didn't check that as part of this session's work.