# PX1 malaria susceptibility reanalysis

This folder contains a local, rerunnable partial reproduction of the published PX1/PIN ex-vivo susceptibility comparisons. It does not need Cathedral, Supabase, Inngest, Modal, or credentials.

The public Cathedral research case study is `/challenges/001-antimalarial-resistance`. Its page is repo-backed and the build copies an allowlisted set of aggregate outputs and reproducibility files to `apps/web/public/case-studies/px1-malaria/`. Raw source workbooks and the local `.cache/` are never copied. The comparison and unsent author-data request are `comparison-to-original.md` and `author-data-request.md`.

## Result classification

**Original experiment partially reproduced.** The released article source workbook supports a reanalysis of PIN versus LMD phenotype measurements and the K13-wild-type stratum. Results agree in direction with the paper for dihydroartemisinin (DHA), lumefantrine, and mefloquine; the RSA comparison is not significant. The exact 465-sample, depth-qualified cohort and mixed-effects model were not reproduced. The released workbook has no numeric per-sample depth and does not include the COI covariate table required by the paper's adjusted model.

## Run locally

Requires Node.js 20+ and the repository dependency `fflate` (already present in the Cathedral web workspace).

```powershell
node experiments/malaria-resistance/scripts/fetch-sources.mjs
node experiments/malaria-resistance/scripts/analyze.mjs
node --test experiments/malaria-resistance/tests/analyze.test.mjs
```

The fetch step downloads only the two small, explicitly listed public XLSX files into `.cache/`, enforces a 2 MB per-file limit, checks the XLSX signature, and prints SHA-256 checksums. `.cache/` is ignored. The analysis writes aggregate results only; sample identifiers and raw rows are not emitted.

If dependencies are not available from the monorepo, install `fflate` in a temporary Node project or use the notebook in `notebooks/px1_malaria_reanalysis.ipynb` in Google Colab. The notebook fetches the same public source files and uses pandas/SciPy; it has not been executed in Colab from this environment.

## Files

- `scripts/fetch-sources.mjs` — bounded public source download and checksum output.
- `scripts/analyze.mjs` — XLSX parsing, schema and identifier checks, filters, descriptive summaries, rank-sum tests, bootstrap intervals, BH adjustment, CSV/JSON/SVG output.
- `notebooks/px1_malaria_reanalysis.ipynb` — Colab-ready equivalent analysis.
- `tests/analyze.test.mjs` — fixtures for validation, filtering, marker mapping, missingness, finite inference, deterministic output, and partial-run classification.
- `data_manifest.json` — source citations, retrieval details, checksums, and reuse notes.
- `results/report.md` — human-readable report.
- `results/summary.json` — machine-readable, importable compact result.
- `results/phenotype-comparisons.csv` and `results/core-phenotype-contrast.svg` — result table and figure.

## Scope and scientific interpretation

PX1 is the phosphoinositide-binding protein locus `PF3D7_0720700`. PIN is the multi-variant haplotype described in the target article; it is not a WHO-classified resistance marker. WHO's compendium classifies the listed K13 C469Y and A675V alterations as validated markers. This analysis uses the published source-data labels for PX1 and does not independently call the complete haplotype from sequence reads.

The comparisons are observational and do not establish that PX1 causes resistance or predicts treatment failure. Ex-vivo IC50 values and RSA survival are laboratory phenotypes, not clinical treatment outcomes. The underlying article states CC BY-NC-ND terms; verify dataset-specific and commercial reuse rights before redistribution. Raw source files are intentionally excluded from version control.

## Exact inputs still needed for full reproduction

1. The sample-matched numeric read-depth/call evidence used to apply the paper's `>=25x` and major allele `>=90%` criteria.
2. `COI_calls_all_uganda_samples.csv` or an authoritative, legally usable equivalent with exact sample identifiers and values.
3. The exact phenotype/parasitemia source versions and stable join keys for all 465 article-analysis samples.
4. The authors' full run environment and complete analysis scripts/data snapshots sufficient to reconstruct the model's cohort, covariates, contrasts, and model diagnostics.

No synthetic sample IDs or phenotype values are generated to fill those gaps.
