junidude14 commited on
Commit
5348ee4
·
verified ·
1 Parent(s): 13e4c62

Archive 4 checkpoints (1-4)

Browse files
paper-releases/pbisc-diffusion/updates/20261004T065028Z-behcet-c1q-k4000-corpus/diffusion/dataset/server_1/model8/plans/behcet_c1q_lora3_20261004/README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Behçet C1Q-high monocytes with LoRA on 3 recovered pairs (2026-10-04)
2
+
3
+ **Question (user).** Can PBISC's paired LoRA reproduce a disease-specific subtype, the C1Q-high monocytes of
4
+ Behçet's disease (Zheng 2022 PNAS)? The zero-shot final model reversed the group difference: BD < HC
5
+ (utility_studies_final6k_20260925/behcet_probe).
6
+
7
+ **Pairs.** BDV4–PBMC_BD_2, BDV5–PBMC_BD_3 and BDV6–PBMC_BD_4 were recovered blind to ages in
8
+ `plans/behcet_pair_recovery_20261004`, and all three have equal ages. There is no HC pair.
9
+
10
+ ## Design
11
+
12
+ - **Training.** LoRA r16 on the 3 BD pairs, using the LoRA-5 protocol: lr 5e-4, 3,000 fixed steps, batch 256, seed
13
+ 20260927, real-bulk condition, fixed depth K = 1,000.
14
+ - Trainer: `paired_finetune_intradataset_20260927/tools/ft_sdd.py`, unchanged.
15
+ - 16,635 cells; 106 s on GB10; checkpoint sha `de5d7974…` (`runs/lora3/RUN.json`).
16
+ - **Generation.** All 19 bulks, 5,000 cells each, DDIM 50, EMA weights, Bernoulli support. Two sampling seeds:
17
+ 20260913 (the published Behçet seed) and 20261004.
18
+
19
+ | arm | model | bulk input |
20
+ |---|---|---|
21
+ | zs_raw | final model, zero-shot | real bulk |
22
+ | zs_cal | final model, zero-shot | bulk × α, gene-wise calibration fitted on the same 3 pairs |
23
+ | lora3_raw | LoRA-3 | real bulk |
24
+
25
+ - **Test rows.** The 6 BD bulks without sc (BDU1–3, BDV1–3) and all 10 HC bulks. None of them was seen in training.
26
+ - **Scoring.** The earlier Behçet wrapper, unchanged (`behcet/tools/behcet_rules_and_groups.py`): frozen f01common
27
+ scANVI labels and Poisson read-out seed 20260916.
28
+ - Gene space: the 5,671-gene shared space ∩ genes measured in all 8 sc libraries = 5,658 genes, used for every arm.
29
+ - Rule A: C1Q-high = any C1Q gene detected. In generated arms rule A equals rule D, because rule D's 95th-percentile
30
+ threshold is 0 there. Rule B: ≥ 2 C1Q genes.
31
+ - **Ground truth.** GSE198616 sc PBMC, 4 BD vs 4 HC, mostly different donors from the bulk. Scored at native depth
32
+ and thinned to each arm's monocyte depth.
33
+
34
+ ## Results (`out/group_table.csv`, `out/in_sample.csv`, `out/capability.csv`)
35
+
36
+ **1. Group direction on the 16 held-out bulks.** C1Q-high share of monocytes, rule A; per-sample means BD / HC and the
37
+ gap:
38
+
39
+ | arm | seed 20260913 | seed 20261004 |
40
+ |---|---|---|
41
+ | zs_raw | 2.16 / 3.10, **−0.94 pp** (p 0.02) | 2.23 / 2.86, **−0.63 pp** (p 0.07) |
42
+ | zs_cal | 4.54 / 3.43, **+1.11 pp** (p 0.18) | – |
43
+ | lora3_raw | 4.86 / 3.95, **+0.91 pp** (p 0.26) | 5.28 / 3.55, **+1.72 pp** (p 0.02) |
44
+ | observed, thinned to lora3 depth (4 vs 4) | 7.96 / 6.70, +1.26 pp (p 0.49) | |
45
+
46
+ - **LoRA-3 turns the zero-shot reversal into the observed direction** in both seeds. The gap size (+0.9 to +1.7 pp)
47
+ brackets the observed +1.3 pp. The BD/HC ratio is 1.2–1.5; observed sc gives 1.2 and the authors' flow cytometry
48
+ 1.75.
49
+ - **Calibration fitted on the same 3 pairs does the same** (+1.1 pp). On the group direction, LoRA is not ahead of
50
+ calibration.
51
+ - The seed-to-seed spread of the LoRA gap (0.8 pp) is as large as the gap itself. With 6 vs 10 held-out bulks this
52
+ is a direction result, not a precise effect size.
53
+
54
+ **2. Composition is where most of the gain comes from.**
55
+ - Monocytes as a share of all cells on held-out bulks, BD / HC: zs_raw 30.2 / 20.1, zs_cal 13.5 / 11.0, lora3 16.0 /
56
+ 11.9. Observed sc gives 16.7 / 13.0.
57
+ - Training donors, generated vs their own observed cells: LoRA 13.7 / 19.2 / 20.2 % vs observed 14.9 / 20.9 / 20.5 %;
58
+ zero-shot 23 / 44 / 44 %.
59
+
60
+ **3. The C1Q-high state itself is still mostly missing.** Pooled monocytes of the held-out bulks, observed thinned to
61
+ the same depth:
62
+
63
+ | | any C1Q gene (rule A) | ≥ 2 C1Q genes (rule B) |
64
+ |---|---|---|
65
+ | zs_raw | 2.6 % (0.57× of 4.6 %) | 0.16 % (0.10× of 1.6 %) |
66
+ | lora3_raw | 4.3 % (0.63× of 6.9 %) | 0.25–0.35 % (0.10–0.15× of 2.4 %) |
67
+
68
+ Even for the 3 training donors, LoRA gives ≥ 2-gene C1Q cells at 0.5–1.1 % against 1.5–3.7 % observed. LoRA improves
69
+ single-gene C1Q detection and composition. It does not create the multi-gene, high-UMI C1Q-high cells. This is the
70
+ same limit the zero-shot probe found (value magnitude of rare genes below 1 UMI).
71
+
72
+ ## Verdict
73
+
74
+ - **Disease direction: yes.** With 3 BD pairs, LoRA reproduces the BD > HC direction of C1Q-positive monocytes on
75
+ held-out bulks and fixes the monocyte over-production. Calibration on the same 3 pairs does as well on this readout.
76
+ - **The subtype itself: not yet.** The generated "C1Q-high" cells are mostly single-gene C1Q detections in CD16-type
77
+ monocytes, not the multi-gene C1Q-high state. A claim that PBISC generates C1Q-high monocytes would overstate this.
78
+ - **Limits.** 3 training pairs, all BD and all vascular type; no HC pair; 6 vs 10 test bulks; 2 seeds. The truth set
79
+ is 4 vs 4 other donors. Rule A is a weak definition at ~500 UMI per cell.
80
+
81
+ ## Follow-up 1: LoRA at K = 4000 (user question: is the gap caused by K = 1000?)
82
+
83
+ **K is the recipe size of the condition, not the number of cells generated.** Every arm generates 5,000 cells per
84
+ bulk, and the 0.10–0.15× above is a rate ratio, so more cells would not change it.
85
+
86
+ **Setup.** LoRA was trained and sampled on the same 3 pairs with the real-bulk condition at K = 4000:
87
+ `tools/build_k_conditions.py 4000`, whose K = 1000 arithmetic is byte-identical to `conditions_raw_fixed.npz`. The
88
+ run is `runs/lora3_k4000` and the queue `queues/arms_k4000.txt`. Scoring is the same, in `out/rules_groups_k4000`;
89
+ the summary is in `out/*_k4000.csv`.
90
+
91
+ | held-out 6 BD vs 10 HC | rule A gap (pp) | ≥ 2 C1Q genes, pooled monocytes | ratio to observed at the same depth |
92
+ |---|---|---|---|
93
+ | zero-shot K = 1000 (s13 / s04) | −0.94 / −0.63 | 0.16 / 0.15 % | 0.10× |
94
+ | zero-shot K = 4000 (s13) | −1.11 | 0.19 % | 0.12× (obs 1.67 %) |
95
+ | LoRA-3 K = 1000 (s13 / s04) | +0.91 / +1.72 | 0.25 / 0.35 % | 0.10–0.15× (obs 2.42 %) |
96
+ | **LoRA-3 K = 4000 (s13 / s04)** | **+2.20 / +2.37** (p 0.005 / 0.0005) | **0.46 / 0.42 %** | **0.17–0.18×** (obs 2.48 %) |
97
+ | observed, 4 vs 4 | +1.32 native; +0.96 thinned to the K = 4000 LoRA depth | 2.53 % native | – |
98
+
99
+ - **K = 4000 makes the group direction stronger and steadier.** Both seeds give BD > HC with p ≤ 0.005, and the gap
100
+ is now larger than the observed one. Monocyte fractions are 15.9 / 11.6 %, still close to the observed 16.7 / 13.0 %.
101
+ - **The multi-gene C1Q state improves only a little**, from 0.10–0.15× to 0.17–0.18×. Even the training donors stay
102
+ at 0.10–0.75 % against 1.6–3.8 % observed.
103
+ - So K is not the main cause. Raising it helps the direction, but the C1Q-high cells themselves are still mostly
104
+ missing.
105
+
106
+ ## Follow-up 2: is Behçet, or the C1Q-high state, in the pretraining corpus? (`tools/corpus_c1q.py`)
107
+
108
+ **Behçet is not in the corpus.** The final model was trained on 22 datasets, 41.4 M cells
109
+ (`full_recipe_allcells_6k_broad_20260909/coverage_v1/shard_offsets.csv`), and none of them is GSE198616 or GSE198533.
110
+
111
+ **The C1Q-high state is in the corpus, at about the Behçet rate.**
112
+ - *Sample:* 179,750 cells, about 8,000 per dataset from random blocks of up to 8 shards. Source is the PBISC-data
113
+ copy of the training shards, on the 6k panel, seed 20261004.
114
+ - *Labels and scoring:* the same frozen scANVI labels, and the same C1Q counting as the Behçet scoring.
115
+ - *Depth matching:* each dataset's monocytes are binomially thinned to the Behçet observed median monocyte library
116
+ (2,045 panel UMI).
117
+
118
+ | | monocytes | ≥ 2 C1Q genes, depth-matched |
119
+ |---|---:|---:|
120
+ | Behçet observed BD / HC | 3,572 / 2,794 | 2.72 / 2.25 % |
121
+ | corpus, pooled over 22 datasets | 32,766 | 2.19 % |
122
+ | highest: DRESS (GSE132802), SLE IL-36 stim, Parse cytokine, COMBAT | | 13.8, 3.4, 3.4, 3.8 % |
123
+ | lowest: SLE B-cell study, JDM, ScaleBio, Miao RA (low depth) | | 0.0, 0.2, 0.4, 0.4 % |
124
+
125
+ **So the gap is not missing training data.** Monocytes with ≥ 2 C1Q genes make up about 2 % of the corpus, the same
126
+ as in Behçet. The model generates them at 0.15–0.46 %, so it under-produces co-expression of these rare genes about
127
+ 5–15-fold even though the state is in its training cells. This points at the generator: per-cell values of rare genes
128
+ come out below 1 UMI, and their joint support is rarely drawn. The next step would be the read-out or the value model
129
+ for rare co-expressed genes, not more pairs or a larger K.
130
+
131
+ ## Files
132
+
133
+ - `tools/build_dataset.py` → `data/behcet/` (features, cells, conditions, BUILD.json).
134
+ - `tools/run_gpu.sh` (train + 5 sampling arms, read-out, labels; NPZs moved to spark-0110 at the same path with a
135
+ sha check, `generated/<arm>.moved`).
136
+ - `tools/score_arms.sh` → `out/rules_groups/`.
137
+ - `tools/summarize.py` → `out/{group_table,in_sample,capability}.csv`, `out/SUMMARY.json`.
138
+ - Queue: `queues/arms.txt`. Logs: `logs/`.
139
+ - GPU: interleaved with the scSemiProfiler CV queue through the shared lock (ml-run flock), never concurrent.
140
+ - Follow-ups (2026-10-04): `tools/build_k_conditions.py`, `queues/arms_k4000.txt`, `runs/lora3_k4000/`, `out/rules_groups_k4000/`, `out/*_k4000.csv`; `tools/corpus_c1q.py` → `out/corpus_c1q.csv`, `work/corpus_c1q/{SAMPLE.json, scanvi_labels/}`.
141
+ - Moved to spark-0110 at the same paths (sha-checked, `.moved` markers here): both LoRA checkpoints, every generated NPZ and read-out h5ad, `work/corpus_c1q/corpus_sample.h5ad`.
142
+ - `tools/*.bak_20261004k1000`: the scripts as run for the K = 1000 part (before the env parameters were added).
paper-releases/pbisc-diffusion/updates/20261004T065028Z-behcet-c1q-k4000-corpus/diffusion/dataset/server_1/model8/plans/behcet_c1q_lora3_20261004/data/behcet/conditions_raw_fixed_K4000.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b0f5fb361418a6ffe97aa296e73cf6b6107986ea8068fa8058a1b4c31e85e25
3
+ size 6174691
paper-releases/pbisc-diffusion/updates/20261004T065028Z-behcet-c1q-k4000-corpus/diffusion/dataset/server_1/model8/plans/behcet_c1q_lora3_20261004/queues/arms_k4000.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # K = 4000 test (2026-10-04): LoRA-3 trained and sampled on the K = 4000 real-bulk condition; zero-shot at K = 4000 as its base
2
+ lora3k4_raw_s13|lora|/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_c1q_lora3_20261004/data/behcet/conditions_raw_fixed_K4000.npz|20260913
3
+ lora3k4_raw_s04|lora|/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_c1q_lora3_20261004/data/behcet/conditions_raw_fixed_K4000.npz|20261004
4
+ zsk4_raw_s13|base|/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_c1q_lora3_20261004/data/behcet/conditions_raw_fixed_K4000.npz|20260913
paper-releases/pbisc-diffusion/updates/20261004T065028Z-behcet-c1q-k4000-corpus/diffusion/dataset/server_1/model8/plans/behcet_c1q_lora3_20261004/tools/score_arms.sh ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # CPU only. Scores every arm of this study with the earlier Behçet task's wrapper, unchanged
3
+ # (utility_studies_final6k_20260925/behcet/tools/behcet_rules_and_groups.py, which imports analyze_c1q_subset.py
4
+ # read-only): frozen f01common scANVI labels, Poisson read-out seed 20260916, C1Q-high rules D / A / B / C.
5
+ # Gene space: the earlier 5,671-gene shared space intersected with this study's output space (genes measured in all 8
6
+ # GSE198616 PBMC libraries) = work/shared_gene_space_lora3.csv, for every arm, observed included.
7
+ # Observed = GSE198616 PBMC (4 BD vs 4 HC), native depth and binomially thinned to each base arm's monocyte depth.
8
+ # env (2026-10-04): TAGS (arms to score), THIN (base arms the observed cells are thinned to), OUTDIR
9
+ set -euo pipefail
10
+ export CUDA_VISIBLE_DEVICES="" OMP_NUM_THREADS=4 MKL_NUM_THREADS=4 OPENBLAS_NUM_THREADS=4
11
+ M8=/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion
12
+ P=$M8/plans/behcet_c1q_lora3_20261004
13
+ B=$M8/plans/utility_studies_final6k_20260925/behcet
14
+ R=$M8/plans/behcet_c1q_repro_20260921
15
+ PY=/home/sj_server_1/miniforge3/envs/cxg_corpus/bin/python
16
+ SERIES=/home/sj_server_1/gblee/datalake/paired-pbmc-bulk-sc/datasets/GSE198533/metadata/GSE198533_series_matrix.txt.gz
17
+ INFO=/home/sj_server_1/gblee/datalake/paired-pbmc-bulk-sc/datasets/GSE198616/raw/GSE198616_sample_info.csv.gz
18
+ OBS_H5AD=$R/work/gse198616_pbmc_all8.h5ad
19
+ OBS_LAB=$B/work/scanvi_labels_real_f01common/labels.parquet
20
+ SHARED=$P/work/shared_gene_space_lora3.csv
21
+ $PY - "$R/work/shared_gene_space_genf016k.csv" "$P/data/behcet/conditions_raw_fixed.npz" "$SHARED" <<'EOF'
22
+ import sys, numpy as np, pandas as pd
23
+ sh = pd.read_csv(sys.argv[1]); z = np.load(sys.argv[2], allow_pickle=False)
24
+ out = set(z["gene_ids"].astype(str)[z["output_availability_mask"].all(0)])
25
+ keep = sh[sh.gene_id.astype(str).isin(out)]
26
+ keep.to_csv(sys.argv[3], index=False)
27
+ print(f"shared space: {len(sh)} -> {len(keep)} genes")
28
+ EOF
29
+ ARMS=()
30
+ TAGS=${TAGS:-zs_raw_s13 zs_cal_s13 lora3_raw_s13 lora3_raw_s04 zs_raw_s04}
31
+ THIN=${THIN:-zs_raw_s13:obs_thin_zs lora3_raw_s13:obs_thin_lora3}
32
+ OUTDIR=${OUTDIR:-$P/out/rules_groups}
33
+ for tag in $TAGS; do
34
+ h5=$P/work/${tag}_poisson.h5ad; lab=$P/work/scanvi_labels_${tag}_f01common/labels.parquet
35
+ [[ -s $h5 && -s $lab ]] || { echo "missing $tag"; exit 1; }
36
+ ARMS+=(--arm "name=$tag,source=generated,h5ad=$h5,labels=$lab,restrict=$SHARED,group=series:$SERIES")
37
+ done
38
+ ARMS+=(--arm "name=obs,source=real,h5ad=$OBS_H5AD,labels=$OBS_LAB,restrict=$SHARED,group=obs:condition,sample_info=$INFO")
39
+ for t in $THIN; do
40
+ ARMS+=(--arm "name=${t#*:},source=real,h5ad=$OBS_H5AD,labels=$OBS_LAB,restrict=$SHARED,group=obs:condition,sample_info=$INFO,thin_to=${t%%:*}")
41
+ done
42
+ echo "rules start $(date -Is)"
43
+ $PY $B/tools/behcet_rules_and_groups.py "${ARMS[@]}" --out-dir $OUTDIR
44
+ echo "done $(date -Is)"