Archive 4 checkpoints (1-4)
Browse files- paper-releases/pbisc-diffusion/updates/20261004T003810Z-behcet-pair-recovery/diffusion/dataset/server_1/model8/plans/behcet_pair_recovery_20261004/out/unblind_ages.csv +9 -0
- paper-releases/pbisc-diffusion/updates/20261004T003810Z-behcet-pair-recovery/diffusion/dataset/server_1/model8/plans/behcet_pair_recovery_20261004/tools/recover_pairs.py +418 -0
- paper-releases/pbisc-diffusion/updates/20261004T003810Z-behcet-pair-recovery/diffusion/dataset/server_1/model8/plans/behcet_pair_recovery_20261004/tools/unblind_ages.py +112 -0
- paper-releases/pbisc-diffusion/updates/20261004T003810Z-behcet-pair-recovery/diffusion/metadata/request.json +241 -0
paper-releases/pbisc-diffusion/updates/20261004T003810Z-behcet-pair-recovery/diffusion/dataset/server_1/model8/plans/behcet_pair_recovery_20261004/out/unblind_ages.csv
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
sc_sample,sc_age,sc_sex_geo,sc_sex_chrY,most_frequent_best_bulk,rules_with_this_best,rules,rules_mutual_with_this_best,rules_calling_it,primary_rule_called,primary_r_best,primary_threshold,best_bulk_age,best_bulk_sex_geo,age_equal,bulk_samples_with_same_age
|
| 2 |
+
PBMC_BD_1,30,male,male,HC3,6,9,3,0,False,0.3348014323568667,0.6581375985244046,18,male,False,BDU2
|
| 3 |
+
PBMC_BD_2,31,male,male,BDV4,9,9,9,8,True,0.7842087546676991,0.6581375985244046,31,male,True,BDV4
|
| 4 |
+
PBMC_BD_3,58,male,male,BDV5,9,9,9,6,False,0.555423006090796,0.6581375985244046,58,male,True,BDV5;HC5
|
| 5 |
+
PBMC_BD_4,41,male,male,BDV6,9,9,9,8,True,0.7455896536503368,0.6581375985244046,41,male,True,BDV6;HC7
|
| 6 |
+
PBMC_HC_1,30,female,female,HC6,9,9,9,3,False,0.5109677763618931,0.6581375985244046,18,male,False,BDU2
|
| 7 |
+
PBMC_HC_2,31,male,female,HC2,9,9,9,0,False,0.3795763066007761,0.6581375985244046,47,male,False,BDV4
|
| 8 |
+
PBMC_HC_3,58,male,male,BDU2,3,9,3,0,False,0.2499276515703745,0.6581375985244046,30,male,False,BDV5;HC5
|
| 9 |
+
PBMC_HC_4,41,male,male,HC8,9,9,9,0,False,0.4170097120879305,0.6581375985244046,36,male,False,BDV6;HC7
|
paper-releases/pbisc-diffusion/updates/20261004T003810Z-behcet-pair-recovery/diffusion/dataset/server_1/model8/plans/behcet_pair_recovery_20261004/tools/recover_pairs.py
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Behçet (Zheng 2022) bulk <-> sc PBMC donor pairing from expression alone, with a validated decision rule (CPU only).
|
| 3 |
+
|
| 4 |
+
Question (user, 2026-10-04): can bulk GSE198533 (9 BD + 10 HC) and sc PBMC GSE198616 (4 BD + 4 HC) be paired, so that
|
| 5 |
+
PBISC's paired LoRA can be tried on Behçet? The authors state that 3 BD donors are in both, without saying which.
|
| 6 |
+
Datalake rule: identity is not inferred from age / sex, so ages are NOT used here; tools/unblind_ages.py compares them
|
| 7 |
+
afterwards.
|
| 8 |
+
|
| 9 |
+
v2 (this file). v1 (residual top-variance genes, out/_v1_resid_test/) put the true pair first in only 60-70 % of
|
| 10 |
+
Behçet-shaped sepsis draws, so its rule could not support a call. v2 scores identity only on genes that carry a
|
| 11 |
+
STABLE donor signal, learnt from other cohorts:
|
| 12 |
+
|
| 13 |
+
1. Identity genes. In cohorts with several timepoints per donor (Imperial ESKD, Liu 2021, Ji 2025, Giroux 2022), take
|
| 14 |
+
the identity-pass pairs of plans/paired_finetune_intradataset_20260927/data/<ds>/pairs.csv and pair each donor's
|
| 15 |
+
bulk at one timepoint with its sc at ANOTHER timepoint, so state shared by one blood draw cannot contribute. Per
|
| 16 |
+
gene: log2(CPM + 1) (genes valid everywhere, not chrY, not in the sex-linked exclusion list), centred within each
|
| 17 |
+
modality and group, Pearson across donors between bulk and sc. Cohorts are combined by Fisher z weighted by
|
| 18 |
+
sqrt(n - 3); genes with mean CPM >= 0.5 in both modalities of every cohort. The top G genes (G = 100, fixed a priori;
|
| 19 |
+
50 and 200 reported) are the identity set.
|
| 20 |
+
2. Score of one bulk x sc table: on the identity genes, log2(CPM + 1) centred within modality and disease group (the
|
| 21 |
+
group labels are known in both modalities), Pearson bulk x sc.
|
| 22 |
+
3. Decision rule: sc sample s is paired with bulk b when b is its best bulk, s is b's best sc sample (mutual best), and
|
| 23 |
+
the statistic is >= T. Three statistics x three gene-set sizes (G 50 / 100 / 200) are evaluated:
|
| 24 |
+
margin_z z of the best minus z of the second-best bulk (z over the bulk rows of column s)
|
| 25 |
+
r_best the correlation itself
|
| 26 |
+
dc_margin double-centred score D = R - row mean - column mean + grand mean (removes samples that correlate with
|
| 27 |
+
everyone, seen in sepsis), best / mutual best on D, statistic = D best minus D second
|
| 28 |
+
(statistics 2 and 3 were added after the first 50-draw test of v2, which also showed the Behçet scores; the choice
|
| 29 |
+
among them is made on the control cohorts only.) T is the smallest value with <= 1 % wrong calls per sc column, in
|
| 30 |
+
1,000 Behçet-shaped draws (case bulk 9, control bulk 10, case sc 4, control sc 4, 3 case donors in both, every other
|
| 31 |
+
slot a different donor) of a cohort whose genes were NOT used to learn the identity set. The primary statistic and G
|
| 32 |
+
are the pair with the highest sensitivity on sepsis; Liu must replicate it. Behçet-internal negative control: sc
|
| 33 |
+
samples with no chrY expression cannot pair with the all-male bulk and must not be called:
|
| 34 |
+
ye2026_sepsis (primary; Chinese cohort, one 10x library per donor like Behçet): identity set from all 4 cohorts
|
| 35 |
+
liu2021 (replication; HTO-pooled libraries, control bulk 7): identity set learnt without Liu
|
| 36 |
+
Behçet uses the 4-cohort identity set (the one validated on sepsis) and the sepsis threshold.
|
| 37 |
+
Outputs (<plan>/out/): identity_genes_{all4,no_liu}.csv, calibration_draws.csv.gz, calibration_summary.csv, RULE.json,
|
| 38 |
+
behcet_scores_G{50,100,200}.csv, behcet_calls.csv, behcet_gene_evidence.csv, sex_check.csv,
|
| 39 |
+
SUMMARY.json
|
| 40 |
+
usage: recover_pairs.py [--draws N]
|
| 41 |
+
"""
|
| 42 |
+
from __future__ import annotations
|
| 43 |
+
|
| 44 |
+
import argparse
|
| 45 |
+
import hashlib
|
| 46 |
+
import json
|
| 47 |
+
import os
|
| 48 |
+
import sys
|
| 49 |
+
from pathlib import Path
|
| 50 |
+
|
| 51 |
+
if os.environ.get("CUDA_VISIBLE_DEVICES") != "":
|
| 52 |
+
raise SystemExit("CPU only: run with CUDA_VISIBLE_DEVICES=''")
|
| 53 |
+
|
| 54 |
+
import h5py
|
| 55 |
+
import numpy as np
|
| 56 |
+
import pandas as pd
|
| 57 |
+
|
| 58 |
+
PLAN = Path(__file__).resolve().parents[1]
|
| 59 |
+
OUT = PLAN / "out"
|
| 60 |
+
DL = Path("/home/sj_server_1/gblee/datalake/paired-pbmc-bulk-sc/processing")
|
| 61 |
+
REF = DL / "strict_qc_v1_20260913/reference/canonical_genes.tsv"
|
| 62 |
+
PAIRDATA = Path("/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/"
|
| 63 |
+
"paired_finetune_intradataset_20260927/data")
|
| 64 |
+
SEXLIST = PAIRDATA / "sex_linked_genes/sex_linked_genes_exclude.csv"
|
| 65 |
+
BEHCET_BULK = DL / "strict_qc_v1_20260913/bulk/GSE198533_count/harmonized.h5ad"
|
| 66 |
+
BEHCET_SC = DL / "strict_qc_v1_20260913/singlecell/GSE198616"
|
| 67 |
+
BEHCET_INV = DL / "strict_qc_v1_20260913/pairing_audit/GSE198616_published_sample_inventory.csv"
|
| 68 |
+
G_PRIMARY, G_SENS = 100, (50, 200)
|
| 69 |
+
MIN_CPM = 0.5
|
| 70 |
+
FALSE_CALL_MAX = 0.01
|
| 71 |
+
SEED = 20261004
|
| 72 |
+
# bulk_key: column of pairs.csv; bulk_match: 'gsm' = harmonized obs source_GSM, 'name' = harmonized obs name
|
| 73 |
+
COHORTS = {
|
| 74 |
+
"imperial_eskd": dict(bulk=DL / "imperial_eskd_v1_20260928/bulk/Zenodo_6497251_htseq_counts/harmonized.h5ad",
|
| 75 |
+
sc_dir=DL / "imperial_eskd_v1_20260928/singlecell", bulk_key="bulk_sample", bulk_match="name",
|
| 76 |
+
sc_key="sc_sample"),
|
| 77 |
+
"liu2021": dict(bulk=DL / "liu2021_v1_20261002/bulk/GSE161918_htseq/harmonized.h5ad",
|
| 78 |
+
sc_dir=DL / "liu2021_v1_20261002/singlecell", bulk_key="bulk_gsm", bulk_match="gsm",
|
| 79 |
+
sc_key="sc_sample", case=("COVID",), ctrl=("HC",),
|
| 80 |
+
design=dict(case_bulk=9, ctrl_bulk=7, case_sc=4, ctrl_sc=4, shared=3)),
|
| 81 |
+
"ji2025_chili": dict(bulk=DL / "ji2025_chili_v1_20260928/bulk/GSE287540_salmon_counts/harmonized.h5ad",
|
| 82 |
+
sc_dir=DL / "ji2025_chili_v1_20260928/singlecell", bulk_key="bulk_gsm", bulk_match="gsm",
|
| 83 |
+
sc_key="sc_gsm"),
|
| 84 |
+
"giroux2022": dict(bulk=DL / "giroux2022_v1_20260928/bulk/GSE206263_featureCounts/harmonized.h5ad",
|
| 85 |
+
sc_dir=DL / "giroux2022_v1_20260928/singlecell", bulk_key="bulk_gsm", bulk_match="gsm",
|
| 86 |
+
sc_key="sc_gsm"),
|
| 87 |
+
"ye2026_sepsis": dict(bulk=DL / "ye2026_sepsis_v1_20260927/bulk/GSE279448_htseq_counts/harmonized.h5ad",
|
| 88 |
+
sc_dir=DL / "ye2026_sepsis_v1_20260927/singlecell", bulk_key="bulk_gsm", bulk_match="gsm",
|
| 89 |
+
sc_key="sc_gsm", case=("adult_sepsis", "ped_sepsis"),
|
| 90 |
+
ctrl=("adult_HC", "ped_HC", "adult_ICU_ctrl", "ped_ICU_ctrl"),
|
| 91 |
+
design=dict(case_bulk=9, ctrl_bulk=10, case_sc=4, ctrl_sc=4, shared=3)),
|
| 92 |
+
}
|
| 93 |
+
LEARN = ("imperial_eskd", "liu2021", "ji2025_chili", "giroux2022")
|
| 94 |
+
TESTS = {"ye2026_sepsis": "all4", "liu2021": "no_liu"}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def sha(p: Path) -> str:
|
| 98 |
+
h = hashlib.sha256()
|
| 99 |
+
with open(p, "rb") as f:
|
| 100 |
+
for b in iter(lambda: f.read(1 << 22), b""):
|
| 101 |
+
h.update(b)
|
| 102 |
+
return h.hexdigest()
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def text(a) -> list:
|
| 106 |
+
return [x.decode() if isinstance(x, bytes) else str(x) for x in a]
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def load_bulk(path: Path):
|
| 110 |
+
import anndata as ad
|
| 111 |
+
a = ad.read_h5ad(path)
|
| 112 |
+
X = np.asarray(a.X, dtype=np.float64)
|
| 113 |
+
V = np.asarray(a.layers["harmonization_valid"]).astype(bool)
|
| 114 |
+
if not np.isfinite(X[V]).all() or (X[V] < 0).any():
|
| 115 |
+
raise SystemExit(f"{path}: invalid values inside the measured mask")
|
| 116 |
+
names = a.obs_names.to_numpy().astype(str)
|
| 117 |
+
gsm = a.obs["source_GSM"].astype(str).to_numpy() if "source_GSM" in a.obs else np.full(len(names), "")
|
| 118 |
+
return np.where(V, X, 0.0), V, names, gsm, a.var_names.to_numpy().astype(str)
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def load_sc(sc_dir: Path, ids: list[str], gene_ids: np.ndarray):
|
| 122 |
+
S = np.zeros((len(ids), len(gene_ids)))
|
| 123 |
+
V = np.zeros_like(S, dtype=bool)
|
| 124 |
+
n = np.zeros(len(ids), dtype=int)
|
| 125 |
+
for i, g in enumerate(ids):
|
| 126 |
+
s = json.loads((sc_dir / g / "summary.json").read_text())
|
| 127 |
+
if s["status"] != "PASS":
|
| 128 |
+
raise SystemExit(f"{g}: sc status {s['status']}")
|
| 129 |
+
with h5py.File(sc_dir / g / "pseudobulk_per_published_sample.h5", "r") as f:
|
| 130 |
+
if text(f["gene_id"][:]) != list(gene_ids):
|
| 131 |
+
raise SystemExit(f"{g}: gene order")
|
| 132 |
+
if f.attrs["units"] != "UMI_counts" or len(f["sample_id"]) != 1:
|
| 133 |
+
raise SystemExit(f"{g}: units / sample count")
|
| 134 |
+
S[i] = f["qc_review_pass_cells_sum"][0]
|
| 135 |
+
V[i] = f["harmonization_valid"][:].astype(bool)
|
| 136 |
+
n[i] = int(f["n_cells"][1, 0])
|
| 137 |
+
return S, V, n
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
def cpm(m: np.ndarray) -> np.ndarray:
|
| 141 |
+
return m / m.sum(1, keepdims=True) * 1e6
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def group_centre(x: np.ndarray, groups) -> np.ndarray:
|
| 145 |
+
x = x.copy()
|
| 146 |
+
groups = np.asarray(groups)
|
| 147 |
+
for g in np.unique(groups):
|
| 148 |
+
m = groups == g
|
| 149 |
+
x[m] -= x[m].mean(0)
|
| 150 |
+
return x
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def pearson(a: np.ndarray, b: np.ndarray) -> np.ndarray:
|
| 154 |
+
a = a - a.mean(1, keepdims=True)
|
| 155 |
+
b = b - b.mean(1, keepdims=True)
|
| 156 |
+
a = a / np.linalg.norm(a, axis=1, keepdims=True)
|
| 157 |
+
b = b / np.linalg.norm(b, axis=1, keepdims=True)
|
| 158 |
+
return a @ b.T
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
class Cohort:
|
| 162 |
+
"""One paired cohort: all identity-pass pairs, bulk and sc rows of every pair loaded once."""
|
| 163 |
+
|
| 164 |
+
def __init__(self, name: str, gene_ids: np.ndarray):
|
| 165 |
+
cfg = COHORTS[name]
|
| 166 |
+
self.name, self.cfg = name, cfg
|
| 167 |
+
p = pd.read_csv(PAIRDATA / name / "pairs.csv", dtype=str, keep_default_na=False)
|
| 168 |
+
p = p[p.identity_pass.str.lower() == "true"].reset_index(drop=True)
|
| 169 |
+
B, BV, names, gsm, genes = load_bulk(cfg["bulk"])
|
| 170 |
+
if list(genes) != list(gene_ids):
|
| 171 |
+
raise SystemExit(f"{name}: bulk gene order")
|
| 172 |
+
key = {x: i for i, x in enumerate(gsm if cfg["bulk_match"] == "gsm" else names)}
|
| 173 |
+
miss = [x for x in p[cfg["bulk_key"]] if x not in key]
|
| 174 |
+
if miss:
|
| 175 |
+
raise SystemExit(f"{name}: {len(miss)} pair bulk ids not in the bulk table, e.g. {miss[:3]}")
|
| 176 |
+
bi = [key[x] for x in p[cfg["bulk_key"]]]
|
| 177 |
+
self.B, self.BV = B[bi], BV[bi]
|
| 178 |
+
self.S, self.SV, _ = load_sc(cfg["sc_dir"], p[cfg["sc_key"]].tolist(), gene_ids)
|
| 179 |
+
self.pairs = p
|
| 180 |
+
|
| 181 |
+
def cross_timepoint(self):
|
| 182 |
+
"""Each donor with >= 2 pairs: bulk of its first pair x sc of its second pair (different blood draws)."""
|
| 183 |
+
bi, si, grp_b, grp_s = [], [], [], []
|
| 184 |
+
for d, g in self.pairs.groupby("donor_id", sort=True):
|
| 185 |
+
if len(g) < 2:
|
| 186 |
+
continue
|
| 187 |
+
i, j = g.index[0], g.index[1]
|
| 188 |
+
bi.append(i); si.append(j)
|
| 189 |
+
grp_b.append(self.pairs.group[i]); grp_s.append(self.pairs.group[j])
|
| 190 |
+
return np.array(bi), np.array(si), grp_b, grp_s
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def learn_identity_genes(cohorts: list[Cohort], exclude: np.ndarray, gene_ids, sym) -> pd.DataFrame:
|
| 194 |
+
zsum = np.zeros(len(gene_ids)); wsum = 0.0
|
| 195 |
+
ok = ~exclude
|
| 196 |
+
per = {}
|
| 197 |
+
for c in cohorts:
|
| 198 |
+
bi, si, gb, gs = c.cross_timepoint()
|
| 199 |
+
if len(bi) < 6:
|
| 200 |
+
raise SystemExit(f"{c.name}: only {len(bi)} donors with two timepoints")
|
| 201 |
+
B, S = c.B[bi], c.S[si]
|
| 202 |
+
ok &= c.BV[bi].all(0) & c.SV[si].all(0)
|
| 203 |
+
cb, cs = cpm(B), cpm(S)
|
| 204 |
+
ok &= (cb.mean(0) >= MIN_CPM) & (cs.mean(0) >= MIN_CPM)
|
| 205 |
+
lb = group_centre(np.log2(cb + 1), gb)
|
| 206 |
+
ls = group_centre(np.log2(cs + 1), gs)
|
| 207 |
+
lb, ls = lb - lb.mean(0), ls - ls.mean(0)
|
| 208 |
+
den = np.sqrt((lb ** 2).sum(0) * (ls ** 2).sum(0))
|
| 209 |
+
r = np.divide((lb * ls).sum(0), den, out=np.zeros(len(gene_ids)), where=den > 0)
|
| 210 |
+
n = len(bi)
|
| 211 |
+
w = np.sqrt(n - 3)
|
| 212 |
+
zsum += w * np.arctanh(np.clip(r, -0.999, 0.999)); wsum += w
|
| 213 |
+
per[c.name] = (r, n)
|
| 214 |
+
z = np.where(ok, zsum / wsum, -np.inf)
|
| 215 |
+
order = np.argsort(-z)
|
| 216 |
+
rows = []
|
| 217 |
+
for rank, j in enumerate(order[:max(G_SENS + (G_PRIMARY,))], 1):
|
| 218 |
+
rec = {"rank": rank, "gene_id": gene_ids[j], "gene_symbol": sym[j], "fisher_z": float(z[j])}
|
| 219 |
+
for name, (r, n) in per.items():
|
| 220 |
+
rec[f"r_{name}"] = float(r[j]); rec[f"n_{name}"] = n
|
| 221 |
+
rows.append(rec)
|
| 222 |
+
return pd.DataFrame(rows)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def score(B, BV, S, SV, gidx, groups_b, groups_s) -> np.ndarray:
|
| 226 |
+
if not (BV[:, gidx].all() and SV[:, gidx].all()):
|
| 227 |
+
raise SystemExit("an identity gene is not measured in some row")
|
| 228 |
+
lb = group_centre(np.log2(cpm(B)[:, gidx] + 1), groups_b)
|
| 229 |
+
ls = group_centre(np.log2(cpm(S)[:, gidx] + 1), groups_s)
|
| 230 |
+
lb, ls = lb - lb.mean(0), ls - ls.mean(0)
|
| 231 |
+
return pearson(lb, ls)
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
STATS = ("margin_z", "r_best", "dc_margin")
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def calls(R: np.ndarray):
|
| 238 |
+
"""Per sc column, for every statistic: best bulk, mutual-best flag and statistic value."""
|
| 239 |
+
z = (R - R.mean(0)) / R.std(0)
|
| 240 |
+
D = R - R.mean(1, keepdims=True) - R.mean(0, keepdims=True) + R.mean()
|
| 241 |
+
out = []
|
| 242 |
+
for s in range(R.shape[1]):
|
| 243 |
+
o = np.argsort(-R[:, s])
|
| 244 |
+
od = np.argsort(-D[:, s])
|
| 245 |
+
mutual = bool(np.argmax(R[o[0]]) == s)
|
| 246 |
+
rec = {"sc": s, "r_best": float(R[o[0], s]), "r_second": float(R[o[1], s]), "second": int(o[1])}
|
| 247 |
+
rec["margin_z"] = {"best": int(o[0]), "mutual": mutual, "value": float(z[o[0], s] - z[o[1], s])}
|
| 248 |
+
rec["r_best_stat"] = {"best": int(o[0]), "mutual": mutual, "value": float(R[o[0], s])}
|
| 249 |
+
rec["dc_margin"] = {"best": int(od[0]), "mutual": bool(np.argmax(D[od[0]]) == s),
|
| 250 |
+
"value": float(D[od[0], s] - D[od[1], s])}
|
| 251 |
+
out.append(rec)
|
| 252 |
+
return out
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
def stat(rec: dict, name: str) -> dict:
|
| 256 |
+
return rec["r_best_stat"] if name == "r_best" else rec[name]
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
def calibrate(c: Cohort, gsets: dict, draws: int, rng) -> pd.DataFrame:
|
| 260 |
+
cfg = c.cfg
|
| 261 |
+
d = cfg["design"]
|
| 262 |
+
first = c.pairs.groupby("donor_id", sort=True).head(1) # one pair per donor
|
| 263 |
+
case = first[first.group.isin(cfg["case"])].index.to_numpy()
|
| 264 |
+
ctrl = first[first.group.isin(cfg["ctrl"])].index.to_numpy()
|
| 265 |
+
need_case, need_ctrl = d["case_bulk"] + d["case_sc"] - d["shared"], d["ctrl_bulk"] + d["ctrl_sc"]
|
| 266 |
+
if len(case) < need_case or len(ctrl) < need_ctrl:
|
| 267 |
+
raise SystemExit(f"{c.name}: design needs {need_case}/{need_ctrl} donors, has {len(case)}/{len(ctrl)}")
|
| 268 |
+
rows = []
|
| 269 |
+
for it in range(draws):
|
| 270 |
+
dc = rng.choice(case, need_case, replace=False)
|
| 271 |
+
dk = rng.choice(ctrl, need_ctrl, replace=False)
|
| 272 |
+
bulk = np.concatenate([dc[:d["case_bulk"]], dk[:d["ctrl_bulk"]]])
|
| 273 |
+
sc = np.concatenate([dc[:d["shared"]], dc[d["case_bulk"]:], dk[d["ctrl_bulk"]:]])
|
| 274 |
+
gb = ["case"] * d["case_bulk"] + ["ctrl"] * d["ctrl_bulk"]
|
| 275 |
+
gs = ["case"] * d["case_sc"] + ["ctrl"] * d["ctrl_sc"]
|
| 276 |
+
truth = {j: (list(bulk).index(x) if x in set(bulk) else -1) for j, x in enumerate(sc)}
|
| 277 |
+
for gname, gidx in gsets.items():
|
| 278 |
+
R = score(c.B[bulk], c.BV[bulk], c.S[sc], c.SV[sc], gidx, gb, gs)
|
| 279 |
+
for k in calls(R):
|
| 280 |
+
tb = truth[k["sc"]]
|
| 281 |
+
for st in STATS:
|
| 282 |
+
v = stat(k, st)
|
| 283 |
+
rows.append({"cohort": c.name, "genes": gname, "stat": st, "draw": it, "sc_slot": k["sc"],
|
| 284 |
+
"shared": tb >= 0, "best_is_true": bool(tb >= 0 and v["best"] == tb),
|
| 285 |
+
"mutual": v["mutual"], "value": v["value"], "r_best": k["r_best"]})
|
| 286 |
+
return pd.DataFrame(rows)
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
def rule_table(df: pd.DataFrame) -> pd.DataFrame:
|
| 290 |
+
out = []
|
| 291 |
+
for (cohort, genes, st), g in df.groupby(["cohort", "genes", "stat"]):
|
| 292 |
+
cand = g[g.mutual]
|
| 293 |
+
wrong = cand[~cand.best_is_true].value.to_numpy() # non-shared sc called, or shared on the wrong bulk
|
| 294 |
+
right = cand[cand.best_is_true].value.to_numpy()
|
| 295 |
+
n_cols = len(g)
|
| 296 |
+
thr = np.inf
|
| 297 |
+
for m in np.sort(np.concatenate([wrong, right])):
|
| 298 |
+
if (wrong >= m).sum() / n_cols <= FALSE_CALL_MAX:
|
| 299 |
+
thr = float(m)
|
| 300 |
+
break
|
| 301 |
+
sh = g[g.shared].assign(ok=lambda x: x.best_is_true & x.mutual & (x.value >= thr))
|
| 302 |
+
out.append({"cohort": cohort, "genes": genes, "stat": st, "threshold": thr,
|
| 303 |
+
"sensitivity": float(sh.ok.mean()), "wrong_call_rate": float((wrong >= thr).sum() / n_cols),
|
| 304 |
+
"draws_with_any_wrong_call": float(cand[~cand.best_is_true & (cand.value >= thr)].draw.nunique()
|
| 305 |
+
/ g.draw.nunique()),
|
| 306 |
+
"top1_true_rate_shared": float(g[g.shared].best_is_true.mean()),
|
| 307 |
+
"mutual_true_rate_shared": float((g[g.shared].best_is_true & g[g.shared].mutual).mean()),
|
| 308 |
+
"all_3_called_rate": float(sh.groupby("draw").ok.all().mean()), "draws": int(g.draw.nunique())})
|
| 309 |
+
return pd.DataFrame(out)
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
def main() -> int:
|
| 313 |
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 314 |
+
ap.add_argument("--draws", type=int, default=1000)
|
| 315 |
+
a = ap.parse_args()
|
| 316 |
+
OUT.mkdir(parents=True, exist_ok=True)
|
| 317 |
+
canon = pd.read_csv(REF, sep="\t", dtype=str)
|
| 318 |
+
gene_ids = canon.gene_id.to_numpy().astype(str)
|
| 319 |
+
sym = canon.gene_symbol.to_numpy().astype(str)
|
| 320 |
+
chr_y = canon.chromosome.astype(str).isin(["Y", "chrY"]).to_numpy()
|
| 321 |
+
sexl = set(pd.read_csv(SEXLIST).gene_id.astype(str))
|
| 322 |
+
exclude = chr_y | np.isin(gene_ids, list(sexl))
|
| 323 |
+
pos = {g: i for i, g in enumerate(gene_ids)}
|
| 324 |
+
coh = {n: Cohort(n, gene_ids) for n in COHORTS}
|
| 325 |
+
print({n: len(c.pairs) for n, c in coh.items()}, flush=True)
|
| 326 |
+
|
| 327 |
+
# ---------------- 1. identity genes (never from the cohort they are tested on, never from Behçet)
|
| 328 |
+
tables = {"all4": learn_identity_genes([coh[n] for n in LEARN], exclude, gene_ids, sym),
|
| 329 |
+
"no_liu": learn_identity_genes([coh[n] for n in LEARN if n != "liu2021"], exclude, gene_ids, sym)}
|
| 330 |
+
for k, t in tables.items():
|
| 331 |
+
t.to_csv(OUT / f"identity_genes_{k}.csv", index=False)
|
| 332 |
+
print(tables["all4"].head(30)[["rank", "gene_symbol", "fisher_z"] + [c for c in tables["all4"] if c.startswith("r_")]]
|
| 333 |
+
.round(3).to_string(index=False), flush=True)
|
| 334 |
+
|
| 335 |
+
def gsets(t):
|
| 336 |
+
return {f"G{G}": np.array([pos[g] for g in t.gene_id[:G]]) for G in (G_PRIMARY,) + G_SENS}
|
| 337 |
+
|
| 338 |
+
# ---------------- 2. calibration (before Behçet is scored)
|
| 339 |
+
rng = np.random.default_rng(SEED)
|
| 340 |
+
cal = pd.concat([calibrate(coh[n], gsets(tables[t]), a.draws, rng) for n, t in TESTS.items()], ignore_index=True)
|
| 341 |
+
cal.to_csv(OUT / "calibration_draws.csv.gz", index=False)
|
| 342 |
+
rt = rule_table(cal)
|
| 343 |
+
rt.to_csv(OUT / "calibration_summary.csv", index=False)
|
| 344 |
+
print(rt.round(4).to_string(index=False), flush=True)
|
| 345 |
+
sep = rt[rt.cohort == "ye2026_sepsis"].sort_values(["sensitivity", "draws_with_any_wrong_call"],
|
| 346 |
+
ascending=[False, True])
|
| 347 |
+
prim = sep.iloc[0]
|
| 348 |
+
liu = rt[(rt.cohort == "liu2021") & (rt.genes == prim.genes) & (rt.stat == prim.stat)].iloc[0]
|
| 349 |
+
rule = {"identity_genes": f"identity_genes_all4.csv top {prim.genes[1:]}", "genes": prim.genes, "stat": prim.stat,
|
| 350 |
+
"threshold": float(prim.threshold), "rule": f"mutual best and {prim.stat} >= threshold",
|
| 351 |
+
"selected_by": "highest sensitivity on ye2026_sepsis at <= 1 % wrong calls per sc column (all 9 "
|
| 352 |
+
"statistic x gene-set combinations in calibration_summary.csv)",
|
| 353 |
+
"sepsis": prim.to_dict(), "liu2021_replication": liu.to_dict(),
|
| 354 |
+
"false_call_max_per_sc_column": FALSE_CALL_MAX, "draws": a.draws, "seed": SEED,
|
| 355 |
+
"frozen_before_final_behcet_scoring": True, "ages_used": False,
|
| 356 |
+
"note": "margin_z / G100 was the first rule; the first 50-draw test of v2 also printed Behçet scores. "
|
| 357 |
+
"r_best and dc_margin were added afterwards; the choice is made on the controls only."}
|
| 358 |
+
(OUT / "RULE.json").write_text(json.dumps(rule, indent=1, default=float) + "\n")
|
| 359 |
+
|
| 360 |
+
# ---------------- 3. Behçet, blind to ages
|
| 361 |
+
B, BV, blab, _, bgenes = load_bulk(BEHCET_BULK)
|
| 362 |
+
if list(bgenes) != list(gene_ids):
|
| 363 |
+
raise SystemExit("behcet: bulk gene order")
|
| 364 |
+
inv = pd.read_csv(BEHCET_INV)
|
| 365 |
+
inv = inv[inv.source_name == "human PBMC"].sort_values("title")
|
| 366 |
+
sc_ids, sc_lab = inv.gsm.tolist(), inv.title.tolist()
|
| 367 |
+
S, SV, ncell = load_sc(BEHCET_SC, sc_ids, gene_ids)
|
| 368 |
+
gb = ["BD" if x.startswith("BD") else "HC" for x in blab]
|
| 369 |
+
gs = ["BD" if "_BD_" in x else "HC" for x in sc_lab]
|
| 370 |
+
ycpm = lambda m: m[:, chr_y].sum(1) / m.sum(1) * 1e6
|
| 371 |
+
pd.concat([pd.DataFrame({"sample": blab, "modality": "bulk", "group": gb, "chrY_cpm": ycpm(B)}),
|
| 372 |
+
pd.DataFrame({"sample": sc_lab, "modality": "sc", "group": gs, "chrY_cpm": ycpm(S), "cells": ncell})]
|
| 373 |
+
).to_csv(OUT / "sex_check.csv", index=False)
|
| 374 |
+
rows, Rs = [], {}
|
| 375 |
+
for gname, gidx in gsets(tables["all4"]).items():
|
| 376 |
+
R = score(B, BV, S, SV, gidx, gb, gs)
|
| 377 |
+
Rs[gname] = R
|
| 378 |
+
pd.DataFrame(R, index=blab, columns=sc_lab).to_csv(OUT / f"behcet_scores_{gname}.csv")
|
| 379 |
+
for st in STATS:
|
| 380 |
+
thr = float(rt[(rt.cohort == "ye2026_sepsis") & (rt.genes == gname) & (rt.stat == st)].threshold.iloc[0])
|
| 381 |
+
for k in calls(R):
|
| 382 |
+
v = stat(k, st)
|
| 383 |
+
rows.append({"genes": gname, "stat": st, "primary": gname == rule["genes"] and st == rule["stat"],
|
| 384 |
+
"sc_sample": sc_lab[k["sc"]], "best_bulk": blab[v["best"]], "r_best": k["r_best"],
|
| 385 |
+
"r_second": k["r_second"], "mutual": v["mutual"], "value": v["value"], "threshold": thr,
|
| 386 |
+
"called": bool(v["mutual"] and v["value"] >= thr),
|
| 387 |
+
"sc_chrY_cpm": float(ycpm(S)[k["sc"]])})
|
| 388 |
+
cl = pd.DataFrame(rows)
|
| 389 |
+
cl.to_csv(OUT / "behcet_calls.csv", index=False)
|
| 390 |
+
# per-gene evidence for every sc sample's best bulk (primary gene set): log2 CPM in both, and on/off flags
|
| 391 |
+
gidx = gsets(tables["all4"])[rule["genes"]]
|
| 392 |
+
lb, ls = np.log2(cpm(B)[:, gidx] + 1), np.log2(cpm(S)[:, gidx] + 1)
|
| 393 |
+
ev = []
|
| 394 |
+
for _, r in cl[cl.primary].iterrows():
|
| 395 |
+
b, s = list(blab).index(r.best_bulk), sc_lab.index(r.sc_sample)
|
| 396 |
+
for jj, j in enumerate(gidx):
|
| 397 |
+
ev.append({"sc_sample": r.sc_sample, "best_bulk": r.best_bulk, "gene": sym[j], "gene_id": gene_ids[j],
|
| 398 |
+
"bulk_log2cpm": float(lb[b, jj]), "sc_log2cpm": float(ls[s, jj]),
|
| 399 |
+
"bulk_rank_among_19": int((lb[:, jj] > lb[b, jj]).sum() + 1),
|
| 400 |
+
"sc_rank_among_8": int((ls[:, jj] > ls[s, jj]).sum() + 1)})
|
| 401 |
+
pd.DataFrame(ev).to_csv(OUT / "behcet_gene_evidence.csv", index=False)
|
| 402 |
+
summary = {"rule": rule, "behcet_calls_primary": cl[cl.primary].to_dict("records"),
|
| 403 |
+
"behcet_negative_control": "sc samples with chrY CPM < 10 (female) must not be called: " + json.dumps(
|
| 404 |
+
cl[cl.primary & (cl.sc_chrY_cpm < 10)][["sc_sample", "called"]].to_dict("records")),
|
| 405 |
+
"inputs": {"behcet_bulk": str(BEHCET_BULK), "behcet_bulk_sha256": sha(BEHCET_BULK),
|
| 406 |
+
"behcet_sc": {l: str(BEHCET_SC / g) for g, l in zip(sc_ids, sc_lab)},
|
| 407 |
+
"pairs": {n: str(PAIRDATA / n / "pairs.csv") for n in COHORTS},
|
| 408 |
+
"sex_linked_exclusion": str(SEXLIST)},
|
| 409 |
+
"n_pairs_identity_pass": {n: len(c.pairs) for n, c in coh.items()},
|
| 410 |
+
"code_sha256": sha(Path(__file__)), "ages_used": False}
|
| 411 |
+
(OUT / "SUMMARY.json").write_text(json.dumps(summary, indent=1, default=str) + "\n")
|
| 412 |
+
with pd.option_context("display.width", 200):
|
| 413 |
+
print(cl.round(3).to_string(index=False))
|
| 414 |
+
return 0
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
if __name__ == "__main__":
|
| 418 |
+
sys.exit(main())
|
paper-releases/pbisc-diffusion/updates/20261004T003810Z-behcet-pair-recovery/diffusion/dataset/server_1/model8/plans/behcet_pair_recovery_20261004/tools/unblind_ages.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""After tools/recover_pairs.py: compare the blind expression calls with the published ages (CPU only).
|
| 3 |
+
|
| 4 |
+
Ages / sex are read from GEO: bulk GSE198533 series matrix (age, Sex per sample title) and sc GSE198616_sample_info.csv.gz
|
| 5 |
+
(Age, Sex per Sample_name). They were not used to make the calls; here they are only an independent check.
|
| 6 |
+
Also writes the per-rule agreement of the three BD calls and a short gene-level view of each match.
|
| 7 |
+
Outputs (<plan>/out/): unblind_ages.csv (one row per sc sample: every rule's best bulk, call counts, ages, sex by chrY),
|
| 8 |
+
rule_agreement.csv, match_gene_view.csv
|
| 9 |
+
"""
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import gzip
|
| 13 |
+
import json
|
| 14 |
+
import re
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
|
| 17 |
+
import numpy as np
|
| 18 |
+
import pandas as pd
|
| 19 |
+
|
| 20 |
+
PLAN = Path(__file__).resolve().parents[1]
|
| 21 |
+
OUT = PLAN / "out"
|
| 22 |
+
DS = Path("/home/sj_server_1/gblee/datalake/paired-pbmc-bulk-sc/datasets")
|
| 23 |
+
BULK_META = DS / "GSE198533/metadata/GSE198533_series_matrix.txt.gz"
|
| 24 |
+
SC_META = DS / "GSE198616/raw/GSE198616_sample_info.csv.gz"
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def bulk_meta() -> pd.DataFrame:
|
| 28 |
+
rows = {}
|
| 29 |
+
with gzip.open(BULK_META, "rt") as f:
|
| 30 |
+
for line in f:
|
| 31 |
+
if line.startswith("!Sample_title"):
|
| 32 |
+
rows["title"] = [x.strip('"') for x in line.rstrip("\n").split("\t")[1:]]
|
| 33 |
+
elif line.startswith("!Sample_geo_accession"):
|
| 34 |
+
rows["geo_accession"] = [x.strip('"') for x in line.rstrip("\n").split("\t")[1:]]
|
| 35 |
+
elif line.startswith("!Sample_characteristics_ch1"):
|
| 36 |
+
vals = [x.strip('"') for x in line.rstrip("\n").split("\t")[1:]]
|
| 37 |
+
key = vals[0].split(":")[0].strip().lower()
|
| 38 |
+
rows[key] = [v.split(":", 1)[1].strip() for v in vals]
|
| 39 |
+
m = pd.DataFrame(rows).set_index("title")
|
| 40 |
+
return m.rename(columns={"age": "bulk_age", "sex": "bulk_sex_geo"})
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def main() -> int:
|
| 44 |
+
cl = pd.read_csv(OUT / "behcet_calls.csv")
|
| 45 |
+
rule = json.loads((OUT / "RULE.json").read_text())
|
| 46 |
+
bm = bulk_meta()
|
| 47 |
+
sm = pd.read_csv(SC_META).set_index("Sample_name")
|
| 48 |
+
sex = pd.read_csv(OUT / "sex_check.csv")
|
| 49 |
+
sc_y = sex[sex.modality == "sc"].set_index("sample").chrY_cpm
|
| 50 |
+
rows = []
|
| 51 |
+
for s, g in cl.groupby("sc_sample", sort=True):
|
| 52 |
+
prim = g[g.primary].iloc[0]
|
| 53 |
+
bests = g.best_bulk.value_counts()
|
| 54 |
+
top = bests.index[0]
|
| 55 |
+
rec = {"sc_sample": s, "sc_age": int(sm.loc[s, "Age"]), "sc_sex_geo": sm.loc[s, "Sex"],
|
| 56 |
+
"sc_sex_chrY": "male" if sc_y[s] > 100 else "female" if sc_y[s] < 10 else "ambiguous",
|
| 57 |
+
"most_frequent_best_bulk": top, "rules_with_this_best": int(bests.iloc[0]), "rules": len(g),
|
| 58 |
+
"rules_mutual_with_this_best": int(((g.best_bulk == top) & g.mutual).sum()),
|
| 59 |
+
"rules_calling_it": int(((g.best_bulk == top) & g.called).sum()),
|
| 60 |
+
"primary_rule_called": bool(prim.called), "primary_r_best": float(prim.r_best),
|
| 61 |
+
"primary_threshold": float(prim.threshold),
|
| 62 |
+
"best_bulk_age": int(bm.loc[top, "bulk_age"]), "best_bulk_sex_geo": bm.loc[top, "bulk_sex_geo"]}
|
| 63 |
+
rec["age_equal"] = rec["sc_age"] == rec["best_bulk_age"]
|
| 64 |
+
same_age = bm.index[bm.bulk_age.astype(int) == rec["sc_age"]].tolist()
|
| 65 |
+
rec["bulk_samples_with_same_age"] = ";".join(same_age)
|
| 66 |
+
rows.append(rec)
|
| 67 |
+
u = pd.DataFrame(rows)
|
| 68 |
+
u.to_csv(OUT / "unblind_ages.csv", index=False)
|
| 69 |
+
agg = cl.groupby(["genes", "stat"]).apply(
|
| 70 |
+
lambda g: pd.Series({"called": ";".join(f"{r.sc_sample}->{r.best_bulk}" for r in g.itertuples() if r.called)}),
|
| 71 |
+
include_groups=False).reset_index()
|
| 72 |
+
agg.to_csv(OUT / "rule_agreement.csv", index=False)
|
| 73 |
+
# gene view: identity genes where the matched bulk and sc are both at an extreme of their modality
|
| 74 |
+
ev = pd.read_csv(OUT / "behcet_gene_evidence.csv")
|
| 75 |
+
called = u[u.rules_calling_it > 0][["sc_sample", "most_frequent_best_bulk"]]
|
| 76 |
+
gv = ev.merge(called, left_on=["sc_sample", "best_bulk"], right_on=["sc_sample", "most_frequent_best_bulk"])
|
| 77 |
+
gv = gv[((gv.bulk_rank_among_19 <= 2) & (gv.sc_rank_among_8 == 1)) |
|
| 78 |
+
((gv.bulk_rank_among_19 >= 18) & (gv.sc_rank_among_8 == 8))]
|
| 79 |
+
gv[["sc_sample", "best_bulk", "gene", "bulk_log2cpm", "sc_log2cpm", "bulk_rank_among_19", "sc_rank_among_8"]] \
|
| 80 |
+
.to_csv(OUT / "match_gene_view.csv", index=False)
|
| 81 |
+
# chance that blind calls land on a same-age bulk for every called sc sample, if bulks were picked at random
|
| 82 |
+
hits = u[u.rules_calling_it > 0]
|
| 83 |
+
hits = hits[hits.sc_sex_chrY == "male"]
|
| 84 |
+
p_chance = float(np.prod([len(h.split(";")) / len(bm) for h in hits.bulk_samples_with_same_age]))
|
| 85 |
+
# recovered pairs: GSMs from the GEO tables; tier from the evidence
|
| 86 |
+
gsm_b = dict(zip(bm.index, bm["geo_accession"])) if "geo_accession" in bm else {}
|
| 87 |
+
inv = pd.read_csv("/home/sj_server_1/gblee/datalake/paired-pbmc-bulk-sc/processing/strict_qc_v1_20260913/"
|
| 88 |
+
"pairing_audit/GSE198616_published_sample_inventory.csv").set_index("title").gsm
|
| 89 |
+
pr = []
|
| 90 |
+
for r in u.itertuples():
|
| 91 |
+
if r.rules_calling_it == 0 or r.sc_sex_chrY != "male":
|
| 92 |
+
continue
|
| 93 |
+
tier = ("expression_identity_called_by_primary_rule+age_equal" if r.primary_rule_called and r.age_equal else
|
| 94 |
+
"expression_best_and_mutual_in_all_rules+age_equal" if r.rules_mutual_with_this_best == r.rules and
|
| 95 |
+
r.age_equal else "unresolved")
|
| 96 |
+
pr.append({"sc_sample": r.sc_sample, "sc_gsm": inv[r.sc_sample], "bulk_sample": r.most_frequent_best_bulk,
|
| 97 |
+
"bulk_gsm": gsm_b.get(r.most_frequent_best_bulk, ""), "age": r.sc_age,
|
| 98 |
+
"rules_calling_it": r.rules_calling_it, "rules": r.rules, "primary_rule_called": r.primary_rule_called,
|
| 99 |
+
"primary_r_best": r.primary_r_best, "tier": tier})
|
| 100 |
+
pd.DataFrame(pr).to_csv(OUT / "pairs_recovered.csv", index=False)
|
| 101 |
+
(OUT / "UNBLIND.json").write_text(json.dumps({"p_same_age_by_chance": p_chance, "pairs": pr}, indent=1) + "\n")
|
| 102 |
+
with pd.option_context("display.width", 220):
|
| 103 |
+
print(u.to_string(index=False))
|
| 104 |
+
print(pd.DataFrame(pr).to_string(index=False), "\nP(all same-age by chance) =", p_chance)
|
| 105 |
+
print(agg.to_string(index=False))
|
| 106 |
+
print(gv.groupby("sc_sample").gene.apply(lambda x: ", ".join(x)).to_string())
|
| 107 |
+
print("primary rule:", rule["genes"], rule["stat"], rule["threshold"])
|
| 108 |
+
return 0
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
if __name__ == "__main__":
|
| 112 |
+
raise SystemExit(main())
|
paper-releases/pbisc-diffusion/updates/20261004T003810Z-behcet-pair-recovery/diffusion/metadata/request.json
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"assets": [
|
| 3 |
+
{
|
| 4 |
+
"host": "server_1",
|
| 5 |
+
"kind": "document",
|
| 6 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/README.md",
|
| 7 |
+
"state": "completed"
|
| 8 |
+
},
|
| 9 |
+
{
|
| 10 |
+
"host": "server_1",
|
| 11 |
+
"kind": "log",
|
| 12 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/logs/unblind_ages.log",
|
| 13 |
+
"state": "completed"
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"host": "server_1",
|
| 17 |
+
"kind": "log",
|
| 18 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/logs/v2_draws1000.log",
|
| 19 |
+
"state": "completed"
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"host": "server_1",
|
| 23 |
+
"kind": "log",
|
| 24 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/logs/v2_test_draws50.log",
|
| 25 |
+
"state": "completed"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"host": "server_1",
|
| 29 |
+
"kind": "metadata",
|
| 30 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/RULE.json",
|
| 31 |
+
"state": "completed"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"host": "server_1",
|
| 35 |
+
"kind": "metadata",
|
| 36 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/SUMMARY.json",
|
| 37 |
+
"state": "completed"
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"host": "server_1",
|
| 41 |
+
"kind": "metadata",
|
| 42 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/UNBLIND.json",
|
| 43 |
+
"state": "completed"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"host": "server_1",
|
| 47 |
+
"kind": "metadata",
|
| 48 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/RULE.json",
|
| 49 |
+
"state": "completed"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"host": "server_1",
|
| 53 |
+
"kind": "metadata",
|
| 54 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/SUMMARY.json",
|
| 55 |
+
"state": "completed"
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"host": "server_1",
|
| 59 |
+
"kind": "table",
|
| 60 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/behcet_calls.csv",
|
| 61 |
+
"state": "completed"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"host": "server_1",
|
| 65 |
+
"kind": "table",
|
| 66 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/behcet_onoff_scores.csv",
|
| 67 |
+
"state": "completed"
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"host": "server_1",
|
| 71 |
+
"kind": "table",
|
| 72 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/behcet_scores_k0.csv",
|
| 73 |
+
"state": "completed"
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"host": "server_1",
|
| 77 |
+
"kind": "table",
|
| 78 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/behcet_scores_k1.csv",
|
| 79 |
+
"state": "completed"
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"host": "server_1",
|
| 83 |
+
"kind": "table",
|
| 84 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/behcet_scores_k2.csv",
|
| 85 |
+
"state": "completed"
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"host": "server_1",
|
| 89 |
+
"kind": "table",
|
| 90 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/behcet_scores_k3.csv",
|
| 91 |
+
"state": "completed"
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"host": "server_1",
|
| 95 |
+
"kind": "table",
|
| 96 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/behcet_top_genes.csv",
|
| 97 |
+
"state": "completed"
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"host": "server_1",
|
| 101 |
+
"kind": "table",
|
| 102 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/calibration_draws.csv.gz",
|
| 103 |
+
"state": "completed"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"host": "server_1",
|
| 107 |
+
"kind": "table",
|
| 108 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/calibration_summary.csv",
|
| 109 |
+
"state": "completed"
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"host": "server_1",
|
| 113 |
+
"kind": "code",
|
| 114 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/recover_pairs_v1.py",
|
| 115 |
+
"state": "completed"
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"host": "server_1",
|
| 119 |
+
"kind": "code",
|
| 120 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/recover_pairs_v2a_margin_only.py",
|
| 121 |
+
"state": "completed"
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"host": "server_1",
|
| 125 |
+
"kind": "table",
|
| 126 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/sex_check.csv",
|
| 127 |
+
"state": "completed"
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"host": "server_1",
|
| 131 |
+
"kind": "log",
|
| 132 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/test_draws20.log",
|
| 133 |
+
"state": "completed"
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"host": "server_1",
|
| 137 |
+
"kind": "log",
|
| 138 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/_v1_resid_test/v2_test_draws50.log",
|
| 139 |
+
"state": "completed"
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"host": "server_1",
|
| 143 |
+
"kind": "table",
|
| 144 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/behcet_calls.csv",
|
| 145 |
+
"state": "completed"
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"host": "server_1",
|
| 149 |
+
"kind": "table",
|
| 150 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/behcet_gene_evidence.csv",
|
| 151 |
+
"state": "completed"
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"host": "server_1",
|
| 155 |
+
"kind": "table",
|
| 156 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/behcet_scores_G100.csv",
|
| 157 |
+
"state": "completed"
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"host": "server_1",
|
| 161 |
+
"kind": "table",
|
| 162 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/behcet_scores_G200.csv",
|
| 163 |
+
"state": "completed"
|
| 164 |
+
},
|
| 165 |
+
{
|
| 166 |
+
"host": "server_1",
|
| 167 |
+
"kind": "table",
|
| 168 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/behcet_scores_G50.csv",
|
| 169 |
+
"state": "completed"
|
| 170 |
+
},
|
| 171 |
+
{
|
| 172 |
+
"host": "server_1",
|
| 173 |
+
"kind": "table",
|
| 174 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/calibration_draws.csv.gz",
|
| 175 |
+
"state": "completed"
|
| 176 |
+
},
|
| 177 |
+
{
|
| 178 |
+
"host": "server_1",
|
| 179 |
+
"kind": "table",
|
| 180 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/calibration_summary.csv",
|
| 181 |
+
"state": "completed"
|
| 182 |
+
},
|
| 183 |
+
{
|
| 184 |
+
"host": "server_1",
|
| 185 |
+
"kind": "table",
|
| 186 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/identity_genes_all4.csv",
|
| 187 |
+
"state": "completed"
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"host": "server_1",
|
| 191 |
+
"kind": "table",
|
| 192 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/identity_genes_no_liu.csv",
|
| 193 |
+
"state": "completed"
|
| 194 |
+
},
|
| 195 |
+
{
|
| 196 |
+
"host": "server_1",
|
| 197 |
+
"kind": "table",
|
| 198 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/match_gene_view.csv",
|
| 199 |
+
"state": "completed"
|
| 200 |
+
},
|
| 201 |
+
{
|
| 202 |
+
"host": "server_1",
|
| 203 |
+
"kind": "table",
|
| 204 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/pairs_recovered.csv",
|
| 205 |
+
"state": "completed"
|
| 206 |
+
},
|
| 207 |
+
{
|
| 208 |
+
"host": "server_1",
|
| 209 |
+
"kind": "table",
|
| 210 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/rule_agreement.csv",
|
| 211 |
+
"state": "completed"
|
| 212 |
+
},
|
| 213 |
+
{
|
| 214 |
+
"host": "server_1",
|
| 215 |
+
"kind": "table",
|
| 216 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/sex_check.csv",
|
| 217 |
+
"state": "completed"
|
| 218 |
+
},
|
| 219 |
+
{
|
| 220 |
+
"host": "server_1",
|
| 221 |
+
"kind": "table",
|
| 222 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/out/unblind_ages.csv",
|
| 223 |
+
"state": "completed"
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"host": "server_1",
|
| 227 |
+
"kind": "code",
|
| 228 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/tools/recover_pairs.py",
|
| 229 |
+
"state": "completed"
|
| 230 |
+
},
|
| 231 |
+
{
|
| 232 |
+
"host": "server_1",
|
| 233 |
+
"kind": "code",
|
| 234 |
+
"source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/behcet_pair_recovery_20261004/tools/unblind_ages.py",
|
| 235 |
+
"state": "completed"
|
| 236 |
+
}
|
| 237 |
+
],
|
| 238 |
+
"inference_locations": [],
|
| 239 |
+
"project_id": "pbisc-diffusion",
|
| 240 |
+
"summary": "Behçet (Zheng 2022) bulk-sc pair recovery for the Behçet C1Q-high utility study (plans/behcet_pair_recovery_20261004, CPU only, 2026-10-04): identity genes learnt from cross-timepoint pairs of Imperial/Liu/Ji/Giroux, decision rule calibrated on Behçet-shaped draws of Ye 2026 sepsis (held out) and Liu 2021 (held out from its gene set), Behçet scored blind to ages. Result: 3 BD pairs (PBMC_BD_2-BDV4, PBMC_BD_3-BDV5, PBMC_BD_4-BDV6), all age-equal after unblinding; no HC pair (two sc HC are female by chrY, the bulk is all male). Code, README, outputs, logs and the superseded v1 test record. Inputs (datalake processing outputs and pairs.csv tables) are read, not modified."
|
| 241 |
+
}
|