graphld.genesets¶
Gene set annotation utilities.
genesets
¶
Gene set annotation utilities for graphREML.
This module keeps the GraphLD-facing LDSC annotation contract while reusing the lightweight score-test implementation for gene-table loading, GMT loading, position encoding, nearest-gene mapping, and gene-to-variant conversion.
convert_gene_sets_to_variant_annotations
¶
convert_gene_sets_to_variant_annotations(gene_sets: dict[str, list[str]], variant_table: DataFrame, gene_table: DataFrame, nearest_weights: ndarray) -> pl.DataFrame
Convert gene sets to LDSC-style variant-level annotations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gene_sets
|
dict[str, list[str]]
|
Dictionary mapping gene set names to gene symbols or Ensembl IDs |
required |
variant_table
|
DataFrame
|
Variant table DataFrame with CHR, POS, SNP columns |
required |
gene_table
|
DataFrame
|
Gene table DataFrame with CHR, POS, gene_id, gene_name columns |
required |
nearest_weights
|
ndarray
|
Weights for k-nearest genes |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with CHR, BP, SNP, CM, and one column per gene set. |
Source code in src/graphld/genesets.py
load_gene_annotations
¶
load_gene_annotations(gene_annot_dir: str, variant_table: DataFrame, gene_table_path: str, nearest_weights: ndarray, annot_names: Optional[list[str]] = None) -> pl.DataFrame
Load GMT gene annotations and convert them to variant-level annotations.