Archive 4 checkpoints (1-4)
Browse files- paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/README.md +93 -0
- paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/analysis/benchmark/imperial_eskd/AGGREGATE.md +26 -0
- paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/share/README.md +102 -0
- paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/tools/split_conditions.py +79 -0
paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LoRA-5 at K = 4,000: bulk-only cells for Ye 2026 sepsis and Imperial ESKD COVID (2026-10-06)
|
| 2 |
+
|
| 3 |
+
**Request (user, 2026-10-06).** After the K = 1,000 version (`plans/bulkonly_lora5_20261006`), retrain the LoRA-5
|
| 4 |
+
models at K = 4,000. Then generate 4,000 cells per bulk-only sample and share them through R2 links, like the first
|
| 5 |
+
version.
|
| 6 |
+
|
| 7 |
+
K is the recipe size of the real-bulk condition, not a cell number. The condition is
|
| 8 |
+
`CPM(bulk) / 1e6 × K × DEPTH_ANCHOR` with `recipe_k = K`. In Behçet, LoRA-3 at K = 4,000 strengthened the group
|
| 9 |
+
direction (`behcet_c1q_lora3_20261004`, follow-up 1).
|
| 10 |
+
|
| 11 |
+
## Design
|
| 12 |
+
|
| 13 |
+
Only K changes relative to the K = 1,000 version, plus three deliberate differences listed at the end.
|
| 14 |
+
|
| 15 |
+
- **Conditions** (`tools/build_k_conditions.py` → `data/<ds>/`).
|
| 16 |
+
- The benchmark arithmetic with `RECIPE_K` replaced by 4,000.
|
| 17 |
+
- Each set is first rebuilt at K = 1,000 and checked byte for byte against the file it comes from (all 12 checks
|
| 18 |
+
passed, `data/<ds>/K_BUILD.json`):
|
| 19 |
+
- `conditions_raw_fixed_K4000.npz`: every paired row, for training;
|
| 20 |
+
- `paired_test/draw<j>_test_raw_K4000.npz`: each draw's paired test rows, 1,500 cells per sample as in the
|
| 21 |
+
benchmark;
|
| 22 |
+
- `bulkonly_raw_K4000.npz`: the 122 / 164 bulk-only samples, 4,000 cells per sample.
|
| 23 |
+
- **Models** (`runs/<ds>/draw<j>/lora_k4000/`).
|
| 24 |
+
- LoRA r16 on the same five few-pair draws: the same 5 training donors (`fewshot_n5/draw<j>/train_donors.txt`) and
|
| 25 |
+
the LoRA-5 protocol (`ft_sdd.py --mode lora --lr 5e-4 --fixed-steps 3000`, seed 20260927).
|
| 26 |
+
- Trained on the K = 4,000 training condition.
|
| 27 |
+
- **Generation** (`tools/make_queue.py`, `tools/gpu_draw.sh`, `tools/run_gpu.sh`; unit `bulkonly-k4000-gpu-s1`).
|
| 28 |
+
- The benchmark's sampler flags: EMA, DDIM 50, Bernoulli read-out, threshold 0, batch 256.
|
| 29 |
+
- Each set is generated in row parts of at most 100,000 cells (`tools/split_conditions.py`).
|
| 30 |
+
- The sampler peaks at about 0.30 GiB per 1,000 cells: 17.6 GiB for 58,500 cells, 29.2 GiB for 100,000.
|
| 31 |
+
- Each part is seeded `base + first row × 10,000,019`, so every cell has the seed it would have in an unsplit
|
| 32 |
+
file.
|
| 33 |
+
- One `ml-run` step per draw (training, then every part) holds the shared GPU lock. The scSemiProfiler queue gets
|
| 34 |
+
the GPU between draws.
|
| 35 |
+
- Before each process the step waits for the thermal gate and `MemAvailable ≥ 32 GiB + 0.45 GiB per 1,000 cells`.
|
| 36 |
+
- Sizes:
|
| 37 |
+
- sepsis: 115,500 paired-test + 488,000 bulk-only cells per draw;
|
| 38 |
+
- Imperial: 213,000–217,500 + 656,000 per draw.
|
| 39 |
+
- **Paired benchmark** (`tools/merge_paired.py`, `tools/score_paired.sh`, `tools/aggregate_k4000.py` →
|
| 40 |
+
`analysis/benchmark/<ds>/`).
|
| 41 |
+
- Each draw's paired-test parts are merged into one NPZ. Both arms are scored in one call of the benchmark's own
|
| 42 |
+
scorer (`score_ft.py`), on the draw's test donors with the cohort's contrast:
|
| 43 |
+
- `lora5`: the benchmark's K = 1,000 cells. Imperial's are copied from spark-0110, sha-checked and removed after
|
| 44 |
+
scoring.
|
| 45 |
+
- `lora5_k4000`: this plan's cells.
|
| 46 |
+
- The re-scored K = 1,000 arm must equal the benchmark's stored draw scores. Draw 0 of sepsis: 25 metrics, max
|
| 47 |
+
difference 0.
|
| 48 |
+
- **Labels, calibration, sharing.**
|
| 49 |
+
- `tools/extract_paired.py`, `tools/annotate_bulkonly.py` and `tools/features.py` work as in the K = 1,000 version.
|
| 50 |
+
- `tools/package_share.py` writes `share/<ds>/lora5k4_bulkonly_<ds>_draw<j>.h5ad`.
|
| 51 |
+
- `tools/run_cpu.sh` (unit `bulkonly-k4000-cpu`) runs the CPU chain for each draw as soon as its GPU step is
|
| 52 |
+
complete.
|
| 53 |
+
- Sharing uses the first plan's `tools/share_r2.sh` with `PLAN=` this plan and `RAW=0`.
|
| 54 |
+
- The raw NPZs (about 160 GB) are not uploaded. Their sha256 is in each receipt, and they stay on this host.
|
| 55 |
+
|
| 56 |
+
**Deliberate differences from the K = 1,000 version** (both from its completeness review):
|
| 57 |
+
|
| 58 |
+
1. **Independent draws.** Draw j uses base seed `20260927 + j × 1,000,003`; draw 0 keeps 20260927.
|
| 59 |
+
- In the K = 1,000 version every draw used 20260927, so cell slot c of sample i shared its noise across the five
|
| 60 |
+
draws.
|
| 61 |
+
- No noise or support seed is shared between draws, checked over all 2.44 M sepsis and 3.28 M Imperial bulk-only
|
| 62 |
+
cells.
|
| 63 |
+
2. **Per-draw read-out seed.** The bulk-only read-out is one Poisson draw over the whole set (all parts in row order,
|
| 64 |
+
one generator; `common.poisson_over_parts`, identical to `poisson_integerise` of the unsplit matrix), with seed
|
| 65 |
+
`20260916 + draw`.
|
| 66 |
+
- Paired-test sets keep 20260916, because the benchmark scorer reads them.
|
| 67 |
+
3. **More cells and a larger K.** 4,000 cells per bulk-only sample instead of 1,500 (user request), and K = 4,000
|
| 68 |
+
instead of 1,000.
|
| 69 |
+
|
| 70 |
+
## Status (2026-10-06, complete)
|
| 71 |
+
|
| 72 |
+
- **Generation: all 10 draws, 11:13.**
|
| 73 |
+
- Sepsis 5 and Imperial 0–1 ran on server_1.
|
| 74 |
+
- Imperial 2–4 ran on server_2, after its root-owned vLLM stopped, using stub queue files and `tools/fetch_s2.sh`.
|
| 75 |
+
Every fetched NPZ's sha equals its receipt. The stubs are kept as `queues/*.stub_record`, and the full queues
|
| 76 |
+
are restored.
|
| 77 |
+
- **CPU chain:** 0 failures, 11:39.
|
| 78 |
+
- Every bulk-only set labelled and packaged: sepsis 488,000 and Imperial 656,000 cells per draw.
|
| 79 |
+
- `share/`: 13 files, 3.49 GB.
|
| 80 |
+
- **Checkpoints.** All 10 LoRA checkpoints are on spark-0110 at the same paths (sha = RUN.json). The server_1
|
| 81 |
+
copies were deleted after the check (`checkpoint_ft.pt.moved`).
|
| 82 |
+
- **Benchmark** (`analysis/benchmark/<ds>/AGGREGATE.md`). The re-scored K = 1,000 arm equals the stored benchmark
|
| 83 |
+
exactly, in all 25 metrics of every draw.
|
| 84 |
+
- Composition L1: sepsis 0.466 → 0.445 (4/5 draws, donor-draw Wilcoxon p 0.005); Imperial 0.503 → 0.487 (5/5,
|
| 85 |
+
p 2e-5).
|
| 86 |
+
- Case-vs-control logFC r: sepsis 0.350 → 0.327; Imperial 0.749 → 0.748.
|
| 87 |
+
- Top-50 DEG overlap: sepsis 16.4 → 17.8; Imperial 113.6 → 115.8.
|
| 88 |
+
- **Calibration** (`analysis/compare_k1000/<ds>/SUMMARY.md`; feature × draw pairs out of 250).
|
| 89 |
+
- Sepsis: level ok 100 → 107; sepsis vs HC contrast 73 → 83; sepsis vs ICU contrast 57 → 66.
|
| 90 |
+
- Imperial: level ok 111 → 110; COVID+ vs COVID− contrast 99 → 106.
|
| 91 |
+
- **Conclusion.** K = 4,000 gives slightly more accurate composition and calibration at the same disease signal.
|
| 92 |
+
- **Not done.** A discovery workflow on the K = 4,000 cells (the K = 1,000 reports found nothing new beyond the bulk
|
| 93 |
+
in either cohort).
|
paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/analysis/benchmark/imperial_eskd/AGGREGATE.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# imperial_eskd: LoRA-5 at K = 4,000 vs K = 1,000 on the paired benchmark (5 draws)
|
| 2 |
+
|
| 3 |
+
Same five few-pair draws (same 5 training donors each), same test donors, same scorer (paired_finetune_intradataset_20260927/tools/score_ft.py), 1,500 cells per test sample. Mean ± SD over draws.
|
| 4 |
+
|
| 5 |
+
| metric | LoRA-5, K = 1,000 (benchmark) | LoRA-5, K = 4,000 | K4000 − K1000 (draws better / n) |
|
| 6 |
+
|---|---:|---:|---|
|
| 7 |
+
| comp_l1 | 0.503 ± 0.022 | 0.487 ± 0.032 | -0.016 (5 / 5) |
|
| 8 |
+
| precision | 0.853 ± 0.018 | 0.846 ± 0.024 | -0.007 (1 / 5) |
|
| 9 |
+
| coverage | 0.737 ± 0.085 | 0.721 ± 0.094 | -0.016 (1 / 5) |
|
| 10 |
+
| coverage_dm | 0.863 ± 0.044 | 0.859 ± 0.046 | -0.004 (2 / 5) |
|
| 11 |
+
| pb_r_median | 0.870 ± 0.005 | 0.871 ± 0.006 | +0.001 (3 / 5) |
|
| 12 |
+
| mono_pct_gen | 17.625 ± 2.453 | 18.400 ± 2.614 | +0.775 (2 / 5) |
|
| 13 |
+
| mono_pct_obs | 16.921 ± 0.585 | 16.921 ± 0.585 | +0.000 |
|
| 14 |
+
| median_umi_gen | 1177.200 ± 140.901 | 1157.800 ± 146.791 | -19.400 (1 / 5) |
|
| 15 |
+
| median_umi_obs | 1352.800 ± 17.852 | 1352.800 ± 17.852 | +0.000 |
|
| 16 |
+
| deg_top50_sum | 113.600 ± 6.309 | 115.800 ± 7.362 | +2.200 (4 / 5) |
|
| 17 |
+
| deg_top50_sum_broadcast | 74.800 ± 7.727 | 74.800 ± 7.727 | +0.000 |
|
| 18 |
+
| logfc_r_gen | 0.749 ± 0.024 | 0.748 ± 0.023 | -0.002 (2 / 5) |
|
| 19 |
+
| logfc_r_broadcast | 0.656 ± 0.009 | 0.656 ± 0.009 | +0.000 |
|
| 20 |
+
| logfc_partial_r | 0.603 ± 0.033 | 0.603 ± 0.038 | -0.000 (2 / 5) |
|
| 21 |
+
|
| 22 |
+
Per donor-draw composition L1, K = 4,000 − K = 1,000: -0.0158; K = 4,000 is better in 56% of 715 donor-draws (Wilcoxon p 2.4e-05).
|
| 23 |
+
|
| 24 |
+
Lower is better for comp_l1; closer to *_obs is better for mono_pct_gen and median_umi_gen; higher is better for precision, coverage, pseudobulk r, the logFC r values and the top-50 DEG overlap. *_obs and *broadcast rows are the same for both arms (observed truth / bulk baseline).
|
| 25 |
+
|
| 26 |
+
Scorer check: this plan's K = 1,000 arm vs the benchmark's stored draw scores, max |difference| per draw: draw0 0 (25 metrics), draw1 0 (25 metrics), draw2 0 (25 metrics), draw3 0 (25 metrics), draw4 0 (25 metrics).
|
paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/share/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Generated single cells for bulk-only samples (LoRA-5, K = 4,000, 4,000 cells per sample)
|
| 2 |
+
|
| 3 |
+
This is the second version of the bulk-only cells, made on 2026-10-06. The first version (K = 1,000, 1,500 cells per
|
| 4 |
+
sample) is shared separately; the two versions use the same samples and the same five few-pair draws.
|
| 5 |
+
|
| 6 |
+
- **Ye 2026 sepsis** (GSE279448): 122 bulk samples without a single-cell partner.
|
| 7 |
+
- 68 adult sepsis, 36 adult healthy controls, 17 adult ICU controls, 1 paediatric ICU control.
|
| 8 |
+
- **Imperial ESKD COVID** (Gisby 2022 bulk; Stephenson 2025 single cell): 164 bulk samples without a single-cell
|
| 9 |
+
partner, from 76 donors.
|
| 10 |
+
- 143 COVID+, 19 COVID−, 2 recovery samples.
|
| 11 |
+
|
| 12 |
+
**These cells are model predictions, not measurements.** Read the caveats below before using them.
|
| 13 |
+
|
| 14 |
+
## What changed from the K = 1,000 version
|
| 15 |
+
|
| 16 |
+
1. **The models were retrained at K = 4,000.** K is the recipe size of the bulk condition, not a cell number.
|
| 17 |
+
- Each of the five draws keeps its 5 training donors and the LoRA-5 protocol: LoRA r16, 3,000 steps, the same
|
| 18 |
+
seed.
|
| 19 |
+
- Only the training condition changed, to K = 4,000. Sampling uses the same K.
|
| 20 |
+
2. **4,000 cells per sample** instead of 1,500.
|
| 21 |
+
- Sepsis: 488,000 cells per draw. Imperial: 656,000 cells per draw.
|
| 22 |
+
3. **The five draws are independent.**
|
| 23 |
+
- Draw j uses base seed `20260927 + j × 1,000,003`, and its Poisson read-out seed is `20260916 + j`.
|
| 24 |
+
- In the K = 1,000 version all draws shared one seed, so the same cell slot started from the same noise in every
|
| 25 |
+
draw.
|
| 26 |
+
|
| 27 |
+
## Files
|
| 28 |
+
|
| 29 |
+
| path | what |
|
| 30 |
+
|---|---|
|
| 31 |
+
| `<cohort>/lora5k4_bulkonly_<cohort>_draw<j>.h5ad` | One file per draw (AnnData; same layout as the K = 1,000 files). |
|
| 32 |
+
| `<cohort>/samples.csv` | Bulk-only sample metadata (clinical columns, sex flags, training-donor flags). |
|
| 33 |
+
| `analysis/benchmark/<cohort>/AGGREGATE.md` | Paired benchmark: K = 4,000 vs K = 1,000 LoRA-5 on the same draws and test donors. |
|
| 34 |
+
| `analysis/compare_k1000/<cohort>/SUMMARY.md` | Paired-test calibration of every feature, K = 4,000 vs K = 1,000. |
|
| 35 |
+
| `analysis/features/<cohort>/calibration.csv` | Paired-test calibration (the trust layer) of this version. |
|
| 36 |
+
| `analysis/analysis_bundle.tar.gz` | Feature tables, scores and every script of this version. |
|
| 37 |
+
| `MANIFEST.json`, `SHA256SUMS` | Byte size and sha256 of every shared file. |
|
| 38 |
+
|
| 39 |
+
The raw sampler outputs (expected counts, about 160 GB) are not uploaded. They stay on the lab server with their
|
| 40 |
+
sha256 receipts and are available on request.
|
| 41 |
+
|
| 42 |
+
**h5ad contents:**
|
| 43 |
+
|
| 44 |
+
- `X`: integer UMI counts (int32 CSR), cells × 6,000 panel genes.
|
| 45 |
+
- `obs`:
|
| 46 |
+
- `sample_id`;
|
| 47 |
+
- the sample's clinical metadata;
|
| 48 |
+
- labels: `celltype_l1_pred`, `aifi_l1`, `aifi_l2`, `aifi_l2_confidence`;
|
| 49 |
+
- `lib_measured`.
|
| 50 |
+
- `var`: `gene_id`, `gene_symbol`, `measured_in_cohort`.
|
| 51 |
+
- Genes the cohort's assay did not measure are generated as 0 by design. Drop them for cohort comparisons.
|
| 52 |
+
- `uns["provenance"]`: a JSON string with the model, K, training donors, LoRA run and checkpoint sha256, seeds,
|
| 53 |
+
part-file sha256 and label sha256.
|
| 54 |
+
|
| 55 |
+
```python
|
| 56 |
+
import json, anndata as ad
|
| 57 |
+
a = ad.read_h5ad("lora5k4_bulkonly_ye2026_sepsis_draw0.h5ad")
|
| 58 |
+
prov = json.loads(a.uns["provenance"])
|
| 59 |
+
a = a[:, a.var.measured_in_cohort.to_numpy()]
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Caveats
|
| 63 |
+
|
| 64 |
+
1. **Predictions.** Nothing here was measured at the single-cell level.
|
| 65 |
+
2. **Draws differ.** Each draw imprints its five training donors.
|
| 66 |
+
- Analyse each draw separately and check that draw's rows in `calibration.csv` before trusting a feature.
|
| 67 |
+
- Do not average absolute levels over draws.
|
| 68 |
+
3. **Calibration.** `calibration.csv` compares generated and observed cells on each draw's paired test samples
|
| 69 |
+
(1,500 generated cells per test sample, as in the benchmark). A feature or contrast that fails there should not be
|
| 70 |
+
interpreted in the bulk-only cells.
|
| 71 |
+
4. **Labels are predictions too.** They are frozen scANVI calls on generated cells. Rare types are the least
|
| 72 |
+
reliable.
|
| 73 |
+
5. **Sex flags.** The bulk sex call differs from the metadata for HC23, HC30 and Res-S34 (sepsis) and C137_positive_2
|
| 74 |
+
(Imperial). These samples are flagged in `obs["sex_flag"]`.
|
| 75 |
+
|
| 76 |
+
## Benchmark: K = 4,000 vs K = 1,000
|
| 77 |
+
|
| 78 |
+
Both versions were scored with the paired benchmark's own scorer on the same draws, training donors, test donors
|
| 79 |
+
and observed truth, with 1,500 generated cells per test sample. Values are means over the 5 draws
|
| 80 |
+
(`analysis/benchmark/<cohort>/AGGREGATE.md`).
|
| 81 |
+
|
| 82 |
+
| metric | sepsis K = 1,000 | sepsis K = 4,000 | Imperial K = 1,000 | Imperial K = 4,000 |
|
| 83 |
+
|---|---:|---:|---:|---:|
|
| 84 |
+
| composition L1 (lower is better) | 0.466 | **0.445** | 0.503 | **0.487** |
|
| 85 |
+
| case-vs-control logFC r | 0.350 | 0.327 | 0.749 | 0.748 |
|
| 86 |
+
| top-50 DEG overlap | 16.4 | 17.8 | 113.6 | 115.8 |
|
| 87 |
+
| coverage | 0.694 | 0.698 | 0.737 | 0.721 |
|
| 88 |
+
|
| 89 |
+
- **Composition improves.**
|
| 90 |
+
- Sepsis: better in 4 of 5 draws (per donor-draw Wilcoxon p = 0.005).
|
| 91 |
+
- Imperial: better in 5 of 5 draws (p = 2e-5).
|
| 92 |
+
- **The disease signal does not change.** logFC r and the top-50 DEG overlap are within draw-to-draw noise.
|
| 93 |
+
- **Paired-test calibration** (`analysis/compare_k1000/<cohort>/SUMMARY.md`). Counts are feature × draw pairs that
|
| 94 |
+
pass, out of 250.
|
| 95 |
+
- Sepsis:
|
| 96 |
+
- level within 0.5–2x of observed with Spearman ≥ 0.3: 107 (K = 1,000: 100);
|
| 97 |
+
- sepsis vs HC contrast reproduced: 83 (73);
|
| 98 |
+
- sepsis vs ICU control contrast reproduced: 66 (57).
|
| 99 |
+
- Imperial: level 110 (111); COVID+ vs COVID− contrast reproduced: 106 (99).
|
| 100 |
+
- **In short.** K = 4,000 gives slightly more accurate cell-type composition and somewhat better calibration in
|
| 101 |
+
sepsis. It is not a stronger disease-signal model. It is the better version when you need many cells per sample
|
| 102 |
+
or independent draws.
|
paper-releases/pbisc-diffusion/updates/20261006T033847Z-bulkonly-lora5-k4000/diffusion/dataset/server_1/model8/plans/bulkonly_lora5_k4000_20261006/tools/split_conditions.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Split a condition NPZ into row parts so one sampler call fits in memory (CPU only; 2026-10-06).
|
| 3 |
+
|
| 4 |
+
Same rule as bulkonly_lora5_20261006/tools/split_conditions.py, generalised to any condition NPZ of this plan.
|
| 5 |
+
Why: sample_sdd_standalone.py keeps five full output arrays and then checks them in float64 (about 0.3-0.4 GB per
|
| 6 |
+
1,000 cells at its peak), so a set is generated as parts of at most about 110,000 cells.
|
| 7 |
+
Each part is the NPZ restricted to a contiguous row range; every per-row key is sliced, the rest is copied.
|
| 8 |
+
Seeds: the sampler draws cell c of bulk row i with seed + i * 10,000,019 + c (support draw: + 7,919). A part starting
|
| 9 |
+
at row r0 is sampled with seed + r0 * 10,000,019, so every cell gets exactly the seed it would get in the unsplit file.
|
| 10 |
+
Writes <stem>_part<k>.npz next to the source and <stem>.PARTS.json (row ranges, cells, seeds, sha256).
|
| 11 |
+
usage: CUDA_VISIBLE_DEVICES='' split_conditions.py CONDITION_NPZ N_PARTS [--seed 20260927]
|
| 12 |
+
"""
|
| 13 |
+
from __future__ import annotations
|
| 14 |
+
|
| 15 |
+
import argparse
|
| 16 |
+
import hashlib
|
| 17 |
+
import json
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
from pathlib import Path
|
| 21 |
+
|
| 22 |
+
if os.environ.get("CUDA_VISIBLE_DEVICES") != "":
|
| 23 |
+
raise SystemExit("run with CUDA_VISIBLE_DEVICES=''")
|
| 24 |
+
|
| 25 |
+
import numpy as np
|
| 26 |
+
|
| 27 |
+
ROW_STRIDE = 10_000_019 # sample_sdd_standalone.py: cell_seed = seed + index * 10_000_019 + cell
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def sha(p: Path) -> str:
|
| 31 |
+
h = hashlib.sha256()
|
| 32 |
+
with open(p, "rb") as f:
|
| 33 |
+
for b in iter(lambda: f.read(1 << 24), b""):
|
| 34 |
+
h.update(b)
|
| 35 |
+
return h.hexdigest()
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def main(argv=None) -> int:
|
| 39 |
+
ap = argparse.ArgumentParser()
|
| 40 |
+
ap.add_argument("condition", type=Path)
|
| 41 |
+
ap.add_argument("n_parts", type=int)
|
| 42 |
+
ap.add_argument("--seed", type=int, default=20260927)
|
| 43 |
+
a = ap.parse_args(argv)
|
| 44 |
+
src = a.condition.resolve()
|
| 45 |
+
# this plan's own files: donor_ids / groups are object arrays, as in the benchmark's condition NPZs (the sampler
|
| 46 |
+
# never reads them)
|
| 47 |
+
d = np.load(src, allow_pickle=True)
|
| 48 |
+
n = int(d["sample_ids"].shape[0])
|
| 49 |
+
if not 1 <= a.n_parts <= n:
|
| 50 |
+
raise SystemExit("N_PARTS must be 1..rows")
|
| 51 |
+
if int(d["cells_per_bulk"].max()) >= ROW_STRIDE:
|
| 52 |
+
raise SystemExit("cells_per_bulk would overlap the next row's seeds")
|
| 53 |
+
per_row = [k for k in d.files if d[k].ndim >= 1 and d[k].shape[0] == n and k != "gene_ids"]
|
| 54 |
+
edges = np.linspace(0, n, a.n_parts + 1).round().astype(int)
|
| 55 |
+
parts = []
|
| 56 |
+
for k in range(a.n_parts):
|
| 57 |
+
r0, r1 = int(edges[k]), int(edges[k + 1])
|
| 58 |
+
out = src.with_name(f"{src.stem}_part{k}.npz")
|
| 59 |
+
arrs = {key: (d[key][r0:r1] if key in per_row else d[key]) for key in d.files}
|
| 60 |
+
np.savez(out, **arrs)
|
| 61 |
+
chk = np.load(out, allow_pickle=True)
|
| 62 |
+
for key in d.files:
|
| 63 |
+
want = d[key][r0:r1] if key in per_row else d[key]
|
| 64 |
+
if not np.array_equal(chk[key], want):
|
| 65 |
+
raise SystemExit(f"{out.name}: {key} differs after writing")
|
| 66 |
+
parts.append({"part": k, "rows": [r0, r1], "n_samples": r1 - r0,
|
| 67 |
+
"cells": int(d["cells_per_bulk"][r0:r1].sum()), "file": out.name, "sha256": sha(out),
|
| 68 |
+
"seed": int(a.seed + r0 * ROW_STRIDE),
|
| 69 |
+
"first_sample": str(d["sample_ids"][r0]), "last_sample": str(d["sample_ids"][r1 - 1])})
|
| 70 |
+
man = {"source": str(src), "source_sha256": sha(src), "n_rows": n, "cells": int(d["cells_per_bulk"].sum()),
|
| 71 |
+
"per_row_keys": per_row, "row_stride": ROW_STRIDE, "base_seed": a.seed,
|
| 72 |
+
"tool": str(Path(__file__).resolve()), "tool_sha256": sha(Path(__file__)), "parts": parts}
|
| 73 |
+
(src.parent / f"{src.stem}.PARTS.json").write_text(json.dumps(man, indent=1) + "\n")
|
| 74 |
+
print(json.dumps([{k: p[k] for k in ("part", "rows", "cells", "seed")} for p in parts]))
|
| 75 |
+
return 0
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
if __name__ == "__main__":
|
| 79 |
+
sys.exit(main())
|