Skip to content

mecfs_bio.constants.polyfun_annotation_families

Map each baseline-LF 2.2.UKB annotation to one of eleven functional families.

Used for the hybrid attribution in the polyfun explainability pipeline: ridge weights are fit on all 187 annotations, but contributions are aggregated to families for headline reporting.

The family taxonomy is grounded in published sources, not invented: - The functional-group names (non_synonymous, coding, conserved, promoter_or_enhancer, histone_marks, repressed, other) are the grouping the polyfun authors themselves use for these annotations in the sub-additive simulation of their Supplementary Note (Weissbrod et al. 2020, Nat Genet). - maf_bins and ld_related_continuous are the MAF-bin and LD-related continuous annotation groups introduced in Gazal et al. 2017 (Nat Genet) baseline-LD (the Continuous rows of Gazal et al. 2018 Supplementary Table 1). - molecular_qtl are the MaxCPP fine-mapped molecular-QTL annotations of Hormozdiari et al. 2018 (Nat Genet). - open_chromatin (DHS/FetalDHS/DGF accessibility annotations) is the ONE deliberate refinement of polyfun's scheme, which otherwise lumps these into "others"; broken out so the explainability figure can show an accessibility panel. TFBS/CTCF/Transcribed/Intron remain in other, as in polyfun's scheme.

Per-annotation assignment is rule-based (keyword + a small override set) and follows the annotation names and their source datasets (Gazal et al. 2018 Supplementary Table 1). The test in test_polyfun_annotation_families.py asserts every one of the 187 annotations resolves to a valid family.

Lives under mecfs_bio.constants (rather than mecfs_bio.assets, alongside the 187-name list in baseline_lf_annotation_names.py) because the ridge annotation weights Task in mecfs_bio.build_system needs to attach a family to each annotation, and the layered-architecture contract in .importlinter does not let build_system import assets.

Functions:

Attributes:

AnnotationFamily module-attribute

AnnotationFamily = Literal[
    "non_synonymous",
    "coding",
    "conserved",
    "promoter_or_enhancer",
    "histone_marks",
    "repressed",
    "open_chromatin",
    "maf_bins",
    "ld_related_continuous",
    "molecular_qtl",
    "other",
]

FAMILY_SHORT_LABELS module-attribute

FAMILY_SHORT_LABELS: dict[AnnotationFamily, str] = {
    "non_synonymous": "nonsyn",
    "coding": "cod",
    "conserved": "cons",
    "promoter_or_enhancer": "prom_enh",
    "histone_marks": "hist",
    "repressed": "repr",
    "open_chromatin": "openchr",
    "maf_bins": "maf",
    "ld_related_continuous": "ld",
    "molecular_qtl": "qtl",
    "other": "other",
}

family_for_annotation

family_for_annotation(name: str) -> AnnotationFamily

Return the functional family for a baseline-LF annotation column name.

Source code in mecfs_bio/constants/polyfun_annotation_families.py
def family_for_annotation(name: str) -> AnnotationFamily:
    """Return the functional family for a baseline-LF annotation column name."""
    for pattern, family in _OVERRIDES:
        if pattern in name:
            return family
    for keywords, family in _KEYWORD_RULES:
        if any(keyword in name for keyword in keywords):
            return family
    raise ValueError(f"No family rule matched annotation {name!r}")