mecfs_bio.build_system.task.sldsc.prepared_sldsc_reference
Format-neutral on-disk contract for S-LDSC reference data.
A prepared annotation set is a directory holding: ld_scores.parquet: SNP, CHR, BP, then one float32 column per unique LD-score source, rows sorted by CHR then BP with unique SNPs. m_5_50.parquet: one row per LD column: column id, genome-wide M_5_50, source. models.parquet: one row per analysis label: label, target column id, control column ids.
A prepared baseline holds ld_scores.parquet and m_5_50.parquet for the baseline annotations plus w_ld.parquet (SNP and the regression-weight LD score). Its rows are restricted to SNPs that have a weight LD score (the HapMap3 weights exclude the MHC region), so w_ld and the baseline LD scores share one SNP column.
M_5_50: for each annotation, the sum of its values over reference-panel SNPs with minor allele frequency above 5% (for a binary annotation, the number of common SNPs it contains). In the LDSC model E[chi2_j] = N_j * sum_c tau_c * l(j, c) + N_j * a + 1, with l(j, c) the LD score of SNP j with annotation c and tau_c the per-SNP heritability contributed by annotation c, M_5_50 converts per-SNP effects into the heritability attributed to an annotation (h2_c = tau_c * M_5_50_c).
Adapter Tasks (one per source format) write this contract; the vectorized S-LDSC Task reads it and knows nothing about the source format.
Classes:
-
LdScoreTable–LD scores for a fixed SNP universe.
-
PreparedAnnotationSet– -
PreparedBaseline–Baseline LD scores plus the regression-weight LD score.
-
SLDSCAnnotationModel–One S-LDSC analysis: the reported target column plus the control columns it is fit with.
Functions:
-
read_prepared_annotation_set– -
read_prepared_baseline– -
write_prepared_annotation_set– -
write_prepared_baseline–
Attributes:
-
BP_COL– -
CHR_COL– -
LD_SCORES_FILENAME– -
MODELS_FILENAME– -
M_5_50_FILENAME– -
SNP_COL– -
W_LD_COL– -
W_LD_FILENAME–
LdScoreTable
LD scores for a fixed SNP universe.
snps: SNP, CHR, BP in row order (sorted by CHR then BP, SNP unique). column_ids: internal id of each LD column (matrix column order). sources: human-readable provenance of each column (e.g. file prefix and column name). matrix: (n_snps, n_columns) float32 LD scores. m_5_50: (n_columns,) genome-wide M_5_50 per column.
Methods:
-
column_index– -
take_rows–The table restricted to the given row indices, in that order.
Attributes:
-
column_ids(tuple[str, ...]) – -
m_5_50(ndarray) – -
matrix(ndarray) – -
snps(DataFrame) – -
sources(tuple[str, ...]) –
column_index
take_rows
The table restricted to the given row indices, in that order.
Source code in mecfs_bio/build_system/task/sldsc/prepared_sldsc_reference.py
PreparedAnnotationSet
Attributes:
-
ld(LdScoreTable) – -
models(tuple[SLDSCAnnotationModel, ...]) –
PreparedBaseline
Baseline LD scores plus the regression-weight LD score.
w_ld: columns SNP and w_ld, row-aligned with ld.snps (same SNPs in the same order).
Attributes:
-
ld(LdScoreTable) – -
w_ld(DataFrame) –
SLDSCAnnotationModel
One S-LDSC analysis: the reported target column plus the control columns it is fit with.
Attributes:
-
control_columns(tuple[str, ...]) – -
label(str) – -
target_column(str) –