junidude14 commited on
Commit
b19762d
·
verified ·
1 Parent(s): 4455666

Archive 4 checkpoints (1-4)

Browse files
paper-releases/pbisc-diffusion/updates/20261015T131236Z-corpus-five-marker-codetection/diffusion/dataset/server_1/model8/plans/corpus_macrophage_markers_20261015/summary.csv ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ dataset,flagged,cells,samples,dataset_scoped_donors,C1QA_detected,C1QA_fraction,C1QA_mean_raw_counts,CD163_detected,CD163_fraction,CD163_mean_raw_counts,CD68_detected,CD68_fraction,CD68_mean_raw_counts,WARS1_detected,WARS1_fraction,WARS1_mean_raw_counts,LGALS3_detected,LGALS3_fraction,LGALS3_mean_raw_counts,exactly_0_detected,exactly_1_detected,exactly_2_detected,exactly_3_detected,exactly_4_detected,exactly_5_detected,all_five_detected,all_five_detected_samples,all_five_detected_dataset_scoped_donors,c1qa_plus_at_least_three_others,c1qa_plus_at_least_three_others_samples,c1qa_plus_at_least_three_others_dataset_scoped_donors
2
+ ALL,False,33219,1398,779,32958,0.9921430506637767,12.234684969445198,1818,0.05472771606610675,0.09467473433878203,32607,0.9815768084529938,6.9743520274541675,28867,0.8689906378879557,3.788584846021855,30962,0.932056955356874,5.272735482705681,10,62,532,5693,25603,1319,1319,580,204,26903,1384,765
3
+ 006,False,2726,439,439,2677,0.9820249449743214,11.379677182685253,7,0.0025678650036683784,0.003301540719002201,2724,0.9992663242846662,12.546955245781364,2664,0.9772560528246516,7.42516507703595,2555,0.9372707263389581,4.842993396918562,0,0,16,252,2451,7,7,5,5,2458,434,434
4
+ 009,False,3058,86,86,3032,0.9914977109221713,12.782210595160235,198,0.06474820143884892,0.1105297580117724,2992,0.9784172661870504,5.9905166775670375,2636,0.8620013080444735,3.287115761935906,2877,0.9408109875735775,5.497383911052975,1,7,49,514,2347,140,140,56,56,2483,86,86
5
+ 065,False,25268,696,77,25115,0.9939449105588095,12.456545828716163,1446,0.05722653158144689,0.09755421877473484,24774,0.9804495804970714,5.973563400348267,21482,0.8501662181415228,3.1704923223048915,23923,0.9467706189646984,5.553110653791356,4,38,425,4400,19353,1048,1048,451,75,20389,696,77
6
+ 200,False,2167,177,177,2134,0.9847715736040609,9.950622981079833,167,0.07706506691278264,0.15366866635902168,2117,0.9769266266728196,13.022150438394092,2085,0.9621596677434241,7.128749423165667,1607,0.7415782187355792,2.2270419935394554,5,17,42,527,1452,124,124,68,68,1573,168,168
7
+ ALL,True,903,351,351,899,0.9955703211517165,19.383167220376524,131,0.1450719822812846,0.2469545957918051,892,0.9878183831672204,10.091915836101883,851,0.9424141749723145,6.210409745293466,841,0.9313399778516057,5.904761904761905,0,1,4,96,693,109,109,86,86,801,339,339
8
+ 006,True,903,351,351,899,0.9955703211517165,19.383167220376524,131,0.1450719822812846,0.2469545957918051,892,0.9878183831672204,10.091915836101883,851,0.9424141749723145,6.210409745293466,841,0.9313399778516057,5.904761904761905,0,1,4,96,693,109,109,86,86,801,339,339
paper-releases/pbisc-diffusion/updates/20261015T131236Z-corpus-five-marker-codetection/diffusion/dataset/server_1/model8/plans/corpus_macrophage_markers_20261015/verify_candidates.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Independent physical-row, gene-axis, and direct sparse-row replay checks."""
3
+ from pathlib import Path
4
+ import argparse
5
+ import json
6
+ import numpy as np
7
+ import pandas as pd
8
+ import pyarrow.parquet as pq
9
+ import zarr
10
+ import h5py
11
+ from check_candidates import ROOT, M7, E2, BLOCK, GENES, IDS, COLS, receipt, write_json, sha
12
+
13
+ ap = argparse.ArgumentParser()
14
+ ap.add_argument('--selected-genes', required=True)
15
+ ap.add_argument('--training-config', required=True)
16
+ args = ap.parse_args()
17
+ v = pd.read_parquet(ROOT / 'candidate_marker_counts.parquet')
18
+ var = pd.read_parquet(E2 / 'metadata/var.parquet')
19
+ assert var.iloc[COLS].gene_id.tolist() == IDS
20
+ assert var.iloc[COLS].panel_index.tolist() == COLS.tolist()
21
+ assert var.iloc[COLS].gene_symbol.tolist() == ['C1QA', 'CD163', 'CD68', 'WARS', 'LGALS3']
22
+ sel = pd.read_csv(args.selected_genes)
23
+ assert set(IDS).issubset(set(sel.gene_id))
24
+ assert len(sel) == 6000 and not sel.gene_id.duplicated().any()
25
+ cfg = json.loads(Path(args.training_config).read_text())['data']
26
+ assert cfg['n_genes'] == 6000
27
+ assert sha(cfg['gene_selection_manifest']) == cfg['gene_selection_manifest_sha256']
28
+ assert sha(cfg['gene_positions_path']) == cfg['gene_positions_sha256']
29
+ manifest = json.loads(Path(cfg['gene_selection_manifest']).read_text())
30
+ assert Path(manifest['selected_genes_path']) == Path(args.selected_genes)
31
+ assert sha(args.selected_genes) == manifest['selected_genes_sha256']
32
+ assert np.array_equal(np.load(cfg['gene_positions_path']), sel.panel_position)
33
+ assert set(COLS).issubset(set(sel.panel_position))
34
+ assert var.iloc[sel.panel_position.to_numpy()].gene_id.tolist() == sel.gene_id.tolist()
35
+ physical_checks, direct_checks, raw_source_checks = [], [], []
36
+ first_by_dataset, boundary_by_dataset = set(), set()
37
+ raw_source_by_dataset = set()
38
+ for sid, d in v.groupby('shard_id', sort=True):
39
+ rows = d.shard_row.to_numpy()
40
+ ep = E2 / 'metadata/obs_sc.parquet' / (sid + '.parquet')
41
+ bp = BLOCK / 'metadata/obs_sc.parquet' / (sid + '.parquet')
42
+ e = pq.read_table(ep, columns=['row_index', 'source_row_index']).to_pandas()
43
+ b = pq.read_table(bp, columns=['row_index', 'source_row_index', 'shard_id']).to_pandas()
44
+ assert np.array_equal(e.iloc[rows].row_index, rows)
45
+ assert set(b.iloc[rows].shard_id) == {sid}
46
+ assert np.array_equal(e.iloc[rows].source_row_index, d.source_row_index)
47
+ assert np.array_equal(b.iloc[rows].source_row_index, d.source_row_index)
48
+ zp = BLOCK / 'counts/sc_counts' / (sid + '.zarr')
49
+ g = zarr.open_group(str(zp), mode='r')
50
+ assert g.attrs['shard_id'] == sid
51
+ assert g.attrs['shape'][0] == len(e) == len(b)
52
+ assert g.attrs['shape'][1] == len(var) == 20097
53
+ physical_checks.append({'shard_id': sid, 'selected_rows': len(d),
54
+ 'e2_row_index_equals_physical_row': True,
55
+ 'historical_source_row_index_is_not_csr_row': int((b.iloc[rows].row_index.to_numpy() != rows).sum()),
56
+ 'e2_and_historical_source_identity_match': True,
57
+ 'metadata_and_expression_shard_id_equal': True})
58
+ prefix = sid[:3]
59
+ chosen = set()
60
+ if prefix not in first_by_dataset:
61
+ chosen.update([d.index[0], d.index[-1]])
62
+ pos = d[d.all_five_detected]
63
+ if len(pos): chosen.add(pos.index[0])
64
+ first_by_dataset.add(prefix)
65
+ if prefix not in boundary_by_dataset:
66
+ ptr = np.asarray(g['indptr'][:])
67
+ boundary = (ptr[rows] // 1000000) != ((ptr[rows+1]-1) // 1000000)
68
+ if boundary.any():
69
+ chosen.add(d.index[np.flatnonzero(boundary)[0]])
70
+ boundary_by_dataset.add(prefix)
71
+ for ix in sorted(chosen):
72
+ r = v.loc[ix]
73
+ p = np.asarray(g['indptr'][int(r.shard_row):int(r.shard_row)+2])
74
+ a, b = int(p[0]), int(p[1])
75
+ indices = np.asarray(g['indices'][a:b])
76
+ vals = np.asarray(g['data'][a:b])
77
+ counts = np.array([vals[indices == j].sum() for j in COLS])
78
+ assert np.array_equal(counts, r[GENES].to_numpy(dtype=np.int64))
79
+ assert int(vals.sum()) == int(r.total_counts_20097)
80
+ direct_checks.append({'shard_id': sid, 'shard_row': int(r.shard_row),
81
+ 'five_counts': counts.tolist(), 'row_sum': int(vals.sum()),
82
+ 'crosses_chunk_boundary': a // 1000000 != (b-1) // 1000000})
83
+ if prefix not in raw_source_by_dataset:
84
+ hp = Path('/home/sj_server_1/gblee') / g.attrs['source_path']
85
+ with h5py.File(hp, 'r') as hf:
86
+ matrix_key = g.attrs['source_count_matrix']
87
+ vg = hf['raw/var' if matrix_key.startswith('raw/') else 'var']
88
+ raw_ids = [x.decode() if isinstance(x, bytes) else str(x) for x in vg[vg.attrs['_index']][:]]
89
+ assert len(raw_ids) == len(set(raw_ids))
90
+ rawpos = {gid: j for j, gid in enumerate(raw_ids)}
91
+ mx = hf[matrix_key]
92
+ assert mx.attrs['encoding-type'] == 'csr_matrix'
93
+ srcrow = int(r.source_row_index)
94
+ p = mx['indptr'][srcrow:srcrow+2]
95
+ ri, rv = mx['indices'][int(p[0]):int(p[1])], mx['data'][int(p[0]):int(p[1])]
96
+ rc = np.array([rv[ri == rawpos[gid]].sum() for gid in IDS])
97
+ assert np.array_equal(rc, counts)
98
+ canonical_positions = np.array([rawpos[gid] for gid in var.gene_id if gid in rawpos])
99
+ projected_sum = rv[np.isin(ri, canonical_positions)].sum()
100
+ assert projected_sum == int(r.total_counts_20097)
101
+ raw_source_checks.append({'path': str(hp), 'bytes': hp.stat().st_size, 'mtime_ns': hp.stat().st_mtime_ns,
102
+ 'source_matrix': matrix_key, 'source_row_index': srcrow,
103
+ 'shard_id': sid, 'shard_row': int(r.shard_row),
104
+ 'original_h5ad_five_counts': rc.tolist(), 'canonical_projected_sum': int(projected_sum),
105
+ 'five_counts_and_projected_sum_match': True})
106
+ raw_source_by_dataset.add(prefix)
107
+ assert len(physical_checks) == 69 and sum(x['selected_rows'] for x in physical_checks) == 34122
108
+ assert len(first_by_dataset) == 4
109
+ assert len(raw_source_by_dataset) == 4
110
+ assert len(direct_checks) >= 8
111
+ data = {'status': 'PASS', 'physical_row_alignment': physical_checks, 'independent_direct_row_replays': direct_checks,
112
+ 'original_h5ad_source_row_replays': raw_source_checks,
113
+ 'historical_row_index_note': 'BLOCK metadata retains original H5AD offsets after QC. E2 row_index resets to contiguous CSR row position; source_row_index is the shared identity join. Direct original-H5AD row replay confirms the projected five counts and total for one cell per dataset.',
114
+ 'gene_axis_raw_positions': COLS.tolist(), 'raw_gene_ids': IDS,
115
+ 'raw_gene_symbols': var.iloc[COLS].gene_symbol.tolist(),
116
+ 'sources': [receipt(E2 / 'metadata/var.parquet'), receipt(args.selected_genes), receipt(args.training_config),
117
+ receipt(cfg['gene_selection_manifest']), receipt(cfg['gene_positions_path']),
118
+ receipt(M7.parent / 'scripts/build_e2_full_source.py'),
119
+ receipt(M7.parent / 'scripts/prepare_e2_celltype_latent_analysis.py'),
120
+ receipt(ROOT / 'check_candidates.py'), receipt(ROOT / 'verify_candidates.py')]}
121
+ write_json(ROOT / 'INDEPENDENT_VERIFICATION.json', data)
122
+ r = json.loads((ROOT / 'RESULT.json').read_text())
123
+ r['independent_verification'] = receipt(ROOT / 'INDEPENDENT_VERIFICATION.json')
124
+ r['code'] = receipt(ROOT / 'check_candidates.py')
125
+ r['gene_axis_and_training_panel_sources'] = data['sources'][:5]
126
+ write_json(ROOT / 'RESULT.json', r)
127
+ print(json.dumps({'status': 'PASS', 'physical_rows_checked': len(v), 'shards': len(physical_checks),
128
+ 'direct_row_replays': len(direct_checks), 'boundary_datasets': sorted(boundary_by_dataset)}))
paper-releases/pbisc-diffusion/updates/20261015T131236Z-corpus-five-marker-codetection/diffusion/metadata/inference_locations.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "locations": [],
3
+ "project_id": "pbisc-diffusion",
4
+ "update_id": "20261015T131236Z-corpus-five-marker-codetection"
5
+ }
paper-releases/pbisc-diffusion/updates/20261015T131236Z-corpus-five-marker-codetection/diffusion/metadata/request.json ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "assets": [
3
+ {
4
+ "host": "server_1",
5
+ "kind": "report",
6
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/AGENTS.md",
7
+ "state": "completed"
8
+ },
9
+ {
10
+ "host": "server_1",
11
+ "kind": "report",
12
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/ara/trace/exploration_tree.yaml",
13
+ "state": "completed"
14
+ },
15
+ {
16
+ "host": "server_1",
17
+ "kind": "report",
18
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/ara/trace/pm_reasoning_log.yaml",
19
+ "state": "completed"
20
+ },
21
+ {
22
+ "host": "server_1",
23
+ "kind": "report",
24
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/ara/trace/sessions/2026-10-15_001.yaml",
25
+ "state": "completed"
26
+ },
27
+ {
28
+ "host": "server_1",
29
+ "kind": "report",
30
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/ara/trace/sessions/session_index.yaml",
31
+ "state": "completed"
32
+ },
33
+ {
34
+ "host": "server_1",
35
+ "kind": "report",
36
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/INDEPENDENT_VERIFICATION.json",
37
+ "state": "completed"
38
+ },
39
+ {
40
+ "host": "server_1",
41
+ "kind": "report",
42
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/PROTOCOL.md",
43
+ "state": "completed"
44
+ },
45
+ {
46
+ "host": "server_1",
47
+ "kind": "report",
48
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/REPORT.md",
49
+ "state": "completed"
50
+ },
51
+ {
52
+ "host": "server_1",
53
+ "kind": "report",
54
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/RESULT.json",
55
+ "state": "completed"
56
+ },
57
+ {
58
+ "host": "server_1",
59
+ "kind": "data",
60
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/candidate_marker_counts.parquet",
61
+ "state": "completed"
62
+ },
63
+ {
64
+ "host": "server_1",
65
+ "kind": "code",
66
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/check_candidates.py",
67
+ "state": "completed"
68
+ },
69
+ {
70
+ "host": "server_1",
71
+ "kind": "report",
72
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/expression_source_receipts.json",
73
+ "state": "completed"
74
+ },
75
+ {
76
+ "host": "server_1",
77
+ "kind": "report",
78
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/extraction_plan.json",
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/corpus_macrophage_markers_20261015/sample_support.csv",
85
+ "state": "completed"
86
+ },
87
+ {
88
+ "host": "server_1",
89
+ "kind": "data",
90
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/selected_training_candidates.parquet",
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/corpus_macrophage_markers_20261015/source_label_summary.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/corpus_macrophage_markers_20261015/summary.csv",
103
+ "state": "completed"
104
+ },
105
+ {
106
+ "host": "server_1",
107
+ "kind": "code",
108
+ "source": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/corpus_macrophage_markers_20261015/verify_candidates.py",
109
+ "state": "completed"
110
+ }
111
+ ],
112
+ "inference_locations": [],
113
+ "project_id": "pbisc-diffusion",
114
+ "summary": "CPU-only exact training C1Q-candidate five-marker co-detection audit. User markers C1QA/CD163/CD68/WARS1/LGALS3. Verified1,319 unflagged+109flagged all-positive; scoped candidate subset, not confirmed macrophages/full-corpus prevalence. Source metadata and figures unchanged."
115
+ }