On this page
Sensitivity and LD diagnostics
Evaluating how posterior inclusion probabilities (PIPs) and credible sets behave under alternative model specifications—and checking whether marginal association -scores are consistent with the linkage disequilibrium (LD) matrix—helps assess the robustness of fine-mapping conclusions. prusie provides structured workflows for multi-setting sensitivity comparisons (run_sensitivity, compare_fits) and SuSiE-RSS LD consistency checks (diagnose_ld).
The examples below build on the example and fit objects created in the quick-start tutorial. Plotting and LD diagnostics require the analysis extra.
Compare explicit settings
prusie.run_sensitivity evaluates a list of named alternative configurations against a baseline fit so that any shifts in PIPs or credible sets can be attributed to specific parameter or input changes. For example, the plan below tests a larger component count (L=6), a fixed effect-size prior variance (0.05), and a 90%-coverage credible-set extraction:
plan = [
{"name": "larger_L", "changes": {"L": 6}},
{"name": "fixed_variance", "changes": {
"scaled_prior_variance": 0.05,
"estimate_prior_variance": False,
}},
{"name": "coverage90", "report": {"coverage": 0.90}},
]
sensitivity = prusie.run_sensitivity(example["inputs"], plan, baseline=fit)
comparison = sensitivity["comparison"]
for record in sensitivity["records"]:
print(record["name"], "new fit:", record["fit_performed"])
Expected output:
baseline new fit: False
larger_L new fit: True
fixed_variance new fit: True
coverage90 new fit: False
The supplied fit serves as the baseline without refitting. Entries using "changes" inherit all baseline model settings (including any configured stopping rule) except for the specified overrides. Note that holding the effect-size prior variance fixed requires setting estimate_prior_variance=False; varying scaled_prior_variance while estimate_prior_variance=True tests sensitivity to variance initialization. Entries using "report" simply re-extract credible sets from the baseline posterior under new coverage or min_abs_corr thresholds without running IBSS.
If you have already fitted multiple SusieResult objects independently, pass them directly to prusie.compare_fits.
Start with a compact plan
For a standard first-pass robustness check, prusie.standard_sensitivity_plan constructs a preset plan that halves and doubles , re-evaluates credible sets at 90% and 99% coverage and at a stricter LD purity threshold (min_abs_corr=0.8), and runs credible-set refinement:
plan = prusie.standard_sensitivity_plan(L=example["parameters"]["L"])
sensitivity = prusie.run_sensitivity(example["inputs"], plan, baseline=fit)
comparison = sensitivity["comparison"]
for row in comparison["cs_stability_summary"]:
print(row["representative"], f"{row['recovered_in']}/{row['assessed_in']}")
You can append custom items to this list—such as alternative LD panels, genomic windows, or effective sample sizes (useful in meta-analyses with per-variant sample size heterogeneity):
plan.append({"name": "smaller_n", "changes": {"n": 900}})
The returned comparison dictionary summarizes robustness across settings:
comparison["fit_status"]records convergence status and iteration counts for each setting.comparison["cs_stability_summary"]reports how many alternative settings recover each baseline credible set.comparison["cs_stability"]provides pairwise detail for every setting, including matched component IDs, member Jaccard overlap, whether the lead representative variant is preserved, total PIP shift across members, and any omitted variants.
Plot and interpret the comparison
plot_sensitivity visualizes candidate variant PIPs across all evaluated settings as a baseline-first heatmap:
from prusie.viz import plot_sensitivity
sensitivity_view = plot_sensitivity(
comparison, layout="compact",
display_names={"baseline": "Baseline", "larger_L": "L = 6",
"fixed_variance": "Scaled prior variance\n0.05 (fixed)",
"coverage90": "CS coverage\n90%"},
)
figure, axes, plotted_data = sensitivity_view
For an example on a fit where refinement alters the credible sets, consider the official susieR convergence fixture:

Here, credible-set refinement shifts posterior mass from variants 32 and 35 to variant 33, whereas increasing L from 10 to 12 leaves the baseline credible sets intact (full numerical records are in comparison.json).
In plot_sensitivity, the baseline fit appears in the first column, and all columns share a uniform [0, 1] color scale. Interior probabilities near the boundaries are labeled <0.01 or >0.99 to distinguish them from exact 0 and 1, while variants absent from a particular fit are shaded grey (NA). Pass candidates_only=False to plot all variants on the comparison support, or layout="full" to add component-relation tables (layer="signals" focuses on retained credible sets, whereas layer="components" includes all active components). Maximum PIP differences from baseline across the full region are recorded in plotted_data["baseline_changes"].
Variant alignment and prior weights
When comparing fits across different variant windows, MAF filters, or LD references, each "inputs" entry in a sensitivity plan must provide its own aligned summary statistics, LD matrix, and unique variant_ids (see Variant order and alleles). run_sensitivity matches variants across fits by variant_ids and maps inherited prior weights and metadata accordingly.
When an alternative setting subsets the baseline variants, inherited prior weights are conditioned on the retained variant set and any inherited null_weight . Specifically, for raw weights , the effective null prior probability becomes
because the augmented weight vector is normalized in a single step. If an alternative window introduces new variant IDs under a non-uniform baseline prior, supply explicit prior_weights (and variant_metadata, if present on the baseline) for the new window:
alternative_inputs = dict(new_inputs, prior_weights=new_variant_weights)
alternative_plan = [{"name": "alternative_window", "inputs": alternative_inputs}]
Passing prior_weights=None explicitly requests uniform weights, and a uniform baseline automatically extends equal weights to newly introduced variant IDs. The resolved weight mapping and effective null probability for each run are recorded under prior_resolution in sensitivity["records"]. You can also pass a dictionary as cache= to run_sensitivity to reuse completed fits across plans without re-running identical configurations.
Common and union comparison support
When comparing fits defined on different sets of variants (e.g., different window boundaries or MAF cutoffs), prusie.compare_fits supports two domain modes via mode=:
| Mode | Displayed variants | Support for pairwise PIP and overlap metrics |
|---|---|---|
"union" (default) |
Union of variants across all fits | Pairwise intersection of each fit with the baseline |
"common" |
Global intersection of variants present in every fit | Global intersection across all fits |
To restrict all rankings, candidate selection, and PIP comparisons strictly to variants shared across every fit:
common_comparison = prusie.compare_fits(
sensitivity["fits"], baseline="baseline", mode="common",
R=example["inputs"]["R"], ld_reference="baseline",
)
Comparing fits never alters or renormalizes the individual posteriors: each fit's original alpha, credible sets, purities, and lead representatives remain intact, and any posterior mass falling outside the selected comparison support is logged in unobserved_mass. Between-fit signal relationships (split, merge, ambiguous, or unresolved when overlapping a diffuse active component without a retained CS) are determined from posterior overlap, credible-set membership overlap, and lead-variant LD rather than raw component row indices.
Diagnose consistency of z and LD
When summary statistics and LD come from different cohorts—or when allele orientation errors occur during harmonization—inconsistencies between -scores and R can cause slow convergence, decreasing ELBOs, or spurious credible sets. prusie.diagnose_ld evaluates each variant's observed -score against its conditional expectation given all other variants and the LD matrix:
ld = prusie.diagnose_ld(
example["inputs"]["z"], example["inputs"]["R"],
n=example["inputs"]["n"], variant_ids=fit.variant_ids,
)
print(ld["status_counts"])
Following the SuSiE-RSS diagnostic model of Zou et al. (2022), under the null hypothesis the Wald-adjusted scores follow
where regularizes the LD matrix toward independence (diagnose_ld estimates via method="null-mle" by default; estimate_s_rss also supports "null-partialmle" and "null-pseudomle"). A normal scale mixture fitted to the standardized conditional residuals via constrained maximum likelihood yields the likelihood ratio () comparing a sign-flipped score () against the observed score (). By default, a variant is flagged as a candidate allele flip when both (flip_log_lr=2) and (flip_abs_z=2):
| Assessment state | Meaning |
|---|---|
Assessed, flagged |
Joint allele-flip criterion ( and $ |
Assessed, not flagged |
Joint criterion was evaluated and not met |
Conditional only |
Conditional mean and residual were computed, but the mixture-model flip test did not converge |
Not assessed |
Variant had a missing (NaN) input -score or could not be evaluated |
Note that diagnose_ld is purely diagnostic and never modifies z or R in place. When variants are flagged, inspect effect-allele alignment, strand orientation, and reference-panel ancestry (see Variant order and alleles).
You can visualize the conditional -score diagnostic and include both the sensitivity comparison and LD diagnostics in an offline HTML report:
from prusie.viz import plot_ld_diagnostics
from prusie.report import write_report
ld_view = plot_ld_diagnostics(ld, layout="compact")
summary = prusie.summarize(fit, example["inputs"]["R"], z=example["inputs"]["z"])
print(prusie.summary_text(summary, ld=ld, comparison=comparison))
report = write_report(
summary, "output/diagnostics", ld=ld, comparison=comparison,
figures={"Sensitivity": sensitivity_view, "LD diagnostics": ld_view},
)
In plot_ld_diagnostics, the secondary panel displays standardized conditional residuals by default; pass auxiliary="log_lr" to plot the allele-flip log likelihood ratios instead.