scripts/run_layer2_perturbation_and_regulatory_plane.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/run_layer2_perturbation_and_regulatory_plane.py · SHA-256: 3220e68f97203dbc…
},
"evidence_counting_unit": "unique canonical gene, PMID and direction; aliases contribute once",
"canonical_gene_aliases": {g: list(aliases) for g, aliases in canonical_gene_aliases.items()},
"deprecated_display_gene_keys_to_canonical_gene": legacy_gene_keys,
"directional_link_normalization_denominator_prior": 148.0,
"legacy_display_counts_must_not_be_summed": True,
"ring1_evidence_weight_prior_heuristic_note": (
f"ring1_continuous_evidence_weight ({directional_study_total}/148 = {ring1_evidence_weight:.6f}) is a declared corpus-level prior confidence scalar "
f"(locked per DEC-007; canonical per-gene directional link counts: "
+ ", ".join(
f"{g} {canonical_gene_effect_counts[g]['protective'] + canonical_gene_effect_counts[g]['penalty']}/{directional_study_total}"
for g in sorted(
canonical_gene_effect_counts,
key=lambda k: (-(canonical_gene_effect_counts[k]["protective"] + canonical_gene_effect_counts[k]["penalty"]), k),
)
)
+ ") rather than a mechanistic copy-number law; wet-lab posterior calibration "
"is governed by data/extracted/wetlab_bayesian_posterior_calibration_v0.8.0.json."
),
},
"external_benchmark_reference_anchors_not_fitted": [
{
"accession": "NCBI GEO GSE190726",
"citation": "Chandra et al. 2022 Nature Communications PMID:36289205 (PMC9606380)",
"published_source_measurements": {
"fig_2c_stage5_neurog3_immunostaining_pct": {"wt_mean_pct": 28.81, "tyk2_ko_mean_pct": 15.45, "relative_change_pct": -46.37},
"fig_2i_stage7_ins_flow_cytometry_pct": {"wt_mean_pct": 29.78, "tyk2_ko_mean_pct": 21.90, "relative_change_pct": -26.46},
"fig_2k_stage7_ins_immunostaining_pct": {"wt_mean_pct": 23.73, "tyk2_ko_mean_pct": 16.01, "relative_change_pct": -32.54},
},
"rescaled_model_prior_baselines": {
"stage4_pp2_fraction": {"wt_prior": 0.840, "tyk2_ko_prior": 0.816, "relative_change_pct": -2.86},
"stage6_neurog3_ep_fraction": {"wt_prior": 0.678, "tyk2_ko_prior": tyk2_ko_s6_mean, "relative_change_pct": round(100.0 * (tyk2_ko_s6_mean / 0.678 - 1.0), 2)},
"stage7_sc_beta_yield_fraction": {"wt_prior": 0.600, "tyk2_ko_prior": tyk2_ko_s7_mean, "relative_change_pct": round(100.0 * (tyk2_ko_s7_mean / 0.600 - 1.0), 2)},
},
"role": "Published summary statistics from Chandra et al. 2022 Source Data (Fig 2c S5 NEUROG3+ -46.37% [28.81% -> 15.45%]; Fig 2k S7 INS+ immunostaining -32.54% [23.73% -> 16.01%]; Fig 2i S7 INS+ flow -26.46% [29.78% -> 21.90%]) anchor the relative perturbation reductions applied to OpenIslet's assigned Stage-0 WT baselines (Stage 4 PP2 0.816 vs 0.840 WT, Stage 5/6 NEUROG3+ 0.364 vs 0.678 WT [-46.31%], Stage 7 SC-beta 0.408 vs 0.600 WT [-32.00%]); raw count matrices are not locally refitted.",
}
],
"stage7_endocrine_yield_reconciliation_note": {
"pre_sort_differentiation_yield_interpretation": (
"Each genotype profile reports pre-sort Stage-7 lineage yield fractions (stage7_sc_beta_yield_fraction, "
f"stage7_sc_alpha_yield_fraction, stage7_sc_delta_yield_fraction; e.g. Arm 1B endocrine sum = "
f"{round(arm1b_profile['stage7_sc_beta_yield_fraction'] + arm1b_profile['stage7_sc_alpha_yield_fraction'] + arm1b_profile['stage7_sc_delta_yield_fraction'], 4)}, "
f"Arm 1A = {round(by_id['SCENARIO_A_ARM_1A_BICISTRONIC_P2A_COMPARATOR']['stage7_sc_beta_yield_fraction'] + by_id['SCENARIO_A_ARM_1A_BICISTRONIC_P2A_COMPARATOR']['stage7_sc_alpha_yield_fraction'] + by_id['SCENARIO_A_ARM_1A_BICISTRONIC_P2A_COMPARATOR']['stage7_sc_delta_yield_fraction'], 4)}, "
f"TYK2-/- = {round(tyk2_profile['stage7_sc_beta_yield_fraction'] + tyk2_profile['stage7_sc_alpha_yield_fraction'] + tyk2_profile['stage7_sc_delta_yield_fraction'], 4)}), "
"with the complement (1 - endocrine_sum) representing non-endocrine/ductal/enterochromaffin off-target fractions prior to magnetic/FACS sorting."
),
"post_sort_reaggregation_link_to_layer4": (
"Downstream Layer 4 metabolic and paracrine ODEs model post-sort CD49a+/CD26-purified and re-aggregated "
"tri-hormonal clusters Standardized to the 60:30:10 beta:alpha:delta target ratio (120 um diameter)."
),
"marginal_uncertainty_vs_simplex_note": (
"Per-lineage p10/p90 bands are independent marginal Gaussian quantiles rather than joint Dirichlet simplex draws, "
"so summing marginal p90 upper bounds across beta + alpha + delta can exceed 1.0."
),
},
"stage_specific_grn_edges": grn_edges,
"profile_count": len(perturbation_profiles),
"uncertainty_semantics": "independent prior scenario draws, no posterior fitting or held-out validation",
"prior_interval_quantile_method": "Hyndman-Fan type 7 linear empirical quantiles; even-sample median averages the two middle draws",
"hour0_hlae_inducible_vs_constitutive_kinetics_note": {
"source": "derived from the current typed profiles; no measured protection claim",
"arm1b_cd47_to_wt_fold": (arm1b_profile["hour0_basal_cd47_molecules_per_cell"] / wt_profile["hour0_basal_cd47_molecules_per_cell"]
if wt_profile["hour0_basal_cd47_molecules_per_cell"] > 0 else None),
"arm1b_cd47_to_wt_fold_status": ("DEFINED_FROM_CURRENT_PRIORS" if wt_profile["hour0_basal_cd47_molecules_per_cell"] > 0
else "UNDEFINED_ZERO_REFERENCE_CD47_DENSITY"),
"cd47_ratio_denominator_genotype_id": wt_profile["genotype_id"],
"tyk2_relative_yield_comparisons": {"baseline_genotype_id": wt_profile["genotype_id"],
"stage6_relative_change_pct": 100 * (tyk2_profile["stage6_neurog3_ep_fraction"] / wt_profile["stage6_neurog3_ep_fraction"] - 1),
"stage7_relative_change_pct": 100 * (tyk2_profile["stage7_sc_beta_yield_fraction"] / wt_profile["stage7_sc_beta_yield_fraction"] - 1)},
"profiles": [{"genotype_id": p["genotype_id"],
"resting_hlae_molecules_per_cell": p["hour0_resting_unstimulated_hlae_molecules_per_cell"],
"resting_hlae_fraction_of_wt": round(p["hour0_resting_unstimulated_hlae_molecules_per_cell"] / basal_hlae_wt, 4) if basal_hlae_wt > 0 else None,
"ifng24h_hlae_molecules_per_cell": p["ifng_24h_induced_hlae_molecules_per_cell"],
"hour0_cd47_molecules_per_cell": p["hour0_basal_cd47_molecules_per_cell"]}
for p in perturbation_profiles if p["genotype_id"].startswith("SCENARIO_A")],
"arm_selection_determinacy_note": (
"Under a strict resting-state (Hour-0 unstimulated) threshold of 15,000 or 25,000 molecules/cell, "
f"constitutive Arm 1A ({by_id['SCENARIO_A_ARM_1A_BICISTRONIC_P2A_COMPARATOR']['hour0_resting_unstimulated_hlae_molecules_per_cell']:,} molecules/cell, "
f"{round(by_id['SCENARIO_A_ARM_1A_BICISTRONIC_P2A_COMPARATOR']['hour0_resting_unstimulated_hlae_molecules_per_cell'] / basal_hlae_wt, 4)}x WT; "
f"24h IFN-g {by_id['SCENARIO_A_ARM_1A_BICISTRONIC_P2A_COMPARATOR']['ifng_24h_induced_hlae_molecules_per_cell']:,} molecules/cell) clears the gate at Hour 0 whereas "
f"inducible Arm 1B ({arm1b_profile['hour0_resting_unstimulated_hlae_molecules_per_cell']:,} molecules/cell, "
f"{round(arm1b_profile['hour0_resting_unstimulated_hlae_molecules_per_cell'] / basal_hlae_wt, 4)}x WT) is below threshold until inflammatory/islet-niche "
f"IFN stimulation ({arm1b_profile['ifng_24h_induced_hlae_molecules_per_cell']:,} molecules/cell at 24h IFN-g) or wet-lab promoter tuning."
),
"protection_status": "PREREGISTERED_PENDING_RESTING_AND_IFNG_LICENSED_NK_ASSAYS",
},
"er_heavy_chain_flux_and_upr_hazard_muse_r3": {
"evidence_class": "BIOPHYSICAL_ERAD_FLUX_HAZARD_MODEL_REQUIRES_GATE_0E_ER_WETLAB_QUALIFICATION",
"primary_citations": ["PMID:12006653", "PMID:32719542"],
"mechanism": (
"In B2M-/- cells where the only beta-2-microglobulin is intramolecularly tethered inside the HLA-E*01:03 SCT via a 15-aa (G4S)3 linker, "
"endogenous HLA-A, HLA-B, and HLA-C promoters remain intact and highly inducible by IFN-gamma/IFN-alpha via conserved ISRE/GAS elements, "
"synthesizing orphan MHC-I heavy chains that cannot assemble with free beta2m and are retained in the ER membrane bound to calnexin/BiP "
"until cleared by HRD1/SEL1L-dependent ER-associated degradation (ERAD; Spiliotis et al. 2002 PMID:12006653)."
),
"synthesis_and_erad_steady_state_bounds": {
"wt_surface_mhci_molecules_per_cell_range": [100000, 300000],
"wt_mhci_turnover_half_life_hours": 12.0,
"wt_mhci_inflammatory_accelerated_turnover_half_life_hours": 6.0,
"ifn_transcriptional_fold_induction_range": [6.0, 15.0],
"ifn_stimulated_orphan_hc_synthesis_flux_at_t12_12h_molecules_per_min_low_central_high": [
round(100000.0 * math.log(2.0) / (12.0 * 60.0) * 6.0, 1),
round(200000.0 * math.log(2.0) / (12.0 * 60.0) * 10.0, 1),
round(300000.0 * math.log(2.0) / (12.0 * 60.0) * 15.0, 1),
],
"ifn_stimulated_orphan_hc_synthesis_flux_at_t12_6h_inflammatory_upper_molecules_per_min": round(
300000.0 * math.log(2.0) / (6.0 * 60.0) * 15.0, 1
),
"ifn_stimulated_orphan_hc_synthesis_flux_molecules_per_min_range": [578, 8664],
"central_orphan_hc_synthesis_flux_at_200k_wt_10x_ifn_molecules_per_min": 1925,
"erad_clearance_half_life_min_range": [30.0, 60.0],
"steady_state_er_retained_orphan_hc_pool_at_t12_12h_molecules_per_cell_low_central_high": [
round((100000.0 * math.log(2.0) / (12.0 * 60.0) * 6.0) * 30.0 / math.log(2.0)),
round((200000.0 * math.log(2.0) / (12.0 * 60.0) * 10.0) * 60.0 / math.log(2.0)),
round((300000.0 * math.log(2.0) / (12.0 * 60.0) * 15.0) * 60.0 / math.log(2.0)),
],
"steady_state_er_retained_orphan_hc_pool_molecules_per_cell_range": [25000, 750000],
"central_er_retained_orphan_hc_pool_at_t12_60min_exact_formula_molecules_per_cell": round(
(200000.0 * math.log(2.0) / (12.0 * 60.0) * 10.0) * 60.0 / math.log(2.0)
),
"central_er_retained_orphan_hc_pool_at_t12_60min_molecules_per_cell": 200000,
"formula_reconciliation_note_kimi31_r4": (
"Exact steady-state mass-action formulas: F_synth = N_WT * (ln(2) / (t_1/2,WT * 60)) * I_IFN and S_ER,retained = F_synth * t_1/2,ERAD / ln(2) "
"= N_WT * I_IFN * (t_1/2,ERAD / (t_1/2,WT * 60)). At resting turnover t_1/2,WT = 12 h (720 min), [Low: N=100k, I=6x, t_ERAD=30 min], "
"[Central: N=200k, I=10x, t_ERAD=60 min], and [High: N=300k, I=15x, t_ERAD=60 min] give F_synth = [577.6, 1925.4, 4332.2] molecules/min "
"and S_ER,retained = [25,000, 166,667, 375,000] molecules/cell (whereas 200,000 is the rounded central reference and 8,664.3 molecules/min -> "
"750,000 molecules/cell corresponds to inflammatory accelerated MHC-I turnover t_1/2,WT = 6 h; AUDIT-REF)."
),
},
"blueprint_comparison": {
"Blueprint_A_and_X_B2M_null": {
"orphan_hc_loci_expressed": ["HLA-A", "HLA-B", "HLA-C"],
"relative_orphan_hc_flux_fraction": 1.0,
"total_er_mhc_folding_load_vs_b2m_null": 1.0,
"status": "B2M_NULL_ORPHAN_HC_ERAD_UNQUALIFIED",
},
"Design_B_prime_SCT_K4_B2M_null_HLA_A_B_WT_CIITA_SCT": {
"orphan_hc_loci_expressed": ["HLA-A", "HLA-B", "HLA-C"],
"relative_orphan_hc_flux_fraction": 1.0,
"total_er_mhc_folding_load_vs_b2m_null": 1.25,
"status": "K4_B_PRIME_SCT_RETAINS_FULL_ORPHAN_HC_FLUX_PLUS_CIITA_HLAC_SCT_LOAD_GATED_BY_0E_ER",
},
"Design_B_prime_SCT_B2M_null_HLA_A_B_null_CIITA_SCT": {
"orphan_hc_loci_expressed": ["HLA-C"],
"relative_orphan_hc_flux_fraction": 0.125,
"total_er_mhc_folding_load_vs_b2m_null": 0.375,
"status": "OPTIONAL_K6_HLA_A_B_KO_RESIDUAL_HLAC_ONLY_ORPHAN_HC_FLUX_85_TO_90PCT_REDUCED",
},
"Design_B_prime_endogenous_HLAC_retained_B2M_intact": {
"orphan_hc_loci_expressed": [],
"relative_orphan_hc_flux_fraction": 0.0,
"total_er_mhc_folding_load_vs_b2m_null": 0.20,
"status": "ZERO_ORPHAN_HC_FLUX_FREE_B2M_INTACT",
},
},
"cis_tethered_hlae_sct_cannot_chaperone_orphan_hc_in_trans_note_argon_r4": (
"Intramolecularly tethered HLA-E SCT (Arm 1A / Arm 1C) has its single B2M domain covalently linked 1:1 in cis to its own HLA-E heavy chain "
"(effective local concentration > 10 mM) and supplies zero free soluble B2M in trans to rescue endogenous orphan HLA-A/B/C heavy chains; "
"therefore, if Gate 0E-ER fails on B2M-/- clones, valid biological ERAD-reduction pivots are: (1) pair with TYK2 P1104A (which suppresses Type-I-IFN "
"HLA-A/B/C transcription by 80-90% in the iPSC-beta knockdown branch [0.10-0.20x] vs 0-20% in the primary human leukocyte WT-like branch [0.80-1.00x], while leaving IFN-gamma -> JAK1/JAK2 unattenuated [0.85-1.00x]), "
"(2) re-include X6 (RNLS-/-) to raise the beta-cell ER-stress apoptosis threshold, or "
"(3) apply NLRC5 promoter CRISPRoff methylation or HLA-A-/- HLA-B-/- debulking (which suppress/eliminate heavy-chain flux across both IFN-alpha and IFN-gamma; AUDIT-REF & AUDIT-REF)."
),
"stage0_gate_0e_er_pass_criteria": {
"ifng_100U_plus_tnfa_10ng_plus_16p7mM_glucose_48h": {
"sXBP1_over_uXBP1_ratio_vs_wt_max": 1.5,
"BiP_HSPA5_vs_wt_max": 1.3,
"CHOP_DDIT3_vs_wt_max": 1.2,
"secreted_proinsulin_to_insulin_molar_ratio_vs_wt_max": 1.25,
"post_stress_gsis_stimulation_index_min": 2.5,
},
"pivot_rule_S5": "If Gate 0E-ER fails on B2M-/- clones, apply NLRC5 CRISPRoff / K=6 HLA-A-/- HLA-B-/- ER debulking (covering both IFN-alpha and IFN-gamma), re-include X6 (RNLS-/-), or pair with TYK2 P1104A if Stage-0 confirms Type-I-IFN attenuation in human SC-beta cells.",
},
"four_mechanism_er_taxonomy_and_tyk2_p1104a_context_sensitivity_sol61_r4": {
"primary_citations": ["PMID:30578352", "PMID:42268925", "PMID:32719542", "PMID:39988068", "PMID:20160085", "PMID:38603470", "PMID:25140605"],
"mechanism_1_er_heavy_chain_source_elimination": "K=6 HLA-A-/- HLA-B-/- (plus HLA-C-/- in Plan A) physically eliminates orphan MHC-I heavy-chain polypeptide entry into the ER lumen, reducing orphan heavy-chain flux to 0.00x under both IFN-alpha and IFN-gamma.",
"mechanism_2_transcriptional_source_suppression": (
"NLRC5 promoter CRISPRoff silences the MHC-I enhanceosome across both Type I and Type II IFN; by contrast, TYK2 P1104A (rs34536443) selectively blunts Type-I-IFN/IL-12/IL-23 signaling while leaving IFN-gamma -> JAK1/JAK2 -> STAT1 -> IRF1 -> NLRC5 -> HLA-A/B/C transcription intact. "
"Moreover, in primary human P1104A/P1104A leukocytes, TYK2 P1104A completely impairs IL-23 and partially impairs IL-12 but retains WT-like cellular response to high-dose IFN-alpha/beta (Boisson-Dupuis et al. 2018 PMID:30578352; whereas Howard et al. 2026 PMID:42268925 is an engineered HEK293T VAMP-seq/signaling screen and Chandra et al. 2022 PMID:36289205 studied TYK2 KO and pharmacologic TYK2i in SC-islets rather than P1104A knock-in); "
"therefore our model tracks both the beta-cell-specific 80-90% IFN-alpha attenuation branch (modeled on TYK2i/KO in Chandra et al. 2022 PMID:36289205) and a conservative 0-20% IFN-alpha attenuation sensitivity branch (0.80-1.00x relative to WT, anchored to primary human P1104A leukocytes in Boisson-Dupuis et al. 2018 PMID:30578352) until resolved by the Stage-0 isogenic TYK2 P1104A satellite."
),
"mechanism_3_erad_retrotranslocation_and_proteasomal_disposal": "Endogenous HRD1/SEL1L/Derlin-1 ubiquitin-proteasome ERAD capacity clears misfolded B2M-free heavy chains up to the saturable beta-cell threshold alongside proinsulin and IAPP folding demand.",
"mechanism_4_downstream_er_stress_apoptosis_tolerance_and_iapp_challenger": (
"RNLS-/- raises the downstream CHOP/TXNIP apoptotic threshold against thapsigargin and cytokine stress without reducing physical heavy-chain entry into the ER lumen (Cai et al. 2020 PMID:32719542; MacDonald et al. 2025 PMID:39988068), "
"whereas the RNLS-WT non-amyloidogenic IAPP(A25P/S28P/S29P) prime-edit challenger (ER_IAPP_PRAMLINTIDE_RNLS_WT) eliminates toxic human IAPP20-29 beta-sheet oligomers directly at the source while preserving wild-type RNLS metabolic fitness (Potter et al. 2010 PMID:20160085; Thorngren et al. 2024 PMID:38603470; Wang et al. 2014 PMID:25140605; AUDIT-REF, AUDIT-REF & AUDIT-REF)."
),