oadr_cpep.oadr_data module

Shared data loaders for OADR autoantibody work — ported from the oadr-autoantibody repo (src/oadr_data.py) so oadr-cpep builds Panel A / Panel B exactly the same way.

Change from the source: instead of finding files by name under a data root, every loader takes the explicit file paths it needs — nothing is guessed. The CLI hands each command its precise input files; this module reads them and parses.

Two feature panels:

Panel A (legacy, 9 features): MIAA, GAD65, IA2IC, ICA, ZNT8, 8-12, 13-17, >18, Sex. Studies: SDY524, SDY569, SDY797, SDY1737. Files: SDY<n>_tidy.csv (features), SDY<n>_cpeptide_auc_tidy.csv (target).

Panel B (extended): Sex, age_years, disease_duration_years, bmi, height_cm, weight_kg, GAD65, IA2IC, MIAA, ZNT8, ICA, received_active_treatment. Studies: SDY524, SDY569, SDY1737 only (no extended data for SDY797). Files: aa_<n>.csv, demo_<n>.csv, SDY<n>_cpeptide_auc_tidy.csv, SDY<n>_arm_or_cohort.txt, SDY<n>_arm_2_subject.txt (arms optional).

Target for both: log(C_Peptide_AUC_4Hrs) = log_auc.

oadr_cpep.oadr_data.load_panel_a(study, tidy_path, cpeptide_path) pandas.DataFrame[source]

Build the 9-feature panel for one study from its explicit files.

Returns a DataFrame with columns:

Subject_ID, Study, <PANEL_A_FEATURES>, C_Peptide_AUC_4Hrs, log_auc

Antibodies absent from the study are filled with 0.0.

oadr_cpep.oadr_data.load_panel_b(study, aa_path, demo_path, cpeptide_path, arms_path=None, arm_subjects_path=None) pandas.DataFrame[source]

Build the extended feature panel for one study from its explicit files.

Columns returned:

Subject_ID, Study, Sex, age_years, disease_duration_years, bmi, height_cm, weight_kg, race, ethnicity, cohort_group, received_active_treatment, <autoantibodies>, ICA (0 if unmeasured), C_Peptide_AUC_4Hrs, log_auc.

oadr_cpep.oadr_data.panel_b_design_matrix(df: pandas.DataFrame)[source]

Turn a Panel B frame into (X, y, feature_names) with categoricals one-hot encoded.

cohort_group is dropped (study-specific arm codes / age bins, not comparable); race and ethnicity are one-hot encoded.

oadr_cpep.oadr_data.panel_a_design_matrix(df: pandas.DataFrame)[source]

Return (X, y, feature_names) for Panel A — features are already numeric.

oadr_cpep.oadr_data.load_features(study, panel, *, tidy=None, aa=None, demo=None, cpeptide=None, arms=None, arm_subjects=None)[source]

Return (frame, feature_names, target) for one study + panel from explicit file paths, with the same within-study cleanup the notebooks apply. frame has the feature columns plus the log_auc target (and Subject_ID). Panel A -> 9 legacy features (needs tidy + cpeptide); Panel B -> the canonical 12 extended features (needs aa + demo + cpeptide; arms + arm_subjects optional).