OpenIslet

scripts/run_layer5_personalized_patient_compiler.py

Layer 5: Personalized Patient-DNA & Multiplex CRISPR Compiler + 10,000-Patient Global Population Simulator (v0.8.0)

script Release v0.8.0 gen-eb955f8266035aba 494 KB · 31 sections

Use this file in any AI chat (paste-only or attachment-capable):

Download as text (.txt) Download section (.txt)

Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/run_layer5_personalized_patient_compiler.py · SHA-256: 0b285369ac6e4409…

                        if _is_default_compiler
                        else pers_disc_4
                    ),
                }
                for tau_kir in (0.42, 0.45, 0.48, 0.52)
            ],
            "physical_uncloned_yield_prior": None,
            "physical_yield_evidence_status": "NOT_MEASURED",
            "donor_seedline_tyk2_genotype_sensitivity_summary": donor_tyk2_sensitivity_summary,
            "b_prime_4digit_hlac_alloreactivity_and_b_prime_sct_pivot_audit_muse_r3": {
                "audit_id": "AUDIT-REF",
                "evidence_class": "IMMUNOGENETIC_ALLOREACTIVITY_AUDIT_AND_PRODUCT_PROMOTION",
                "active_plan_b_routed_patients_of_10000": total_plan_b_routed,
                "three_line_kir_subbank_4digit_mismatch_fraction_range": [0.70, 0.85],
                "homozygous_4digit_hlac_lines_for_85_to_90pct_self_match": [12, 16],
                "hlac_4digit_relation_penalty_model": {
                    "SELF_4DIGIT_MATCH_or_crossmatch_cleared_B_PRIME_SCT_penalty": 0.0,
                    "KIR_MATCH_FOREIGN_4DIGIT_ALLO_endogenous_hlac_penalty": -0.25,
                    "KIR_MATCH_FOREIGN_4DIGIT_ALLO_uncrossmatched_b_prime_sct_penalty": -0.08,
                    "recipient_anti_hla_c_dsa_penalty_all_hlac_grafts": -0.40,
                    "recipient_activating_kir2ds1_unlicensed_c2_sct_penalty": -0.12,
                },
                "population_10k_plan_b_if_80pct_foreign_4digit_allo_unpenalized_survival_pct": round(
                    pers_mean_4 - 100.0 * 0.80 * 0.25 * plan_b_routed_frac, 4
                ),
                "population_10k_b_prime_sct_k4_b0_2pass_survival_pct": pers_mean_4,
                "population_10k_b_prime_sct_k4_complexity_discounted_utility_pct": b_prime_sct_disc_4,
                "b_prime_sct_complexity_discounted_gain_over_k5_endogenous_hlac_pp": b_prime_sct_gain_over_k5_pp,
                "b_prime_sct_complexity_discounted_gain_over_standardized_plan_a_pp": b_prime_sct_gain_over_std_a_pp,
                "hazard_active_cohort_sensitivity_audit_sonnet55_r4": {
                    "audit_id": "AUDIT-REF",
                    "baseline_97p50_conditioning_scope": (
                        f"The {pers_mean_4:.2f}% ({pers_disc_4:.2f}% K=5 [{pers_disc_4:.4f}%] / {b_prime_sct_disc_4:.2f}% K=4 [{b_prime_sct_disc_4:.4f}%] complexity-discounted) personalized headline is conditioned on "
                        "post-clearance grafts (all donor-panel Gate 0A NKG2C+, recipient serum CDC/ADCC crossmatch, and recipient "
                        "CD8+ MLC non-reactivity holds cleared; AUDIT-REF [DEC-076]). Prior to crossmatch/MLC/Gate-0A clearance, sampling realistic "
                        "recipient allorecognition and CMV adaptive-NK hazards yields the pre-clearance cohort sensitivity below."
                    ),
                    "plan_b_routed_fraction_of_10000_cohort": round(plan_b_routed_frac, 4),
                    "three_line_kir_subbank_foreign_4digit_hlac_exposure_range": [0.792, 0.902],
                    "endogenous_hlac_k5_with_79p2_to_90p2pct_foreign_4digit_allo_unpenalized_survival_pct_range": [
                        round(pers_mean_4 - 100.0 * 0.902 * 0.25 * plan_b_routed_frac, 4),
                        round(pers_mean_4 - 100.0 * 0.792 * 0.25 * plan_b_routed_frac, 4),
                    ],
                    "endogenous_hlac_k5_with_79p2_to_90p2pct_foreign_4digit_allo_gain_vs_plan_a_92p50_pp_range": [
                        round((pers_mean_4 - 100.0 * 0.902 * 0.25 * plan_b_routed_frac) - std_mean_4, 4),
                        round((pers_mean_4 - 100.0 * 0.792 * 0.25 * plan_b_routed_frac) - std_mean_4, 4),
                    ],
                    "endogenous_hlac_k5_with_79p2_to_90p2pct_foreign_4digit_allo_kb_discounted_utility_pct_range": [
                        round(pers_disc_4 - 100.0 * 0.902 * 0.25 * plan_b_routed_frac * math.exp(-float(engineering_parameters["lambda_K"])), 4),
                        round(pers_disc_4 - 100.0 * 0.792 * 0.25 * plan_b_routed_frac * math.exp(-float(engineering_parameters["lambda_K"])), 4),
                    ],
                    "endogenous_hlac_k5_with_79p2_to_90p2pct_foreign_4digit_allo_kb_discounted_delta_vs_plan_a_pp_range": [
                        round(
                            (pers_disc_4 - 100.0 * 0.902 * 0.25 * plan_b_routed_frac * math.exp(-float(engineering_parameters["lambda_K"])))
                            - std_mean_4 * standard_discount,
                            4,
                        ),
                        round(
                            (pers_disc_4 - 100.0 * 0.792 * 0.25 * plan_b_routed_frac * math.exp(-float(engineering_parameters["lambda_K"])))
                            - std_mean_4 * standard_discount,
                            4,
                        ),
                    ],
                    "b_prime_sct_k4_pre_mlc_clearance_with_foreign_4digit_and_c2_qyddavykl_survival_pct_range": [
                        round(pers_mean_4 - 100.0 * 0.08 * plan_b_routed_frac, 4),
                        round(pers_mean_4 - 100.0 * 0.792 * 0.08 * plan_b_routed_frac, 4),
                    ],
                    "post_clearance_b_prime_sct_k4_survival_pct": pers_mean_4,
                    "post_clearance_b_prime_sct_k4_kb_discounted_utility_pct": b_prime_sct_disc_4,
                    "population_simulation_with_cmv_nkg2c_and_sensitization_sonnet55_r5": {
                        "finding_ids": ["AUDIT-REF", "AUDIT-REF", "AUDIT-REF", "AUDIT-REF", "MW-R5-S2-4p3", "AUDIT-REF"],
                        "model_epistemic_scope": "ILLUSTRATIVE_ASSIGNED_PENALTY_COMPETING_RISKS_SENSITIVITY_MODEL",
                        "ancestry_cmv_high_nkg2c_adaptive_nk_prevalence_range": [0.22, 0.38],
                        "mean_cohort_cmv_high_nkg2c_adaptive_nk_prevalence": 0.30,
                        "sensitized_cpra_ge_80_prevalence": 0.08,
                        "moderate_kir_nk_0p30_to_0p48_cohort_fraction": 0.625,
                        "four_hazard_competing_risks_decomposition_from_100pct": {
                            "h1_baseline_allo_autoimmune_residual_hazard": 0.025,
                            "h2_unrouted_moderate_kir_and_sirpa_low_nk_hazard": 0.04425,
                            "h3_cmv_high_nkg2c_adaptive_nk_hazard": 0.036,
                            "h4_non_hla_and_sct_sensitized_cpra_and_stress_hazard": 0.037175,
                            "total_4hazard_additive_sum": 0.142425,
                            "pre_clearance_unscreened_4hazard_additive_survival_pct": 85.7575,
                            "pre_clearance_independent_competing_risks_multiplicative_survival_pct_from_100": round(
                                100.0 * (1.0 - 0.025) * (1.0 - 0.04425) * (1.0 - 0.036) * (1.0 - 0.037175),
                                4,
                            ),
                        },
                        "hazard_term_breakdown_from_97p5pct_baseline": {
                            "cmv_high_nkg2c_adaptive_nk_term": round(0.30 * 0.12, 6),
                            "sensitized_cpra_ge_80_term": round(0.08 * 0.25, 6),
                            "moderate_kir_sirpa_low_nk_term": round(0.625 * 0.35 * 0.14, 6),
                            "residual_allo_autoimmune_stress_term": round(0.22 * 0.14, 6),
                        },
                        "pre_clearance_unscreened_cohort_mean_survival_pct": round(
                            pers_mean_4
                            - 100.0 * (0.30 * 0.12 + 0.08 * 0.25 + 0.625 * 0.35 * 0.14 + 0.22 * 0.14),
                            4,
                        ),
                        "pre_clearance_independent_competing_risks_multiplicative_survival_pct": round(
                            97.4612
                            * (1.0 - 0.30 * 0.12)
                            * (1.0 - 0.08 * 0.25)
                            * (1.0 - 0.625 * 0.35 * 0.14)
                            * (1.0 - 0.22 * 0.14),
                            4,
                        ),
                        "pre_clearance_4hazard_from_100pct_multiplicative_survival_pct": round(
                            100.0 * (1.0 - 0.025) * (1.0 - 0.04425) * (1.0 - 0.036) * (1.0 - 0.037175),
                            4,
                        ),
                        "competing_risks_baseline_provenance_reconciliation_muse_r6": {
                            "from_100pct_4hazard_multiplicative_survival_pct": 86.4915,
                            "from_97p4612pct_pers_mean_4_multiplicative_survival_pct": 86.5048,
                            "from_live_pers_mean_4_97p4963pct_multiplicative_survival_pct": round(
                                pers_mean_4
                                * (1.0 - 0.30 * 0.12)
                                * (1.0 - 0.08 * 0.25)
                                * (1.0 - 0.625 * 0.35 * 0.14)
                                * (1.0 - 0.22 * 0.14),
                                4,
                            ),
                            "from_97p4612pct_4hazard_additive_survival_pct": 85.7575,
                            "from_100pct_4hazard_additive_survival_pct_reference": round(
                                100.0 - 100.0 * (0.025 + 0.04425 + 0.036 + 0.037175), 4
                            ),
                            "from_97p4612pct_exact_additive_subtraction_survival_pct": round(
                                97.4612 - 100.0 * (0.30 * 0.12 + 0.08 * 0.25 + 0.625 * 0.35 * 0.14 + 0.22 * 0.14), 4
                            ),
                            "from_live_pers_mean_4_97p4963pct_exact_additive_subtraction_survival_pct": round(
                                pers_mean_4 - 100.0 * (0.30 * 0.12 + 0.08 * 0.25 + 0.625 * 0.35 * 0.14 + 0.22 * 0.14), 4
                            ),
                            "note": (
                                "Reconciles the two baseline references: 97.4612% is the pre-DEC-048 historical cohort mean (yielding 86.5048% multiplicative and 85.7187% additive; "
                                "85.7575% in from_97p4612pct_4hazard_additive_survival_pct is the 100% - 14.2425% = 85.7575% 4-hazard additive reference retained for backward compatibility), "
                                "whereas live pers_mean_4 = 97.4963% yields 86.5359% multiplicative and 85.7538% additive (M1 [DEC-077])."
                            ),
                        },
                        "post_gate0_and_crossmatch_clearance_modular_3to4x100cm2_cassette_mean_survival_pct": pers_mean_4,
                        "post_gate0_and_crossmatch_clearance_modular_3x100cm2_cassette_mean_survival_pct": pers_mean_4,
                        "single_200cm2_pouch_unscaled_chronic_1500_ieq_cm2_violation_mean_survival_pct": round(
                            pers_mean_4 - 100.0 * 0.38 * ((2500.0 - 1500.0) / 1000.0), 4
                        ),
                        "clinical_interpretation": (
                            "Illustrative assigned-penalty competing-risks sensitivity model: without Stage-0 Gate 0A NKG2C+/SIRPa-low NK clearance, "
                            "Gate 0D 50-serum non-HLA/SCT flow crossmatch, and modular 3-4 x 100 cm^2 omental cassette area scaling (<= 1,500 IEQ/cm^2), "
                            "unscreened cohort survival drops from 97.50% to 85.76% (85.7575% under additive 4-hazard sum h1+h2+h3+h4 = 0.142425; "
                            "86.5048% under 97.50%-baseline 4-term multiplicative competing risks and 86.4915% under 100%-baseline 4-hazard multiplicative competing risks "
                            "100% * (1-0.025)*(1-0.04425)*(1-0.036)*(1-0.037175)) or "
                            f"{round(pers_mean_4 - 100.0 * 0.38 * ((2500.0 - 1500.0) / 1000.0), 2)}% (single-pouch anoxic overload), confirming why both recipient screening gates and modular 3-4 x 100 cm^2 cassette scaling are mandatory."
                        ),
                    },
                },
                "canonical_track2_kir_subbank_products": [
                    "ISLET1_B_SCT_C1_CIITA",
                    "ISLET1_B_SCT_C2_CIITA",
                    "ISLET1_B_SCT_C1C2_CIITA",
                    "ISLET1_B_SCT_C1_CIITA_TYK2_PE",
                    "ISLET1_B_SCT_C2_CIITA_TYK2_PE",
                    "ISLET1_B_SCT_C1C2_CIITA_TYK2_PE",
                ],
                "endogenous_hlac_retention_product_demotion": {
                    "product_variant_ids": ["ISLET1_B2_5LOCUS_BASE", "ISLET1_B2_5LOCUS_TYK2_PE"],
                    "status": "EXPLORATORY_REQUIRES_4DIGIT_BANK",
                    "reason": (
                        "Retaining endogenous polymorphic HLA-C + WT B2M with only a 3-line KIR-ligand-group bank (C1/C1, C2/C2, C1/C2) "
                        "leaves ~70-85% of recipients 4-digit mismatched at HLA-C, re-arming direct CD8+ T-cell allorecognition and "
                        "anti-HLA-C DSA (Xu et al. 2019 PMID:30853558; Tran et al. 2011 PMID:21743387) while requiring 3-pass "
                        "clonal editing to avoid the 1.41 Mb chr6p21.3 HLA-A-to-HLA-B cis-deletion. Design B'-SCT "
                        "(ISLET1_B_SCT_C1_CIITA [GAVDPLLAL, PDB:1EFX] / ISLET1_B_SCT_C2_CIITA [QYDDAVYKL, PDB:1IM9] at CIITA Exon 5) retains B2M-/- at Locus 1 and expresses a "
                        "covalently tethered human self-peptide single-chain trimer at K=4, B=0 (P_passes=2) or B=1 (P_passes=3)."
                    ),
                },
                "donor_bank_antigen_hygiene_and_indirect_tolerance_window_muse_r6": {
                    "finding_ids": ["MW-R6-S1-19", "MW-R6-S1-20", "MW-R6-S1-21"],
                    "mcb_donor_genetic_and_serological_hygiene_criteria": {
                        "donor_sex_karyotype_required": "46,XX_FEMALE_H_Y_NULL",
                        "abo_secretor_genotype_required": "BLOOD_GROUP_O_FUT2_NON_SECRETOR_PREFERRED",
                        "viral_serology_required": "CMV_NEG_EBV_NEG_HHV6_NEG_PARVOB19_NEG",
                        "mitochondrial_haplogroup_and_common_mhc_polymorphism_screened": True,
                        "rationale": "Eliminates H-Y (UTY/DBY/SMCY) minor histocompatibility antigens in female recipients, A/B glycocalyx neoantigens, and donor-derived latent herpesvirus reactivation (MW-R6-S1-19).",
                    },
                    "two_independent_mcb_clone_diversification_and_functional_nutlin3a_p53_gate_muse_r6": {
                        "finding_id": "MW-R6-S1-20",
                        "min_independent_mcb_clones_from_distinct_46xx_o_neg_donors": 2,
                        "functional_p53_nutlin3a_assay_endpoint": "obs_nutlin3a_p21_mdm2_fold_induction",
                        "min_nutlin3a_10uM_8h_p21_cdkn1a_and_mdm2_fold_induction": 5.0,
                        "post_stress_20q11_bcl2l1_outgrowth_endpoint": "obs_post_stress_20q11_bcl2l1_outgrowth_fold",
                        "max_post_stress_20q11_bcl2l1_outgrowth_fold": 1.0,
                        "max_post_stress_20q11_bcl2l1_outgrowth_upper95_fold": 1.20,
                    },
                    "peri_operative_14day_damp_inflammation_and_indirect_pathway_bridging_option": {
                        "finding_id": "MW-R6-S1-21",
                        "surgical_implantation_damp_window_days": 14,
                        "recipient_dc_pinocytosis_of_shed_donor_debris_pathway": "Indirect CD4+ T-cell priming on recipient HLA-DR3/DR4-DQ8 APCs during surgical trauma + early hypoxic attrition",
                        "high_risk_z_ge_2p0_optional_local_or_transient_bridging": "Recipient-stratified transient 14-day peri-implantation anti-inflammatory/co-stimulatory blockade or hydrogel-tethered local anti-TNFa/IL-1Ra scavenging during capsule maturation",
                    },
                },
                "patient_safety_viral_outgrowth_p53_and_kir3dl1_gates_muse_r6": {
                    "finding_ids": ["MW-R6-S1-19", "MW-R6-S1-20", "MW-R6-S1-21"],
                    "track3_bw4_kir3dl1_hold_token": "HOLD_RECIPIENT_BW4_KIR3DL1_EDUCATED_NK_REQUIRES_SORTED_KIR3DL1_NK_CLEARANCE",
                    "functional_p53_nutlin3a_assay_endpoint": "obs_nutlin3a_p21_mdm2_fold_induction",
                    "min_nutlin3a_10uM_8h_p21_cdkn1a_and_mdm2_fold_induction": 5.0,
                    "post_stress_20q11_bcl2l1_outgrowth_endpoint": "obs_post_stress_20q11_bcl2l1_outgrowth_fold",
                    "max_post_stress_20q11_bcl2l1_outgrowth_fold": 1.0,
                    "max_post_stress_20q11_bcl2l1_outgrowth_upper95_fold": 1.20,
                    "viral_day14_log10_reduction_endpoint": "obs_gate0v_cvb_day14_log10_viral_reduction",
                    "min_viral_day14_log10_reduction": 3.0,
                    "viral_day28_persistent_vp1_ie1_endpoint": "obs_gate0v_day28_persistent_vp1_ie1_positive_cell_pct",
                    "max_viral_day28_persistent_vp1_ie1_upper95_pct": 0.05,
                },
            },
            "hour0_kinetic_race_and_basal_floor_audit_muse_r3": {
                "audit_id": "AUDIT-REF",
                "evidence_class": "KINETIC_RACE_HAZARD_PRIOR_AND_BASAL_FLOOR_CHALLENGER",
                "innate_nk_and_memory_ctl_degranulation_window_hours": [0.5, 4.0],
                "cxcl10_inducible_serpinb9_pdl1_accumulation_lag_hours": [4.0, 6.0],
                "basal_floor_challenger_product_variant_id": "ISLET1_A4_L3_BFB_BASALFLOOR",
                "basal_floor_challenger_constructs": ["L3-BF-B (4,078 bp)", "L3-BF-C (4,160 bp)"],
                "stage0_kill_gate": "Gate 0B (Hour-0 to Hour-12 real-time primary human NK + memory CD8+ CTL live-imaging kill race; S1 -> S2 precedence)",
            },
            "scope_reconciliation_note": (
                f"Illustrative assigned-rule outcomes, conditional on hypothetical release-qualified clones: standardized Plan A "
                f"{analytic_standard_pct:.4f}% and personalized {analytic_personalized_pct:.4f}% (whereas if Plan B's unmaterialized "
                f"CD47/HLA-E safe-harbor cassette is treated as absent, analytic personalized survival drops by {pers_mean_4 - unmat_b_mean_pct:.4f} pp to {unmat_b_mean_pct:.4f}% "
                f"[{unmat_b_disc_pct:.4f}% after patient-level complexity discount, {unmat_b_disc_pct - pers_disc_4:.4f} pp below complexity-discounted Plan B-prime {pers_disc_4:.4f}% and {unmat_b_mean_pct - std_mean_4:.4f} pp unpenalized / "