mecfs_bio.build_system.task.sldsc.sldsc_regression_inputs
Turn gwaslab sumstats plus prepared S-LDSC references into kernel inputs, reproducing the preprocessing of ldsc's cell_type_specific as wrapped by gwaslab's estimate_h2_cts_by_ldsc: rows restricted to gwaslab's bundled HapMap3 list (rsID present, and EA/NEA equal to the HapMap3 A1/A2 in either orientation; the list depends on the sumstats' genome build), Z from BETA/SE, rows with missing SNP/Z/alleles dropped, an inner join onto the baseline SNP order (the prepared baseline is already restricted to SNPs with a weight LD score, matching ldsc's inner join with w_ld), N cast to int64 by truncation, and the chi-square filter Z^2 < max(0.001 * max(N), 80).
Fail-fast checks with no gwaslab counterpart: fewer than min_hapmap3_snps sumstats SNPs in the baseline's HapMap3 regression-SNP universe raises; a regression SNP with missing N raises (gwaslab fills with the median N); a SNP appearing more than once raises (gwaslab's merge would duplicate the row).
M_5_50 (passed through to the kernel with each LD-score column): 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).
Classes:
Functions:
-
build_regression_inputs– -
load_sldsc_sumstats–SNP, Z, N (Float64, possibly null) for every usable HapMap3 row of the sumstats.
AlignedSLDSCRegression
Attributes:
-
inputs(SLDSCRegressionInputs) – -
models(tuple[SLDSCModel, ...]) –
build_regression_inputs
build_regression_inputs(
sumstats: DataFrame,
baseline: PreparedBaseline,
annotation_set: PreparedAnnotationSet,
min_hapmap3_snps: int,
) -> AlignedSLDSCRegression
Source code in mecfs_bio/build_system/task/sldsc/sldsc_regression_inputs.py
load_sldsc_sumstats
SNP, Z, N (Float64, possibly null) for every usable HapMap3 row of the sumstats.