Add verified PBISC dataset assets (851-900)
Browse files- counts/overlay/bdafb989995613f8ac7f97d8.tar.members.json +3 -0
- counts/overlay/c6e419e6a00d1ad94003972f.tar +3 -0
- counts/overlay/c6e419e6a00d1ad94003972f.tar.members.json +3 -0
- counts/overlay/cdbc154095873b33a243d0cc.tar +3 -0
- counts/overlay/cdbc154095873b33a243d0cc.tar.members.json +3 -0
- counts/overlay/d00ea4f69d315e8b7eb02b50.tar +3 -0
- counts/overlay/d00ea4f69d315e8b7eb02b50.tar.members.json +3 -0
- counts/overlay/de2b64453cf53b48e961a8a6.tar +3 -0
- counts/overlay/de2b64453cf53b48e961a8a6.tar.members.json +3 -0
- counts/overlay/e828519707889463d0ae5834.tar +3 -0
- counts/overlay/e828519707889463d0ae5834.tar.members.json +3 -0
- counts/overlay/fa6520d6d6ba7ce900c05c1c.tar +3 -0
- counts/overlay/fa6520d6d6ba7ce900c05c1c.tar.members.json +3 -0
- counts/overlay/ffe78b07765fe1855d887029.tar +3 -0
- counts/overlay/ffe78b07765fe1855d887029.tar.members.json +3 -0
- index/COMPLETE +1 -0
- index/audit.json +31 -0
- index/dataset_manifest.json +322 -0
- index/metadata/donor_splits.parquet +3 -0
- index/metadata/joint_quotas.parquet +3 -0
- index/metadata/k_quotas.parquet +3 -0
- index/metadata/platform_quotas.parquet +3 -0
- index/metadata/recipe_parts.parquet +3 -0
- index/metadata/sample_index.parquet +3 -0
- index/metadata/sample_pools.parquet +3 -0
- index/metadata/source_shards.parquet +3 -0
- index/recipes/diagnostic.parquet +3 -0
- index/recipes/test.parquet +3 -0
- index/recipes/train-slot-000.parquet +3 -0
- index/recipes/train-slot-001.parquet +3 -0
- index/recipes/train-slot-002.parquet +3 -0
- index/recipes/train-slot-003.parquet +3 -0
- index/recipes/train-slot-004.parquet +3 -0
- index/recipes/train-slot-005.parquet +3 -0
- index/recipes/train-slot-006.parquet +3 -0
- index/recipes/train-slot-007.parquet +3 -0
- index/recipes/train-slot-008.parquet +3 -0
- index/recipes/train-slot-009.parquet +3 -0
- index/recipes/train-slot-010.parquet +3 -0
- index/recipes/train-slot-011.parquet +3 -0
- index/recipes/train-slot-012.parquet +3 -0
- index/recipes/train-slot-013.parquet +3 -0
- index/recipes/train-slot-014.parquet +3 -0
- index/recipes/train-slot-015.parquet +3 -0
- index/recipes/val.parquet +3 -0
- panels/2k/gene_positions.npy +3 -0
- panels/2k/legacy_selection_manifest.v1.json +35 -0
- provenance/coverage_v1/summary.json +153 -0
- provenance/implementations/panel_ladder.py +1981 -0
- provenance/rights.tsv +23 -0
counts/overlay/bdafb989995613f8ac7f97d8.tar.members.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ff665f70708a4df6b4fb9b84b2a038db35ec821b5f46e62bd5d55747e93bb384
|
| 3 |
+
size 3527
|
counts/overlay/c6e419e6a00d1ad94003972f.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b0776da05bfd1e5ebad493c8d0b8e752180d7ccc854a2d45e965dc248ccd1f28
|
| 3 |
+
size 3389440
|
counts/overlay/c6e419e6a00d1ad94003972f.tar.members.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c46c6c58bf7614a61decd280376de51a217328c980f3f092dfab2f029d2b2532
|
| 3 |
+
size 4456
|
counts/overlay/cdbc154095873b33a243d0cc.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6425e92986bb31ed1a2fc63380979e683440d54374cd229ddeddc65e04029c80
|
| 3 |
+
size 7178240
|
counts/overlay/cdbc154095873b33a243d0cc.tar.members.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4f5df33b84a7997d5b6efc46ab512f9c9f30376f010dbcaacc85210144b6080c
|
| 3 |
+
size 6010
|
counts/overlay/d00ea4f69d315e8b7eb02b50.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d70e60b84406f8a74cbed50f4a48266930ef8107b89b7283dd33703407c67ea6
|
| 3 |
+
size 204800
|
counts/overlay/d00ea4f69d315e8b7eb02b50.tar.members.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6e50835d5386153b1876141b026e18c378c0ace8d654e6cfe45fc9ddda7128c0
|
| 3 |
+
size 3626
|
counts/overlay/de2b64453cf53b48e961a8a6.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1e3bfec6878f11f96cad7fe1001e4d8ec892783d591582f0072e12defc6c9a7a
|
| 3 |
+
size 1433600
|
counts/overlay/de2b64453cf53b48e961a8a6.tar.members.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0bed22663c2dc846d56b73208362b174b2bf81c0422755389c0592e5121893d8
|
| 3 |
+
size 3788
|
counts/overlay/e828519707889463d0ae5834.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4a877f2f320c6150bca92dd313e1d944ed3187e3e4b51d1d686d1be036598d38
|
| 3 |
+
size 5038080
|
counts/overlay/e828519707889463d0ae5834.tar.members.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4cfa510dea6716bc3c453b61b67cab5624d9e78e416bde86632dc981767dc1a
|
| 3 |
+
size 5548
|
counts/overlay/fa6520d6d6ba7ce900c05c1c.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5efba90a3938f50591d2bf3feb95a2c6e75318e57f79d12366451fbee327cab4
|
| 3 |
+
size 5007360
|
counts/overlay/fa6520d6d6ba7ce900c05c1c.tar.members.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc8ff816d521e9e40f3df127965442e45959243305e8eddda0ba9c3c800a3c99
|
| 3 |
+
size 5548
|
counts/overlay/ffe78b07765fe1855d887029.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a9278f1cf3609a389cc56f4d9dd9e995c2f4eed25b63c4cb63bd4ce5550b38e1
|
| 3 |
+
size 59699200
|
counts/overlay/ffe78b07765fe1855d887029.tar.members.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:978440ac03531fce9bdcf5a5dfa47231c44e2673b568dae49bd724e4c97030de
|
| 3 |
+
size 23100
|
index/COMPLETE
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
eeb609250457248225432b6df94573b26a8cad8ac743670b5ca43134fea7e007
|
index/audit.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"annotation_columns_requested": [],
|
| 3 |
+
"corpus_fingerprint": "eeb609250457248225432b6df94573b26a8cad8ac743670b5ca43134fea7e007",
|
| 4 |
+
"donor_split_overlap_count": 0,
|
| 5 |
+
"exact_k_quota_each_slot": true,
|
| 6 |
+
"exact_platform_quota_each_slot": true,
|
| 7 |
+
"excluded_ref_datasets": true,
|
| 8 |
+
"max_disjoint_epochs": 16,
|
| 9 |
+
"missing_donor_cells_using_sample_fallback": 0,
|
| 10 |
+
"n_pool_rows": 65589,
|
| 11 |
+
"scale_bio_heldout_available": false,
|
| 12 |
+
"scale_bio_train_only": true,
|
| 13 |
+
"selection_uses_annotation_values": false,
|
| 14 |
+
"source_fingerprint": "653a06a72a2a785bc2e21fe1666950319e21847dd382e7ff7bfc852815a5f58f",
|
| 15 |
+
"source_obs_columns_read": [
|
| 16 |
+
"dataset_id",
|
| 17 |
+
"donor_id",
|
| 18 |
+
"sample_id",
|
| 19 |
+
"row_index"
|
| 20 |
+
],
|
| 21 |
+
"source_shard_columns_read": [
|
| 22 |
+
"dataset_id",
|
| 23 |
+
"shard_id",
|
| 24 |
+
"n_cells",
|
| 25 |
+
"n_genes",
|
| 26 |
+
"count_zarr",
|
| 27 |
+
"obs_part"
|
| 28 |
+
],
|
| 29 |
+
"status": "PASS",
|
| 30 |
+
"train_recipe_ids_unique": true
|
| 31 |
+
}
|
index/dataset_manifest.json
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"annotation_fields_never_requested_by_index_builder": true,
|
| 3 |
+
"base_source_root": "/home/sj_server_1/PBISC/PBISC-data/single-cell-data-block-blood",
|
| 4 |
+
"build_config_signature": "438806219f5ea470c918cca4ff076c9b9c2e1b9144cbadb5179a5600f49d88b1",
|
| 5 |
+
"corpus_core": {
|
| 6 |
+
"build_config_signature": "438806219f5ea470c918cca4ff076c9b9c2e1b9144cbadb5179a5600f49d88b1",
|
| 7 |
+
"donor_splits_sha256": "4e08cb07ed5280dee3b27fe9550d09c706b6cfb5e4f97539e2de07ec4086103f",
|
| 8 |
+
"gene_panel_sha256": "64f4e30e17763bef37793e7229edb6caa0a7ffe3f3bfa5a08e1d4ca8ea7ea1dc",
|
| 9 |
+
"index_source_shards_sha256": "14c9befabe3c901613321682d8a1b3be0de5182613265584ee6baea2e6badf28",
|
| 10 |
+
"recipe_ids_sha256": "df93f80c4a05ef0f50c0a37407533885a5c18e37ed411bc1269af982a80a32f9",
|
| 11 |
+
"recipe_parts_content_sha256": "018493f60745f026ea4979cfb8954ba6dc3e3f79f351d688382a84c6a360de4b",
|
| 12 |
+
"recipe_parts_manifest_sha256": "b794775c8ddfa0bd66833c26f8d17a66eb2d55ee9a4df7b68e88589cc2b6f47f",
|
| 13 |
+
"sample_index_sha256": "8c4b38d313eac651f545979ef5813c60fa47ff59da8c07f11e1712b8a83d2322",
|
| 14 |
+
"sample_pools_sha256": "5f272fba92c0b388a3d7cd27f1fcb5ccd3e7edb5490c95948a50bc2ba35da8d1",
|
| 15 |
+
"source_fingerprint": "653a06a72a2a785bc2e21fe1666950319e21847dd382e7ff7bfc852815a5f58f",
|
| 16 |
+
"source_shards_sha256": "d9cb4515e6e9113918ad16f9453d7ffc435c8a3597b8b6f753f8363c9d4e1296"
|
| 17 |
+
},
|
| 18 |
+
"corpus_fingerprint": "eeb609250457248225432b6df94573b26a8cad8ac743670b5ca43134fea7e007",
|
| 19 |
+
"created_at_utc": "2026-08-12T12:10:46.232540+00:00",
|
| 20 |
+
"donor_splits_sha256": "4e08cb07ed5280dee3b27fe9550d09c706b6cfb5e4f97539e2de07ec4086103f",
|
| 21 |
+
"gene_panel_sha256": "64f4e30e17763bef37793e7229edb6caa0a7ffe3f3bfa5a08e1d4ca8ea7ea1dc",
|
| 22 |
+
"global_validation_contract": {
|
| 23 |
+
"excludes_diagnostic_platforms": [
|
| 24 |
+
"ScaleBio"
|
| 25 |
+
],
|
| 26 |
+
"platforms": [
|
| 27 |
+
"10x",
|
| 28 |
+
"Parse",
|
| 29 |
+
"Seq-Well"
|
| 30 |
+
],
|
| 31 |
+
"scope": "heldout_dataset_donor",
|
| 32 |
+
"split": "val",
|
| 33 |
+
"used_for_best_checkpoint": true
|
| 34 |
+
},
|
| 35 |
+
"index_source_shards_sha256": "14c9befabe3c901613321682d8a1b3be0de5182613265584ee6baea2e6badf28",
|
| 36 |
+
"joint_quotas_per_epoch": {
|
| 37 |
+
"10x|1000": 1279,
|
| 38 |
+
"10x|2000": 1708,
|
| 39 |
+
"10x|250": 426,
|
| 40 |
+
"10x|4000": 426,
|
| 41 |
+
"10x|500": 852,
|
| 42 |
+
"Parse|1000": 717,
|
| 43 |
+
"Parse|2000": 954,
|
| 44 |
+
"Parse|250": 239,
|
| 45 |
+
"Parse|4000": 238,
|
| 46 |
+
"Parse|500": 477,
|
| 47 |
+
"ScaleBio|1000": 190,
|
| 48 |
+
"ScaleBio|2000": 253,
|
| 49 |
+
"ScaleBio|250": 64,
|
| 50 |
+
"ScaleBio|4000": 63,
|
| 51 |
+
"ScaleBio|500": 128,
|
| 52 |
+
"Seq-Well|1000": 48,
|
| 53 |
+
"Seq-Well|2000": 64,
|
| 54 |
+
"Seq-Well|250": 16,
|
| 55 |
+
"Seq-Well|4000": 18,
|
| 56 |
+
"Seq-Well|500": 32
|
| 57 |
+
},
|
| 58 |
+
"k_quotas_per_epoch": {
|
| 59 |
+
"1000": 2234,
|
| 60 |
+
"2000": 2979,
|
| 61 |
+
"250": 745,
|
| 62 |
+
"4000": 745,
|
| 63 |
+
"500": 1489
|
| 64 |
+
},
|
| 65 |
+
"k_values": [
|
| 66 |
+
250,
|
| 67 |
+
500,
|
| 68 |
+
1000,
|
| 69 |
+
2000,
|
| 70 |
+
4000
|
| 71 |
+
],
|
| 72 |
+
"k_weights": [
|
| 73 |
+
1,
|
| 74 |
+
2,
|
| 75 |
+
3,
|
| 76 |
+
4,
|
| 77 |
+
1
|
| 78 |
+
],
|
| 79 |
+
"max_disjoint_epochs": 16,
|
| 80 |
+
"n_cells": 41395184,
|
| 81 |
+
"n_datasets": 22,
|
| 82 |
+
"n_shards": 432,
|
| 83 |
+
"platform_cell_counts": {
|
| 84 |
+
"10x": 30967465,
|
| 85 |
+
"Parse": 9697974,
|
| 86 |
+
"ScaleBio": 685024,
|
| 87 |
+
"Seq-Well": 44721
|
| 88 |
+
},
|
| 89 |
+
"platform_quota_basis": "sqrt(all_strict_corpus_cells_by_platform)",
|
| 90 |
+
"platform_quotas_per_epoch": {
|
| 91 |
+
"10x": 4691,
|
| 92 |
+
"Parse": 2625,
|
| 93 |
+
"ScaleBio": 698,
|
| 94 |
+
"Seq-Well": 178
|
| 95 |
+
},
|
| 96 |
+
"platform_sampling_policy": "sqrt_cells",
|
| 97 |
+
"platform_validation_contract": {
|
| 98 |
+
"10x": {
|
| 99 |
+
"heldout": true,
|
| 100 |
+
"heldout_available": true,
|
| 101 |
+
"scope": "heldout_dataset_donor",
|
| 102 |
+
"split": "val"
|
| 103 |
+
},
|
| 104 |
+
"Parse": {
|
| 105 |
+
"heldout": true,
|
| 106 |
+
"heldout_available": true,
|
| 107 |
+
"scope": "heldout_dataset_donor",
|
| 108 |
+
"split": "val"
|
| 109 |
+
},
|
| 110 |
+
"ScaleBio": {
|
| 111 |
+
"heldout": false,
|
| 112 |
+
"heldout_available": false,
|
| 113 |
+
"scope": "in_corpus_diagnostic_singleton_donor",
|
| 114 |
+
"split": "diagnostic"
|
| 115 |
+
},
|
| 116 |
+
"Seq-Well": {
|
| 117 |
+
"heldout": true,
|
| 118 |
+
"heldout_available": true,
|
| 119 |
+
"scope": "heldout_dataset_donor",
|
| 120 |
+
"split": "val"
|
| 121 |
+
}
|
| 122 |
+
},
|
| 123 |
+
"recipe_counts_by_split_platform": {
|
| 124 |
+
"diagnostic": {
|
| 125 |
+
"ScaleBio": 64
|
| 126 |
+
},
|
| 127 |
+
"test": {
|
| 128 |
+
"10x": 64,
|
| 129 |
+
"Parse": 64,
|
| 130 |
+
"Seq-Well": 64
|
| 131 |
+
},
|
| 132 |
+
"train": {
|
| 133 |
+
"10x": 75056,
|
| 134 |
+
"Parse": 42000,
|
| 135 |
+
"ScaleBio": 11168,
|
| 136 |
+
"Seq-Well": 2848
|
| 137 |
+
},
|
| 138 |
+
"val": {
|
| 139 |
+
"10x": 64,
|
| 140 |
+
"Parse": 64,
|
| 141 |
+
"Seq-Well": 64
|
| 142 |
+
}
|
| 143 |
+
},
|
| 144 |
+
"recipe_part_files": [
|
| 145 |
+
{
|
| 146 |
+
"recipe_part": "recipes/diagnostic.parquet",
|
| 147 |
+
"rows": 64,
|
| 148 |
+
"schedule_slot": -1,
|
| 149 |
+
"sha256": "d8a117fa309b72832f574e7dde057895518d92e0cc95841222ced511d383a657",
|
| 150 |
+
"split": "diagnostic"
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"recipe_part": "recipes/test.parquet",
|
| 154 |
+
"rows": 192,
|
| 155 |
+
"schedule_slot": -1,
|
| 156 |
+
"sha256": "fa5522cd34fce1e2248ea9904b73ac86180eec28f4b338ea2868bcc88e310def",
|
| 157 |
+
"split": "test"
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"recipe_part": "recipes/train-slot-000.parquet",
|
| 161 |
+
"rows": 8192,
|
| 162 |
+
"schedule_slot": 0,
|
| 163 |
+
"sha256": "bdc1875f34f9754d94750e0d968b83f33efc01cbae9d967032fc5ed97de43c36",
|
| 164 |
+
"split": "train"
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"recipe_part": "recipes/train-slot-001.parquet",
|
| 168 |
+
"rows": 8192,
|
| 169 |
+
"schedule_slot": 1,
|
| 170 |
+
"sha256": "be0d8fa3d85de56eddedcd77370de3427ed6a1e7fd27830b550650ab4b43633c",
|
| 171 |
+
"split": "train"
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
"recipe_part": "recipes/train-slot-002.parquet",
|
| 175 |
+
"rows": 8192,
|
| 176 |
+
"schedule_slot": 2,
|
| 177 |
+
"sha256": "9022f271e2a291c1cbf979d45911e89908faaf00334ef586e92949a5fe346fb5",
|
| 178 |
+
"split": "train"
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"recipe_part": "recipes/train-slot-003.parquet",
|
| 182 |
+
"rows": 8192,
|
| 183 |
+
"schedule_slot": 3,
|
| 184 |
+
"sha256": "cc2bd2b099ef2d48c8ff3992bb219692a18a3bcd2b8f67aa2edb0165fba2c136",
|
| 185 |
+
"split": "train"
|
| 186 |
+
},
|
| 187 |
+
{
|
| 188 |
+
"recipe_part": "recipes/train-slot-004.parquet",
|
| 189 |
+
"rows": 8192,
|
| 190 |
+
"schedule_slot": 4,
|
| 191 |
+
"sha256": "535c5c9e8f7a2317d593e8e03c677c4cc1fb233b0bd70a9159d534d4d01e4814",
|
| 192 |
+
"split": "train"
|
| 193 |
+
},
|
| 194 |
+
{
|
| 195 |
+
"recipe_part": "recipes/train-slot-005.parquet",
|
| 196 |
+
"rows": 8192,
|
| 197 |
+
"schedule_slot": 5,
|
| 198 |
+
"sha256": "af8b8dd9e529ba5e1ff38b0c1105de2fa581c684c0b245a2b00db8d3cb61c405",
|
| 199 |
+
"split": "train"
|
| 200 |
+
},
|
| 201 |
+
{
|
| 202 |
+
"recipe_part": "recipes/train-slot-006.parquet",
|
| 203 |
+
"rows": 8192,
|
| 204 |
+
"schedule_slot": 6,
|
| 205 |
+
"sha256": "3a6e6731a3284f389f50713eb42a64b6cf64526a78631c036ec663ebb542bfa2",
|
| 206 |
+
"split": "train"
|
| 207 |
+
},
|
| 208 |
+
{
|
| 209 |
+
"recipe_part": "recipes/train-slot-007.parquet",
|
| 210 |
+
"rows": 8192,
|
| 211 |
+
"schedule_slot": 7,
|
| 212 |
+
"sha256": "65fb7c3933e4a077bb1876e37f85f63297c995ecb20cb62f9240598aac118672",
|
| 213 |
+
"split": "train"
|
| 214 |
+
},
|
| 215 |
+
{
|
| 216 |
+
"recipe_part": "recipes/train-slot-008.parquet",
|
| 217 |
+
"rows": 8192,
|
| 218 |
+
"schedule_slot": 8,
|
| 219 |
+
"sha256": "802567424fedff8f4038ab9cfe4b886eb25a3ac490c36a43f7ab7f3607dff115",
|
| 220 |
+
"split": "train"
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
"recipe_part": "recipes/train-slot-009.parquet",
|
| 224 |
+
"rows": 8192,
|
| 225 |
+
"schedule_slot": 9,
|
| 226 |
+
"sha256": "ba38b56f0ad98e853753d58fa521183977b2ab0bb5fddc1d7d1f73f0a6f9f317",
|
| 227 |
+
"split": "train"
|
| 228 |
+
},
|
| 229 |
+
{
|
| 230 |
+
"recipe_part": "recipes/train-slot-010.parquet",
|
| 231 |
+
"rows": 8192,
|
| 232 |
+
"schedule_slot": 10,
|
| 233 |
+
"sha256": "f2956bdec0a88e44c12bcbdee63d8e1d7412e4b40e942d06f0350d5dd4a5f400",
|
| 234 |
+
"split": "train"
|
| 235 |
+
},
|
| 236 |
+
{
|
| 237 |
+
"recipe_part": "recipes/train-slot-011.parquet",
|
| 238 |
+
"rows": 8192,
|
| 239 |
+
"schedule_slot": 11,
|
| 240 |
+
"sha256": "1e893d164e32ada346d6b5068821011677f29d60fbf2965976d9722c5ac5f649",
|
| 241 |
+
"split": "train"
|
| 242 |
+
},
|
| 243 |
+
{
|
| 244 |
+
"recipe_part": "recipes/train-slot-012.parquet",
|
| 245 |
+
"rows": 8192,
|
| 246 |
+
"schedule_slot": 12,
|
| 247 |
+
"sha256": "ddbe429b657b3b6b1cf474c417155c5a00f7009f2e6660079aa6517b4a35a518",
|
| 248 |
+
"split": "train"
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
"recipe_part": "recipes/train-slot-013.parquet",
|
| 252 |
+
"rows": 8192,
|
| 253 |
+
"schedule_slot": 13,
|
| 254 |
+
"sha256": "ad43faa41a805c035b8e91f0b6e69b01e4365f70b422c522e2dee8d4d047ba33",
|
| 255 |
+
"split": "train"
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"recipe_part": "recipes/train-slot-014.parquet",
|
| 259 |
+
"rows": 8192,
|
| 260 |
+
"schedule_slot": 14,
|
| 261 |
+
"sha256": "0254004bdc0bc84e2936d5f2a082fd78a5c6453adc823dcbeffbca8a7ef09548",
|
| 262 |
+
"split": "train"
|
| 263 |
+
},
|
| 264 |
+
{
|
| 265 |
+
"recipe_part": "recipes/train-slot-015.parquet",
|
| 266 |
+
"rows": 8192,
|
| 267 |
+
"schedule_slot": 15,
|
| 268 |
+
"sha256": "bac7d8c39ab864ebd658844bbbcbb28a6701ef15dc1e0a2ec747983c3bdaa1e3",
|
| 269 |
+
"split": "train"
|
| 270 |
+
},
|
| 271 |
+
{
|
| 272 |
+
"recipe_part": "recipes/val.parquet",
|
| 273 |
+
"rows": 192,
|
| 274 |
+
"schedule_slot": -1,
|
| 275 |
+
"sha256": "d05dd1ba63e3fad846aa44e932e20b5afb0da015c66e4b14ece762a7d486f526",
|
| 276 |
+
"split": "val"
|
| 277 |
+
}
|
| 278 |
+
],
|
| 279 |
+
"recipe_parts_content_sha256": "018493f60745f026ea4979cfb8954ba6dc3e3f79f351d688382a84c6a360de4b",
|
| 280 |
+
"recipe_parts_manifest_sha256": "b794775c8ddfa0bd66833c26f8d17a66eb2d55ee9a4df7b68e88589cc2b6f47f",
|
| 281 |
+
"recipe_pool_annotation_free": true,
|
| 282 |
+
"sample_index_sha256": "8c4b38d313eac651f545979ef5813c60fa47ff59da8c07f11e1712b8a83d2322",
|
| 283 |
+
"sample_pools_rows": 65589,
|
| 284 |
+
"sample_pools_schema": {
|
| 285 |
+
"row_indices": "list<element: int32>",
|
| 286 |
+
"sample_key": "string",
|
| 287 |
+
"shard_id": "string"
|
| 288 |
+
},
|
| 289 |
+
"sample_pools_sha256": "5f272fba92c0b388a3d7cd27f1fcb5ccd3e7edb5490c95948a50bc2ba35da8d1",
|
| 290 |
+
"sampling_policy": "random",
|
| 291 |
+
"schedule_slots": 16,
|
| 292 |
+
"schema_version": "model7.e2_full.index.v1",
|
| 293 |
+
"selection_uses_annotation_values": false,
|
| 294 |
+
"source_fingerprint": "653a06a72a2a785bc2e21fe1666950319e21847dd382e7ff7bfc852815a5f58f",
|
| 295 |
+
"source_manifest_schema": "model7.e2_strict_source.v1",
|
| 296 |
+
"source_obs_columns_read": [
|
| 297 |
+
"dataset_id",
|
| 298 |
+
"donor_id",
|
| 299 |
+
"sample_id",
|
| 300 |
+
"row_index"
|
| 301 |
+
],
|
| 302 |
+
"source_root": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_7_no_annotation_sh_hwang/data/e2_full_source",
|
| 303 |
+
"source_shard_columns_read": [
|
| 304 |
+
"dataset_id",
|
| 305 |
+
"shard_id",
|
| 306 |
+
"n_cells",
|
| 307 |
+
"n_genes",
|
| 308 |
+
"count_zarr",
|
| 309 |
+
"obs_part"
|
| 310 |
+
],
|
| 311 |
+
"source_shards_sha256": "d9cb4515e6e9113918ad16f9453d7ffc435c8a3597b8b6f753f8363c9d4e1296",
|
| 312 |
+
"split_fractions": {
|
| 313 |
+
"test": 0.1,
|
| 314 |
+
"train": 0.8,
|
| 315 |
+
"val": 0.1
|
| 316 |
+
},
|
| 317 |
+
"split_unit": "dataset_donor",
|
| 318 |
+
"split_unit_detail": "dataset_id,donor_id; sample_id fallback when donor_id is missing",
|
| 319 |
+
"train_dataset_coverage": 22,
|
| 320 |
+
"train_recipe_pool_size": 131072,
|
| 321 |
+
"train_recipes_per_epoch": 8192
|
| 322 |
+
}
|
index/metadata/donor_splits.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4e08cb07ed5280dee3b27fe9550d09c706b6cfb5e4f97539e2de07ec4086103f
|
| 3 |
+
size 96225
|
index/metadata/joint_quotas.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fb479392754f6c17dad7710a24ed10e9834302396ad1c8b1e43f94b1dc3c268b
|
| 3 |
+
size 3451
|
index/metadata/k_quotas.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af15978459b4f3658a3a601bc6c29585b7bdfa1f349bc0b9eed609abc108a32f
|
| 3 |
+
size 2755
|
index/metadata/platform_quotas.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:05564333d395c288683515eed5cc45f8f56bf8b590e1b7c0b25060f9003cc1ce
|
| 3 |
+
size 2739
|
index/metadata/recipe_parts.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b794775c8ddfa0bd66833c26f8d17a66eb2d55ee9a4df7b68e88589cc2b6f47f
|
| 3 |
+
size 3503
|
index/metadata/sample_index.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8c4b38d313eac651f545979ef5813c60fa47ff59da8c07f11e1712b8a83d2322
|
| 3 |
+
size 316364
|
index/metadata/sample_pools.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5f272fba92c0b388a3d7cd27f1fcb5ccd3e7edb5490c95948a50bc2ba35da8d1
|
| 3 |
+
size 197702890
|
index/metadata/source_shards.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:14c9befabe3c901613321682d8a1b3be0de5182613265584ee6baea2e6badf28
|
| 3 |
+
size 67133
|
index/recipes/diagnostic.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d8a117fa309b72832f574e7dde057895518d92e0cc95841222ced511d383a657
|
| 3 |
+
size 16087
|
index/recipes/test.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fa5522cd34fce1e2248ea9904b73ac86180eec28f4b338ea2868bcc88e310def
|
| 3 |
+
size 30791
|
index/recipes/train-slot-000.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bdc1875f34f9754d94750e0d968b83f33efc01cbae9d967032fc5ed97de43c36
|
| 3 |
+
size 761384
|
index/recipes/train-slot-001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be0d8fa3d85de56eddedcd77370de3427ed6a1e7fd27830b550650ab4b43633c
|
| 3 |
+
size 763245
|
index/recipes/train-slot-002.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9022f271e2a291c1cbf979d45911e89908faaf00334ef586e92949a5fe346fb5
|
| 3 |
+
size 761423
|
index/recipes/train-slot-003.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cc2bd2b099ef2d48c8ff3992bb219692a18a3bcd2b8f67aa2edb0165fba2c136
|
| 3 |
+
size 761346
|
index/recipes/train-slot-004.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:535c5c9e8f7a2317d593e8e03c677c4cc1fb233b0bd70a9159d534d4d01e4814
|
| 3 |
+
size 761644
|
index/recipes/train-slot-005.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af8b8dd9e529ba5e1ff38b0c1105de2fa581c684c0b245a2b00db8d3cb61c405
|
| 3 |
+
size 761430
|
index/recipes/train-slot-006.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a6e6731a3284f389f50713eb42a64b6cf64526a78631c036ec663ebb542bfa2
|
| 3 |
+
size 760725
|
index/recipes/train-slot-007.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:65fb7c3933e4a077bb1876e37f85f63297c995ecb20cb62f9240598aac118672
|
| 3 |
+
size 760945
|
index/recipes/train-slot-008.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:802567424fedff8f4038ab9cfe4b886eb25a3ac490c36a43f7ab7f3607dff115
|
| 3 |
+
size 760119
|
index/recipes/train-slot-009.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba38b56f0ad98e853753d58fa521183977b2ab0bb5fddc1d7d1f73f0a6f9f317
|
| 3 |
+
size 763238
|
index/recipes/train-slot-010.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f2956bdec0a88e44c12bcbdee63d8e1d7412e4b40e942d06f0350d5dd4a5f400
|
| 3 |
+
size 762274
|
index/recipes/train-slot-011.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1e893d164e32ada346d6b5068821011677f29d60fbf2965976d9722c5ac5f649
|
| 3 |
+
size 760884
|
index/recipes/train-slot-012.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ddbe429b657b3b6b1cf474c417155c5a00f7009f2e6660079aa6517b4a35a518
|
| 3 |
+
size 763740
|
index/recipes/train-slot-013.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ad43faa41a805c035b8e91f0b6e69b01e4365f70b422c522e2dee8d4d047ba33
|
| 3 |
+
size 759577
|
index/recipes/train-slot-014.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0254004bdc0bc84e2936d5f2a082fd78a5c6453adc823dcbeffbca8a7ef09548
|
| 3 |
+
size 762750
|
index/recipes/train-slot-015.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bac7d8c39ab864ebd658844bbbcbb28a6701ef15dc1e0a2ec747983c3bdaa1e3
|
| 3 |
+
size 761965
|
index/recipes/val.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d05dd1ba63e3fad846aa44e932e20b5afb0da015c66e4b14ece762a7d486f526
|
| 3 |
+
size 30446
|
panels/2k/gene_positions.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ac9c8a1520a319ff64de66c9b20a068b114cc398a44ae26f73fef8153a603f5e
|
| 3 |
+
size 16128
|
panels/2k/legacy_selection_manifest.v1.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"algorithm": "universal train-only measurement-aware HVG ranking; this tier is a rank prefix emitted in canonical tensor order",
|
| 3 |
+
"corpus_fingerprint": "eeb609250457248225432b6df94573b26a8cad8ac743670b5ca43134fea7e007",
|
| 4 |
+
"implementation": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/src/pbisc_sdd/panel_ladder.py",
|
| 5 |
+
"implementation_sha256": "45116a496e1f38247dfdaa3d306ab54aa28e13736754dbe9dd75eaa5dc7d518f",
|
| 6 |
+
"n_selected_genes": 2000,
|
| 7 |
+
"parameters": {
|
| 8 |
+
"cells_per_recipe": 128,
|
| 9 |
+
"mean_bins": 20,
|
| 10 |
+
"model7_root": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_7_no_annotation_sh_hwang",
|
| 11 |
+
"n_genes": 2000,
|
| 12 |
+
"recipes": 256,
|
| 13 |
+
"seed": 20260627,
|
| 14 |
+
"target_sum": 10000.0,
|
| 15 |
+
"tier_sizes": {
|
| 16 |
+
"2k": 2000,
|
| 17 |
+
"3k": 3000,
|
| 18 |
+
"6k": 6000
|
| 19 |
+
}
|
| 20 |
+
},
|
| 21 |
+
"parent_panel_ladder": {
|
| 22 |
+
"binding_sha256": "0608f3bf114d272d2daadc2b5477840490129f0dffcf4b4b7f18ae6ca5393bf8",
|
| 23 |
+
"manifest_path": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/artifacts/panel_ladder_train256x128_seed20260627_v3/manifest.json",
|
| 24 |
+
"schema_version": "pbisc_sdd.panel_ladder.v2",
|
| 25 |
+
"tier": "2k"
|
| 26 |
+
},
|
| 27 |
+
"positions_path": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/artifacts/panel_ladder_train256x128_seed20260627_v3/tiers/2k/gene_positions.npy",
|
| 28 |
+
"positions_sha256": "ac9c8a1520a319ff64de66c9b20a068b114cc398a44ae26f73fef8153a603f5e",
|
| 29 |
+
"sampled_cells": 32768,
|
| 30 |
+
"sampled_recipes": 256,
|
| 31 |
+
"schema_version": "pbisc_sdd.hvg_selection.v1",
|
| 32 |
+
"selected_genes_path": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/artifacts/panel_ladder_train256x128_seed20260627_v3/tiers/2k/selected_genes.csv",
|
| 33 |
+
"selected_genes_sha256": "9ced976a4c10675f9628429e010faf3b6befcae9e3cf8336e7a26b942dbc3a3a",
|
| 34 |
+
"selection_scope": "train_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|
| 3 |
+
"all_possible_cell_combinations_exhausted": false,
|
| 4 |
+
"array_policy": "All source splits allocated; nontrain visit counts zero. Never count nontrain zero rows in train denominator.",
|
| 5 |
+
"cell_identity": "shard_offsets.csv maps global index to (shard_id, row_index); owner index maps to sample_identities.csv",
|
| 6 |
+
"cell_membership_disjoint_across_slots": "not required; cell reuse is counted",
|
| 7 |
+
"corpus_fingerprint": "eeb609250457248225432b6df94573b26a8cad8ac743670b5ca43134fea7e007",
|
| 8 |
+
"denominator_policy": "ALL sample_index train cells, including samples absent from recipes",
|
| 9 |
+
"duplicate_train_member_sets": 23,
|
| 10 |
+
"elapsed_seconds": 20.719,
|
| 11 |
+
"heldout_target_exposures": 0,
|
| 12 |
+
"index_root": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_7_no_annotation_sh_hwang/data/e2_full_index",
|
| 13 |
+
"pool_order_policy": "all-train-first-then-validation-v1",
|
| 14 |
+
"pool_order_sha256": "b44aed91ab628de4fc7505c9ecc13296bc04d8cd78120d46aca3e50ae0267b3f",
|
| 15 |
+
"recipe_ids_disjoint_across_slots": true,
|
| 16 |
+
"recipe_membership_hash_encoding": "train parts sorted (split,slot,path), stored row order; ASCII recipe_id + NUL + sorted global cell IDs little-endian int64",
|
| 17 |
+
"recipe_membership_sha256": "b28cef371a2ff5c42b77ec13a0a34cc239ff57ae8127f9e3a4ea81ee945e7fce",
|
| 18 |
+
"registered_train_recipe_samples": 4849,
|
| 19 |
+
"rng": {
|
| 20 |
+
"algorithm": "default_rng(seed).choice(N,K,replace=False); final refs shuffle omitted because membership is invariant",
|
| 21 |
+
"library": "numpy",
|
| 22 |
+
"version": "1.26.4"
|
| 23 |
+
},
|
| 24 |
+
"schedule_slots": 16,
|
| 25 |
+
"schema_version": "pbisc_sdd.allcell_recipe_coverage.v1",
|
| 26 |
+
"slot_coverage": [
|
| 27 |
+
{
|
| 28 |
+
"recipes": 8192,
|
| 29 |
+
"schedule_slot": 0,
|
| 30 |
+
"target_exposures": 12102750,
|
| 31 |
+
"unique_target_cells": 8938607
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"recipes": 8192,
|
| 35 |
+
"schedule_slot": 1,
|
| 36 |
+
"target_exposures": 12102750,
|
| 37 |
+
"unique_target_cells": 9021563
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"recipes": 8192,
|
| 41 |
+
"schedule_slot": 2,
|
| 42 |
+
"target_exposures": 12102750,
|
| 43 |
+
"unique_target_cells": 9003557
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"recipes": 8192,
|
| 47 |
+
"schedule_slot": 3,
|
| 48 |
+
"target_exposures": 12102750,
|
| 49 |
+
"unique_target_cells": 9008917
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"recipes": 8192,
|
| 53 |
+
"schedule_slot": 4,
|
| 54 |
+
"target_exposures": 12102750,
|
| 55 |
+
"unique_target_cells": 9013180
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"recipes": 8192,
|
| 59 |
+
"schedule_slot": 5,
|
| 60 |
+
"target_exposures": 12102750,
|
| 61 |
+
"unique_target_cells": 9012802
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"recipes": 8192,
|
| 65 |
+
"schedule_slot": 6,
|
| 66 |
+
"target_exposures": 12102750,
|
| 67 |
+
"unique_target_cells": 8946887
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"recipes": 8192,
|
| 71 |
+
"schedule_slot": 7,
|
| 72 |
+
"target_exposures": 12102750,
|
| 73 |
+
"unique_target_cells": 9026739
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"recipes": 8192,
|
| 77 |
+
"schedule_slot": 8,
|
| 78 |
+
"target_exposures": 12102750,
|
| 79 |
+
"unique_target_cells": 8991366
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"recipes": 8192,
|
| 83 |
+
"schedule_slot": 9,
|
| 84 |
+
"target_exposures": 12102750,
|
| 85 |
+
"unique_target_cells": 9054628
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"recipes": 8192,
|
| 89 |
+
"schedule_slot": 10,
|
| 90 |
+
"target_exposures": 12102750,
|
| 91 |
+
"unique_target_cells": 8984395
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"recipes": 8192,
|
| 95 |
+
"schedule_slot": 11,
|
| 96 |
+
"target_exposures": 12102750,
|
| 97 |
+
"unique_target_cells": 8994772
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"recipes": 8192,
|
| 101 |
+
"schedule_slot": 12,
|
| 102 |
+
"target_exposures": 12102750,
|
| 103 |
+
"unique_target_cells": 8988810
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"recipes": 8192,
|
| 107 |
+
"schedule_slot": 13,
|
| 108 |
+
"target_exposures": 12102750,
|
| 109 |
+
"unique_target_cells": 8999657
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"recipes": 8192,
|
| 113 |
+
"schedule_slot": 14,
|
| 114 |
+
"target_exposures": 12102750,
|
| 115 |
+
"unique_target_cells": 9047105
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"recipes": 8192,
|
| 119 |
+
"schedule_slot": 15,
|
| 120 |
+
"target_exposures": 12102750,
|
| 121 |
+
"unique_target_cells": 8978408
|
| 122 |
+
}
|
| 123 |
+
],
|
| 124 |
+
"source_cells_all_splits": 41395184,
|
| 125 |
+
"status": "PASS",
|
| 126 |
+
"train_recipe_ids_in_part_order_sha256": "f108bbbb1acd5c8cf8a33e11423ba87b8fbc80e89878cc4be2eaeaa641c640a9",
|
| 127 |
+
"train_recipes": 131072,
|
| 128 |
+
"train_samples": 5232,
|
| 129 |
+
"train_universe": {
|
| 130 |
+
"cell_coverage_fraction": 0.9397752899849071,
|
| 131 |
+
"mean_visits_all_cells": 5.8429673115603515,
|
| 132 |
+
"mean_visits_represented_cells": 6.217408963428045,
|
| 133 |
+
"never_visited_cells": 1995930,
|
| 134 |
+
"represented_cells": 31145450,
|
| 135 |
+
"target_exposures": 193644000,
|
| 136 |
+
"universe_cells": 33141380,
|
| 137 |
+
"visits_q00": 0.0,
|
| 138 |
+
"visits_q01": 0.0,
|
| 139 |
+
"visits_q05": 0.0,
|
| 140 |
+
"visits_q100": 228.0,
|
| 141 |
+
"visits_q25": 2.0,
|
| 142 |
+
"visits_q50": 4.0,
|
| 143 |
+
"visits_q75": 8.0,
|
| 144 |
+
"visits_q90": 12.0,
|
| 145 |
+
"visits_q95": 16.0,
|
| 146 |
+
"visits_q99": 29.0
|
| 147 |
+
},
|
| 148 |
+
"unique_train_member_sets": 131049,
|
| 149 |
+
"unique_train_recipe_ids": 131072,
|
| 150 |
+
"unique_train_recipe_seed_keys": 131072,
|
| 151 |
+
"unregistered_train_cells": 285340,
|
| 152 |
+
"unregistered_train_samples": 383
|
| 153 |
+
}
|
provenance/implementations/panel_ladder.py
ADDED
|
@@ -0,0 +1,1981 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Versioned, train-only PBISC gene-panel ladder publication.
|
| 2 |
+
|
| 3 |
+
The legacy :mod:`pbisc_sdd.gene_selection` module is intentionally left
|
| 4 |
+
unchanged because published v1 artifacts bind its file hash. This module
|
| 5 |
+
reuses that ranking kernel, computes one total order for the canonical gene
|
| 6 |
+
panel, and derives every finite tier from a prefix of that order.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
from dataclasses import dataclass
|
| 12 |
+
import hashlib
|
| 13 |
+
import inspect
|
| 14 |
+
import io
|
| 15 |
+
import json
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
import re
|
| 18 |
+
import shutil
|
| 19 |
+
import sys
|
| 20 |
+
import tempfile
|
| 21 |
+
from typing import Any, Mapping, Sequence
|
| 22 |
+
|
| 23 |
+
import numpy as np
|
| 24 |
+
import pandas as pd
|
| 25 |
+
|
| 26 |
+
from .data import DEFAULT_MODEL7_ROOT
|
| 27 |
+
from .gene_selection import HVGSelection, rank_hvg_statistics
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
PANEL_LADDER_SCHEMA = "pbisc_sdd.panel_ladder.v2"
|
| 31 |
+
LEAKAGE_AUDIT_SCHEMA = "pbisc_sdd.panel_ladder.leakage_audit.v1"
|
| 32 |
+
REPLAY_PROOF_SCHEMA = "pbisc_sdd.panel_ladder.replay_proof.v1"
|
| 33 |
+
LEGACY_SELECTION_SCHEMA = "pbisc_sdd.hvg_selection.v1"
|
| 34 |
+
SUFFICIENT_STATISTICS_SCHEMA = "pbisc_sdd.panel_ladder.sufficient_statistics.v1"
|
| 35 |
+
MODEL7_IMPLEMENTATION_SCHEMA = "pbisc_sdd.panel_ladder.model7_implementation.v1"
|
| 36 |
+
DEFAULT_TIER_SIZES: Mapping[str, int] = {"2k": 2_000, "3k": 3_000, "6k": 6_000}
|
| 37 |
+
REPLAY_PARAMETER_KEYS = (
|
| 38 |
+
"recipes",
|
| 39 |
+
"cells_per_recipe",
|
| 40 |
+
"mean_bins",
|
| 41 |
+
"target_sum",
|
| 42 |
+
"seed",
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
ORDERED_RECIPE_COLUMNS = (
|
| 46 |
+
"recipe_order",
|
| 47 |
+
"stream_recipe_index",
|
| 48 |
+
"recipe_id",
|
| 49 |
+
"block_id",
|
| 50 |
+
"recipe_index",
|
| 51 |
+
"schedule_slot",
|
| 52 |
+
"split",
|
| 53 |
+
"platform",
|
| 54 |
+
"validation_scope",
|
| 55 |
+
"heldout",
|
| 56 |
+
"sample_key",
|
| 57 |
+
"dataset_id",
|
| 58 |
+
"donor_id",
|
| 59 |
+
"sample_id",
|
| 60 |
+
"k",
|
| 61 |
+
"rng_seed",
|
| 62 |
+
"sampling_policy",
|
| 63 |
+
)
|
| 64 |
+
SAMPLED_CELL_REFERENCE_COLUMNS = (
|
| 65 |
+
"sample_order",
|
| 66 |
+
"recipe_order",
|
| 67 |
+
"chosen_order_within_recipe",
|
| 68 |
+
"recipe_id",
|
| 69 |
+
"block_id",
|
| 70 |
+
"sample_key",
|
| 71 |
+
"ref_position_in_recipe",
|
| 72 |
+
"selection_occurrence_id",
|
| 73 |
+
"segment_index",
|
| 74 |
+
"shard_id",
|
| 75 |
+
"count_zarr",
|
| 76 |
+
"source_coordinate_id",
|
| 77 |
+
"strict_row_index",
|
| 78 |
+
"row_index",
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
class ReplayMismatchError(ValueError):
|
| 83 |
+
"""Raised before publication when a requested legacy replay is not exact."""
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
@dataclass(frozen=True)
|
| 87 |
+
class FullGeneRanking:
|
| 88 |
+
"""Tier-independent ranking and statistics for every canonical gene."""
|
| 89 |
+
|
| 90 |
+
ranked_positions: np.ndarray
|
| 91 |
+
universal_rank: np.ndarray
|
| 92 |
+
eligible_rank: np.ndarray
|
| 93 |
+
eligible: np.ndarray
|
| 94 |
+
eligibility_reason: tuple[str, ...]
|
| 95 |
+
mean_log1p: np.ndarray
|
| 96 |
+
variance_log1p: np.ndarray
|
| 97 |
+
log_dispersion: np.ndarray
|
| 98 |
+
normalized_dispersion: np.ndarray
|
| 99 |
+
measured_cells: np.ndarray
|
| 100 |
+
detected_cells: np.ndarray
|
| 101 |
+
marker_mask: np.ndarray
|
| 102 |
+
|
| 103 |
+
@property
|
| 104 |
+
def n_genes(self) -> int:
|
| 105 |
+
return int(self.ranked_positions.size)
|
| 106 |
+
|
| 107 |
+
@property
|
| 108 |
+
def n_eligible(self) -> int:
|
| 109 |
+
return int(self.eligible.sum())
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
@dataclass(frozen=True)
|
| 113 |
+
class PanelLadderSelection:
|
| 114 |
+
"""One full ranking plus canonical-order tensor subsets for every tier."""
|
| 115 |
+
|
| 116 |
+
full_ranking: FullGeneRanking
|
| 117 |
+
tiers: Mapping[str, np.ndarray]
|
| 118 |
+
sampled_cells: int
|
| 119 |
+
sampled_recipes: int
|
| 120 |
+
corpus_fingerprint: str
|
| 121 |
+
gene_panel_sha256: str
|
| 122 |
+
min_measured_cells: int
|
| 123 |
+
min_detected_cells: int
|
| 124 |
+
leakage_audit: Mapping[str, object]
|
| 125 |
+
provenance: TrainSelectionProvenance | None = None
|
| 126 |
+
sufficient_statistics: BoundSufficientStatistics | None = None
|
| 127 |
+
model7_implementation: Mapping[str, object] | None = None
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
@dataclass(frozen=True)
|
| 131 |
+
class TrainSelectionProvenance:
|
| 132 |
+
"""Exact ordered recipes and cell references used to compute train statistics."""
|
| 133 |
+
|
| 134 |
+
ordered_train_recipes: pd.DataFrame
|
| 135 |
+
sampled_cell_references: pd.DataFrame
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
@dataclass(frozen=True)
|
| 139 |
+
class BoundSufficientStatistics:
|
| 140 |
+
"""Raw statistic arrays retained so publication can revalidate and re-rank."""
|
| 141 |
+
|
| 142 |
+
value_sum: np.ndarray
|
| 143 |
+
value_square_sum: np.ndarray
|
| 144 |
+
measured_cells: np.ndarray
|
| 145 |
+
detected_cells: np.ndarray
|
| 146 |
+
binding: Mapping[str, object]
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
@dataclass(frozen=True)
|
| 150 |
+
class TrainPanelStatistics:
|
| 151 |
+
"""Sufficient statistics and exact provenance from one train-only pass."""
|
| 152 |
+
|
| 153 |
+
value_sum: np.ndarray
|
| 154 |
+
value_square_sum: np.ndarray
|
| 155 |
+
measured_cells: np.ndarray
|
| 156 |
+
detected_cells: np.ndarray
|
| 157 |
+
sampled_cells: int
|
| 158 |
+
sampled_recipes: int
|
| 159 |
+
corpus_fingerprint: str
|
| 160 |
+
gene_panel: Any
|
| 161 |
+
leakage_audit: Mapping[str, object]
|
| 162 |
+
provenance: TrainSelectionProvenance
|
| 163 |
+
min_measured_cells: int
|
| 164 |
+
min_detected_cells: int
|
| 165 |
+
mean_bins: int
|
| 166 |
+
sufficient_statistics_binding: Mapping[str, object]
|
| 167 |
+
model7_implementation: Mapping[str, object]
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def _sha256_bytes(data: bytes) -> str:
|
| 171 |
+
return hashlib.sha256(data).hexdigest()
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def sha256_file(path: Path | str) -> str:
|
| 175 |
+
"""Return a streaming SHA-256 digest for a local file."""
|
| 176 |
+
|
| 177 |
+
digest = hashlib.sha256()
|
| 178 |
+
with Path(path).open("rb") as handle:
|
| 179 |
+
for chunk in iter(lambda: handle.read(1024 * 1024), b""):
|
| 180 |
+
digest.update(chunk)
|
| 181 |
+
return digest.hexdigest()
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
def _json_ready(value: object) -> object:
|
| 185 |
+
if isinstance(value, Mapping):
|
| 186 |
+
return {str(key): _json_ready(item) for key, item in value.items()}
|
| 187 |
+
if isinstance(value, (list, tuple)):
|
| 188 |
+
return [_json_ready(item) for item in value]
|
| 189 |
+
if isinstance(value, Path):
|
| 190 |
+
return str(value)
|
| 191 |
+
if isinstance(value, np.integer):
|
| 192 |
+
return int(value)
|
| 193 |
+
if isinstance(value, np.floating):
|
| 194 |
+
value = float(value)
|
| 195 |
+
if isinstance(value, float):
|
| 196 |
+
if not np.isfinite(value):
|
| 197 |
+
raise ValueError("manifest values must not contain NaN or Inf")
|
| 198 |
+
return value
|
| 199 |
+
if value is None or isinstance(value, (str, int, bool)):
|
| 200 |
+
return value
|
| 201 |
+
raise TypeError(f"unsupported manifest value: {type(value).__name__}")
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def _canonical_json_bytes(value: object) -> bytes:
|
| 205 |
+
return json.dumps(
|
| 206 |
+
_json_ready(value),
|
| 207 |
+
allow_nan=False,
|
| 208 |
+
ensure_ascii=False,
|
| 209 |
+
separators=(",", ":"),
|
| 210 |
+
sort_keys=True,
|
| 211 |
+
).encode("utf-8")
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def canonical_sha256(value: object) -> str:
|
| 215 |
+
"""Hash a JSON-compatible value using a stable canonical encoding."""
|
| 216 |
+
|
| 217 |
+
return _sha256_bytes(_canonical_json_bytes(value))
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
def _array_content_binding(
|
| 221 |
+
value: np.ndarray, *, dtype: np.dtype[Any], name: str
|
| 222 |
+
) -> tuple[np.ndarray, dict[str, object]]:
|
| 223 |
+
array = np.asarray(value)
|
| 224 |
+
expected_dtype = np.dtype(dtype)
|
| 225 |
+
if array.dtype != expected_dtype:
|
| 226 |
+
raise ValueError(f"{name} must have dtype {expected_dtype.name}")
|
| 227 |
+
if array.ndim != 1:
|
| 228 |
+
raise ValueError(f"{name} must be a 1-D vector")
|
| 229 |
+
canonical = np.ascontiguousarray(array.astype(expected_dtype.newbyteorder("<"), copy=False))
|
| 230 |
+
if np.issubdtype(expected_dtype, np.floating) and not np.isfinite(canonical).all():
|
| 231 |
+
raise ValueError(f"{name} contains NaN or Inf")
|
| 232 |
+
if np.issubdtype(expected_dtype, np.integer) and bool((canonical < 0).any()):
|
| 233 |
+
raise ValueError(f"{name} contains negative counts")
|
| 234 |
+
return canonical, {
|
| 235 |
+
"dtype": expected_dtype.name,
|
| 236 |
+
"shape": [int(canonical.size)],
|
| 237 |
+
"content_sha256": _sha256_bytes(canonical.tobytes(order="C")),
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def build_sufficient_statistics_binding(
|
| 242 |
+
*,
|
| 243 |
+
value_sum: np.ndarray,
|
| 244 |
+
value_square_sum: np.ndarray,
|
| 245 |
+
measured_cells: np.ndarray,
|
| 246 |
+
detected_cells: np.ndarray,
|
| 247 |
+
sampled_cells: int,
|
| 248 |
+
sampled_recipes: int,
|
| 249 |
+
corpus_fingerprint: str,
|
| 250 |
+
min_measured_cells: int,
|
| 251 |
+
min_detected_cells: int,
|
| 252 |
+
mean_bins: int,
|
| 253 |
+
collection_parameters: Mapping[str, object],
|
| 254 |
+
) -> dict[str, object]:
|
| 255 |
+
"""Build a deterministic digest over raw selection statistics and their context."""
|
| 256 |
+
|
| 257 |
+
arrays: dict[str, object] = {}
|
| 258 |
+
shapes: set[int] = set()
|
| 259 |
+
for name, value, dtype in (
|
| 260 |
+
("value_sum", value_sum, np.dtype(np.float64)),
|
| 261 |
+
("value_square_sum", value_square_sum, np.dtype(np.float64)),
|
| 262 |
+
("measured_cells", measured_cells, np.dtype(np.int64)),
|
| 263 |
+
("detected_cells", detected_cells, np.dtype(np.int64)),
|
| 264 |
+
):
|
| 265 |
+
canonical, descriptor = _array_content_binding(value, dtype=dtype, name=name)
|
| 266 |
+
shapes.add(int(canonical.size))
|
| 267 |
+
arrays[name] = descriptor
|
| 268 |
+
if len(shapes) != 1 or next(iter(shapes)) <= 0:
|
| 269 |
+
raise ValueError("sufficient-statistic arrays must be non-empty and aligned")
|
| 270 |
+
core: dict[str, object] = {
|
| 271 |
+
"schema_version": SUFFICIENT_STATISTICS_SCHEMA,
|
| 272 |
+
"arrays": arrays,
|
| 273 |
+
"n_genes": next(iter(shapes)),
|
| 274 |
+
"sampled_cells": int(sampled_cells),
|
| 275 |
+
"sampled_recipes": int(sampled_recipes),
|
| 276 |
+
"corpus_fingerprint": str(corpus_fingerprint),
|
| 277 |
+
"min_measured_cells": int(min_measured_cells),
|
| 278 |
+
"min_detected_cells": int(min_detected_cells),
|
| 279 |
+
"mean_bins": int(mean_bins),
|
| 280 |
+
"collection_parameters": dict(collection_parameters),
|
| 281 |
+
}
|
| 282 |
+
if int(sampled_cells) <= 0 or int(sampled_recipes) <= 0:
|
| 283 |
+
raise ValueError("sampled cell and recipe counts must be positive")
|
| 284 |
+
if int(min_measured_cells) <= 0 or int(min_detected_cells) <= 0:
|
| 285 |
+
raise ValueError("selection thresholds must be positive")
|
| 286 |
+
if int(mean_bins) <= 0:
|
| 287 |
+
raise ValueError("mean_bins must be positive")
|
| 288 |
+
return {**core, "binding_sha256": canonical_sha256(core)}
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
def _validate_sufficient_statistics_binding(
|
| 292 |
+
statistics: BoundSufficientStatistics,
|
| 293 |
+
*,
|
| 294 |
+
sampled_cells: int,
|
| 295 |
+
sampled_recipes: int,
|
| 296 |
+
corpus_fingerprint: str,
|
| 297 |
+
min_measured_cells: int,
|
| 298 |
+
min_detected_cells: int,
|
| 299 |
+
mean_bins: int,
|
| 300 |
+
) -> str:
|
| 301 |
+
binding = statistics.binding
|
| 302 |
+
collection_parameters = binding.get("collection_parameters")
|
| 303 |
+
if not isinstance(collection_parameters, Mapping):
|
| 304 |
+
raise ValueError("sufficient-statistics binding lacks collection parameters")
|
| 305 |
+
expected = build_sufficient_statistics_binding(
|
| 306 |
+
value_sum=statistics.value_sum,
|
| 307 |
+
value_square_sum=statistics.value_square_sum,
|
| 308 |
+
measured_cells=statistics.measured_cells,
|
| 309 |
+
detected_cells=statistics.detected_cells,
|
| 310 |
+
sampled_cells=sampled_cells,
|
| 311 |
+
sampled_recipes=sampled_recipes,
|
| 312 |
+
corpus_fingerprint=corpus_fingerprint,
|
| 313 |
+
min_measured_cells=min_measured_cells,
|
| 314 |
+
min_detected_cells=min_detected_cells,
|
| 315 |
+
mean_bins=mean_bins,
|
| 316 |
+
collection_parameters=collection_parameters,
|
| 317 |
+
)
|
| 318 |
+
if dict(binding) != expected:
|
| 319 |
+
raise ValueError("sufficient-statistics binding or arrays differ")
|
| 320 |
+
return str(expected["binding_sha256"])
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def bind_model7_implementation(data_module: Any) -> dict[str, object]:
|
| 324 |
+
"""Bind the concrete Model7 class and methods used for selection I/O."""
|
| 325 |
+
|
| 326 |
+
method_names = (
|
| 327 |
+
"split_manifest",
|
| 328 |
+
"prime_pools",
|
| 329 |
+
"_recipe_refs_and_pools",
|
| 330 |
+
"_load_sparse_refs",
|
| 331 |
+
"_zarr_group",
|
| 332 |
+
)
|
| 333 |
+
data_class = type(data_module)
|
| 334 |
+
methods: dict[str, object] = {}
|
| 335 |
+
for name in method_names:
|
| 336 |
+
method = getattr(data_class, name, None)
|
| 337 |
+
if method is None:
|
| 338 |
+
raise ValueError(f"Model7 data module lacks required method: {name}")
|
| 339 |
+
source_name = inspect.getsourcefile(method) or inspect.getfile(method)
|
| 340 |
+
source_path = Path(source_name).resolve()
|
| 341 |
+
if not source_path.is_file():
|
| 342 |
+
raise FileNotFoundError(f"Model7 implementation source not found: {source_path}")
|
| 343 |
+
methods[name] = {
|
| 344 |
+
"qualified_name": f"{data_class.__module__}.{data_class.__qualname__}.{name}",
|
| 345 |
+
"path": str(source_path),
|
| 346 |
+
"sha256": sha256_file(source_path),
|
| 347 |
+
}
|
| 348 |
+
core: dict[str, object] = {
|
| 349 |
+
"schema_version": MODEL7_IMPLEMENTATION_SCHEMA,
|
| 350 |
+
"data_module_class": f"{data_class.__module__}.{data_class.__qualname__}",
|
| 351 |
+
"methods": methods,
|
| 352 |
+
}
|
| 353 |
+
return {**core, "bundle_sha256": canonical_sha256(core)}
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
def _validate_model7_implementation(binding: Mapping[str, object]) -> str:
|
| 357 |
+
if binding.get("schema_version") != MODEL7_IMPLEMENTATION_SCHEMA:
|
| 358 |
+
raise ValueError("unsupported Model7 implementation binding schema")
|
| 359 |
+
methods = binding.get("methods")
|
| 360 |
+
if not isinstance(methods, Mapping):
|
| 361 |
+
raise ValueError("Model7 implementation binding lacks methods")
|
| 362 |
+
required = {
|
| 363 |
+
"split_manifest",
|
| 364 |
+
"prime_pools",
|
| 365 |
+
"_recipe_refs_and_pools",
|
| 366 |
+
"_load_sparse_refs",
|
| 367 |
+
"_zarr_group",
|
| 368 |
+
}
|
| 369 |
+
if set(str(name) for name in methods) != required:
|
| 370 |
+
raise ValueError("Model7 implementation binding method set differs")
|
| 371 |
+
for name, raw_entry in methods.items():
|
| 372 |
+
if not isinstance(raw_entry, Mapping):
|
| 373 |
+
raise ValueError(f"Model7 method binding is invalid: {name}")
|
| 374 |
+
path = Path(str(raw_entry.get("path", ""))).resolve()
|
| 375 |
+
if not path.is_file() or sha256_file(path) != raw_entry.get("sha256"):
|
| 376 |
+
raise ValueError(f"Model7 implementation changed: {name}")
|
| 377 |
+
core = {key: value for key, value in binding.items() if key != "bundle_sha256"}
|
| 378 |
+
expected = canonical_sha256(core)
|
| 379 |
+
if binding.get("bundle_sha256") != expected:
|
| 380 |
+
raise ValueError("Model7 implementation bundle hash differs")
|
| 381 |
+
return expected
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
def _write_json(path: Path, value: object) -> None:
|
| 385 |
+
path.write_bytes(_json_file_bytes(value))
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
def _json_file_bytes(value: object) -> bytes:
|
| 389 |
+
return (
|
| 390 |
+
json.dumps(
|
| 391 |
+
_json_ready(value),
|
| 392 |
+
allow_nan=False,
|
| 393 |
+
ensure_ascii=False,
|
| 394 |
+
indent=2,
|
| 395 |
+
sort_keys=True,
|
| 396 |
+
)
|
| 397 |
+
+ "\n"
|
| 398 |
+
).encode("utf-8")
|
| 399 |
+
|
| 400 |
+
|
| 401 |
+
def gene_panel_identity_sha256(gene_panel: Any) -> str:
|
| 402 |
+
"""Hash canonical gene identity and tensor order, independent of file format."""
|
| 403 |
+
|
| 404 |
+
columns = set(getattr(gene_panel, "columns", ()))
|
| 405 |
+
required = {"gene_id", "gene_symbol"}
|
| 406 |
+
if not required.issubset(columns):
|
| 407 |
+
missing = sorted(required.difference(columns))
|
| 408 |
+
raise ValueError(f"gene panel lacks required columns: {missing}")
|
| 409 |
+
panel = gene_panel.reset_index(drop=True)
|
| 410 |
+
if panel.empty:
|
| 411 |
+
raise ValueError("gene panel is empty")
|
| 412 |
+
identity_columns = ["gene_id", "gene_symbol"]
|
| 413 |
+
if "panel_index" in columns:
|
| 414 |
+
identity_columns.append("panel_index")
|
| 415 |
+
rows: list[dict[str, object]] = []
|
| 416 |
+
for position, row in panel[identity_columns].iterrows():
|
| 417 |
+
item: dict[str, object] = {
|
| 418 |
+
"canonical_tensor_position": int(position),
|
| 419 |
+
"gene_id": str(row["gene_id"]),
|
| 420 |
+
"gene_symbol": str(row["gene_symbol"]),
|
| 421 |
+
}
|
| 422 |
+
if "panel_index" in identity_columns:
|
| 423 |
+
item["panel_index"] = int(row["panel_index"])
|
| 424 |
+
rows.append(item)
|
| 425 |
+
return canonical_sha256(
|
| 426 |
+
{"schema_version": "pbisc_sdd.gene_panel_identity.v1", "rows": rows}
|
| 427 |
+
)
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
def train_only_leakage_audit(
|
| 431 |
+
expression_splits_accessed: Sequence[str] = ("train",),
|
| 432 |
+
*,
|
| 433 |
+
evidence: Mapping[str, object] | None = None,
|
| 434 |
+
ordered_recipe_ids_sha256: str | None = None,
|
| 435 |
+
sampled_cell_refs_sha256: str | None = None,
|
| 436 |
+
sufficient_statistics_sha256: str | None = None,
|
| 437 |
+
model7_implementation_sha256: str | None = None,
|
| 438 |
+
) -> dict[str, object]:
|
| 439 |
+
"""Validate and record the expression-data split boundary used for ranking."""
|
| 440 |
+
|
| 441 |
+
accessed = tuple(dict.fromkeys(str(split_name) for split_name in expression_splits_accessed))
|
| 442 |
+
if accessed != ("train",):
|
| 443 |
+
raise ValueError(
|
| 444 |
+
"panel ranking may access expression statistics from the train split only"
|
| 445 |
+
)
|
| 446 |
+
hex_digest = re.compile(r"[0-9a-f]{64}")
|
| 447 |
+
digests = {
|
| 448 |
+
"ordered_recipe_ids_sha256": ordered_recipe_ids_sha256,
|
| 449 |
+
"sampled_cell_refs_sha256": sampled_cell_refs_sha256,
|
| 450 |
+
"sufficient_statistics_sha256": sufficient_statistics_sha256,
|
| 451 |
+
"model7_implementation_sha256": model7_implementation_sha256,
|
| 452 |
+
}
|
| 453 |
+
for name, value in digests.items():
|
| 454 |
+
if value is not None and not hex_digest.fullmatch(value):
|
| 455 |
+
raise ValueError(f"{name} must be a lowercase SHA-256")
|
| 456 |
+
exact_recipe_ids = ordered_recipe_ids_sha256 is not None
|
| 457 |
+
exact_sample_refs = sampled_cell_refs_sha256 is not None
|
| 458 |
+
exact_statistics = sufficient_statistics_sha256 is not None
|
| 459 |
+
exact_implementation = model7_implementation_sha256 is not None
|
| 460 |
+
production_ready = bool(
|
| 461 |
+
exact_recipe_ids and exact_sample_refs and exact_statistics and exact_implementation
|
| 462 |
+
)
|
| 463 |
+
combined_binding = (
|
| 464 |
+
canonical_sha256(digests) if production_ready else None
|
| 465 |
+
)
|
| 466 |
+
return {
|
| 467 |
+
"schema_version": LEAKAGE_AUDIT_SCHEMA,
|
| 468 |
+
"status": "pass",
|
| 469 |
+
"selection_scope": "train_split_only",
|
| 470 |
+
"allowed_expression_splits": ["train"],
|
| 471 |
+
"expression_splits_accessed": ["train"],
|
| 472 |
+
"held_out_expression_accessed": False,
|
| 473 |
+
"held_out_splits": ["val", "test", "diagnostic", "evaluation"],
|
| 474 |
+
"ordered_recipe_ids_sha256": ordered_recipe_ids_sha256,
|
| 475 |
+
"exact_ordered_recipe_ids_persisted": exact_recipe_ids,
|
| 476 |
+
"sampled_cell_refs_sha256": sampled_cell_refs_sha256,
|
| 477 |
+
"exact_sample_refs_persisted": exact_sample_refs,
|
| 478 |
+
"sufficient_statistics_sha256": sufficient_statistics_sha256,
|
| 479 |
+
"exact_sufficient_statistics_bound": exact_statistics,
|
| 480 |
+
"model7_implementation_sha256": model7_implementation_sha256,
|
| 481 |
+
"exact_model7_implementation_bound": exact_implementation,
|
| 482 |
+
"provenance_statistics_binding_sha256": combined_binding,
|
| 483 |
+
"production_ready": production_ready,
|
| 484 |
+
"provenance_limitation": (
|
| 485 |
+
None
|
| 486 |
+
if production_ready
|
| 487 |
+
else (
|
| 488 |
+
"recipe IDs, sampled refs, sufficient statistics, and Model7 "
|
| 489 |
+
"implementation are not all cryptographically bound"
|
| 490 |
+
)
|
| 491 |
+
),
|
| 492 |
+
"evidence": {} if evidence is None else dict(evidence),
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
def _validate_leakage_audit(audit: Mapping[str, object]) -> None:
|
| 497 |
+
if audit.get("schema_version") != LEAKAGE_AUDIT_SCHEMA:
|
| 498 |
+
raise ValueError("unsupported train-only leakage audit schema")
|
| 499 |
+
if audit.get("status") != "pass":
|
| 500 |
+
raise ValueError("train-only leakage audit did not pass")
|
| 501 |
+
if audit.get("selection_scope") != "train_split_only":
|
| 502 |
+
raise ValueError("panel selection scope is not train-only")
|
| 503 |
+
if audit.get("expression_splits_accessed") != ["train"]:
|
| 504 |
+
raise ValueError("leakage audit includes non-train expression access")
|
| 505 |
+
if audit.get("held_out_expression_accessed") is not False:
|
| 506 |
+
raise ValueError("leakage audit reports held-out expression access")
|
| 507 |
+
exact_recipe_ids = audit.get("exact_ordered_recipe_ids_persisted") is True
|
| 508 |
+
exact_sample_refs = audit.get("exact_sample_refs_persisted") is True
|
| 509 |
+
exact_statistics = audit.get("exact_sufficient_statistics_bound") is True
|
| 510 |
+
exact_implementation = audit.get("exact_model7_implementation_bound") is True
|
| 511 |
+
if audit.get("production_ready") is True and not (
|
| 512 |
+
exact_recipe_ids and exact_sample_refs and exact_statistics and exact_implementation
|
| 513 |
+
):
|
| 514 |
+
raise ValueError("production-ready selection lacks a required exact binding")
|
| 515 |
+
if audit.get("production_ready") is True:
|
| 516 |
+
keys = (
|
| 517 |
+
"ordered_recipe_ids_sha256",
|
| 518 |
+
"sampled_cell_refs_sha256",
|
| 519 |
+
"sufficient_statistics_sha256",
|
| 520 |
+
"model7_implementation_sha256",
|
| 521 |
+
)
|
| 522 |
+
for key in keys:
|
| 523 |
+
value = audit.get(key)
|
| 524 |
+
if not isinstance(value, str) or re.fullmatch(r"[0-9a-f]{64}", value) is None:
|
| 525 |
+
raise ValueError(f"production-ready provenance lacks valid {key}")
|
| 526 |
+
expected_combined = canonical_sha256(
|
| 527 |
+
{key: audit.get(key) for key in keys}
|
| 528 |
+
)
|
| 529 |
+
if audit.get("provenance_statistics_binding_sha256") != expected_combined:
|
| 530 |
+
raise ValueError("combined provenance/statistics binding differs")
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
def _marker_mask(gene_panel: Any) -> np.ndarray:
|
| 534 |
+
marker = np.zeros(len(gene_panel), dtype=bool)
|
| 535 |
+
for column in ("is_immune_marker", "is_interferon_gene"):
|
| 536 |
+
if column in gene_panel.columns:
|
| 537 |
+
marker |= np.asarray(gene_panel[column], dtype=bool)
|
| 538 |
+
return marker
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
def _eligibility_reasons(
|
| 542 |
+
*,
|
| 543 |
+
measured_cells: np.ndarray,
|
| 544 |
+
detected_cells: np.ndarray,
|
| 545 |
+
mean_log1p: np.ndarray,
|
| 546 |
+
variance_log1p: np.ndarray,
|
| 547 |
+
normalized_dispersion: np.ndarray,
|
| 548 |
+
min_measured_cells: int,
|
| 549 |
+
min_detected_cells: int,
|
| 550 |
+
) -> tuple[np.ndarray, tuple[str, ...]]:
|
| 551 |
+
reasons: list[str] = []
|
| 552 |
+
eligible_values: list[bool] = []
|
| 553 |
+
for measured, detected, mean, variance, score in zip(
|
| 554 |
+
measured_cells,
|
| 555 |
+
detected_cells,
|
| 556 |
+
mean_log1p,
|
| 557 |
+
variance_log1p,
|
| 558 |
+
normalized_dispersion,
|
| 559 |
+
strict=True,
|
| 560 |
+
):
|
| 561 |
+
local: list[str] = []
|
| 562 |
+
if float(measured) < int(min_measured_cells):
|
| 563 |
+
local.append("below_min_measured_cells")
|
| 564 |
+
if float(detected) < int(min_detected_cells):
|
| 565 |
+
local.append("below_min_detected_cells")
|
| 566 |
+
if not np.isfinite(mean):
|
| 567 |
+
local.append("nonfinite_mean_log1p")
|
| 568 |
+
if not np.isfinite(variance):
|
| 569 |
+
local.append("nonfinite_variance_log1p")
|
| 570 |
+
if not local and not np.isfinite(score):
|
| 571 |
+
local.append("nonfinite_normalized_dispersion")
|
| 572 |
+
eligible_values.append(not local)
|
| 573 |
+
reasons.append("eligible" if not local else "|".join(local))
|
| 574 |
+
return np.asarray(eligible_values, dtype=bool), tuple(reasons)
|
| 575 |
+
|
| 576 |
+
|
| 577 |
+
def _full_ranking(
|
| 578 |
+
*,
|
| 579 |
+
mean_log1p: np.ndarray,
|
| 580 |
+
variance_log1p: np.ndarray,
|
| 581 |
+
normalized_dispersion: np.ndarray,
|
| 582 |
+
measured_cells: np.ndarray,
|
| 583 |
+
detected_cells: np.ndarray,
|
| 584 |
+
marker_mask: np.ndarray,
|
| 585 |
+
min_measured_cells: int,
|
| 586 |
+
min_detected_cells: int,
|
| 587 |
+
) -> FullGeneRanking:
|
| 588 |
+
arrays = [
|
| 589 |
+
np.asarray(mean_log1p),
|
| 590 |
+
np.asarray(variance_log1p),
|
| 591 |
+
np.asarray(normalized_dispersion),
|
| 592 |
+
np.asarray(measured_cells),
|
| 593 |
+
np.asarray(detected_cells),
|
| 594 |
+
np.asarray(marker_mask),
|
| 595 |
+
]
|
| 596 |
+
shape = arrays[0].shape
|
| 597 |
+
if len(shape) != 1 or any(array.shape != shape for array in arrays):
|
| 598 |
+
raise ValueError("all full-ranking arrays must be aligned 1-D vectors")
|
| 599 |
+
if shape[0] == 0:
|
| 600 |
+
raise ValueError("full ranking requires at least one gene")
|
| 601 |
+
mean = np.asarray(mean_log1p, dtype=np.float32)
|
| 602 |
+
variance = np.asarray(variance_log1p, dtype=np.float32)
|
| 603 |
+
score = np.asarray(normalized_dispersion, dtype=np.float32)
|
| 604 |
+
measured = np.asarray(measured_cells, dtype=np.int64)
|
| 605 |
+
detected = np.asarray(detected_cells, dtype=np.int64)
|
| 606 |
+
marker = np.asarray(marker_mask, dtype=bool)
|
| 607 |
+
eligible, reasons = _eligibility_reasons(
|
| 608 |
+
measured_cells=measured,
|
| 609 |
+
detected_cells=detected,
|
| 610 |
+
mean_log1p=mean,
|
| 611 |
+
variance_log1p=variance,
|
| 612 |
+
normalized_dispersion=score,
|
| 613 |
+
min_measured_cells=min_measured_cells,
|
| 614 |
+
min_detected_cells=min_detected_cells,
|
| 615 |
+
)
|
| 616 |
+
if not bool(eligible.any()):
|
| 617 |
+
raise ValueError("no genes pass panel-ladder eligibility")
|
| 618 |
+
canonical = np.arange(shape[0], dtype=np.int64)
|
| 619 |
+
ranked = np.lexsort((canonical, -score, -(marker & eligible).astype(np.int8))).astype(
|
| 620 |
+
np.int64, copy=False
|
| 621 |
+
)
|
| 622 |
+
if not bool(eligible[ranked[: int(eligible.sum())]].all()):
|
| 623 |
+
raise RuntimeError("eligible genes are not a contiguous ranking prefix")
|
| 624 |
+
universal_rank = np.empty(shape[0], dtype=np.int64)
|
| 625 |
+
universal_rank[ranked] = np.arange(1, shape[0] + 1, dtype=np.int64)
|
| 626 |
+
eligible_rank = np.zeros(shape[0], dtype=np.int64)
|
| 627 |
+
eligible_rank[ranked[: int(eligible.sum())]] = np.arange(
|
| 628 |
+
1, int(eligible.sum()) + 1, dtype=np.int64
|
| 629 |
+
)
|
| 630 |
+
with np.errstate(divide="ignore", invalid="ignore", over="ignore"):
|
| 631 |
+
log_dispersion = np.log1p(
|
| 632 |
+
variance.astype(np.float64) / np.maximum(mean.astype(np.float64), 1.0e-8)
|
| 633 |
+
).astype(np.float32)
|
| 634 |
+
return FullGeneRanking(
|
| 635 |
+
ranked_positions=ranked,
|
| 636 |
+
universal_rank=universal_rank,
|
| 637 |
+
eligible_rank=eligible_rank,
|
| 638 |
+
eligible=eligible,
|
| 639 |
+
eligibility_reason=reasons,
|
| 640 |
+
mean_log1p=mean,
|
| 641 |
+
variance_log1p=variance,
|
| 642 |
+
log_dispersion=log_dispersion,
|
| 643 |
+
normalized_dispersion=score,
|
| 644 |
+
measured_cells=measured,
|
| 645 |
+
detected_cells=detected,
|
| 646 |
+
marker_mask=marker,
|
| 647 |
+
)
|
| 648 |
+
|
| 649 |
+
|
| 650 |
+
def rank_hvg_full_statistics(
|
| 651 |
+
*,
|
| 652 |
+
value_sum: np.ndarray,
|
| 653 |
+
value_square_sum: np.ndarray,
|
| 654 |
+
measured_cells: np.ndarray,
|
| 655 |
+
detected_cells: np.ndarray,
|
| 656 |
+
marker_mask: np.ndarray,
|
| 657 |
+
min_measured_cells: int,
|
| 658 |
+
min_detected_cells: int,
|
| 659 |
+
mean_bins: int = 20,
|
| 660 |
+
) -> FullGeneRanking:
|
| 661 |
+
"""Run the sealed v1 scoring kernel once and return a total gene ranking."""
|
| 662 |
+
|
| 663 |
+
_, mean, variance, score = rank_hvg_statistics(
|
| 664 |
+
value_sum=value_sum,
|
| 665 |
+
value_square_sum=value_square_sum,
|
| 666 |
+
measured_cells=measured_cells,
|
| 667 |
+
detected_cells=detected_cells,
|
| 668 |
+
marker_mask=marker_mask,
|
| 669 |
+
n_genes=1,
|
| 670 |
+
min_measured_cells=min_measured_cells,
|
| 671 |
+
min_detected_cells=min_detected_cells,
|
| 672 |
+
mean_bins=mean_bins,
|
| 673 |
+
)
|
| 674 |
+
return _full_ranking(
|
| 675 |
+
mean_log1p=mean,
|
| 676 |
+
variance_log1p=variance,
|
| 677 |
+
normalized_dispersion=score,
|
| 678 |
+
measured_cells=measured_cells,
|
| 679 |
+
detected_cells=detected_cells,
|
| 680 |
+
marker_mask=marker_mask,
|
| 681 |
+
min_measured_cells=min_measured_cells,
|
| 682 |
+
min_detected_cells=min_detected_cells,
|
| 683 |
+
)
|
| 684 |
+
|
| 685 |
+
|
| 686 |
+
def _normalise_tier_sizes(
|
| 687 |
+
tier_sizes: Mapping[str, int] | Sequence[int],
|
| 688 |
+
) -> tuple[tuple[str, int], ...]:
|
| 689 |
+
if isinstance(tier_sizes, Mapping):
|
| 690 |
+
items = [(str(name).lower(), int(size)) for name, size in tier_sizes.items()]
|
| 691 |
+
else:
|
| 692 |
+
items = []
|
| 693 |
+
for raw_size in tier_sizes:
|
| 694 |
+
size = int(raw_size)
|
| 695 |
+
name = f"{size // 1000}k" if size >= 1000 and size % 1000 == 0 else str(size)
|
| 696 |
+
items.append((name, size))
|
| 697 |
+
if not items:
|
| 698 |
+
raise ValueError("at least one finite panel tier is required")
|
| 699 |
+
names = [name for name, _ in items]
|
| 700 |
+
sizes = [size for _, size in items]
|
| 701 |
+
if "broad" in names:
|
| 702 |
+
raise ValueError("the broad tier is created automatically")
|
| 703 |
+
if len(set(names)) != len(names) or len(set(sizes)) != len(sizes):
|
| 704 |
+
raise ValueError("finite panel tier names and sizes must be unique")
|
| 705 |
+
if any(not re.fullmatch(r"[a-z0-9][a-z0-9_-]*", name) for name in names):
|
| 706 |
+
raise ValueError("panel tier names must be safe lowercase path components")
|
| 707 |
+
if any(size <= 0 for size in sizes):
|
| 708 |
+
raise ValueError("panel tier sizes must be positive")
|
| 709 |
+
return tuple(sorted(items, key=lambda item: item[1]))
|
| 710 |
+
|
| 711 |
+
|
| 712 |
+
def _provenance_hashes(
|
| 713 |
+
provenance: TrainSelectionProvenance,
|
| 714 |
+
) -> tuple[str, str]:
|
| 715 |
+
recipes = provenance.ordered_train_recipes
|
| 716 |
+
references = provenance.sampled_cell_references
|
| 717 |
+
if tuple(recipes.columns) != ORDERED_RECIPE_COLUMNS:
|
| 718 |
+
raise ValueError("ordered train-recipe provenance columns differ")
|
| 719 |
+
if tuple(references.columns) != SAMPLED_CELL_REFERENCE_COLUMNS:
|
| 720 |
+
raise ValueError("sampled-cell provenance columns differ")
|
| 721 |
+
return (
|
| 722 |
+
_sha256_bytes(_csv_bytes(recipes)),
|
| 723 |
+
_sha256_bytes(_csv_bytes(references)),
|
| 724 |
+
)
|
| 725 |
+
|
| 726 |
+
|
| 727 |
+
def _validate_provenance(
|
| 728 |
+
provenance: TrainSelectionProvenance,
|
| 729 |
+
*,
|
| 730 |
+
sampled_recipes: int,
|
| 731 |
+
sampled_cells: int,
|
| 732 |
+
corpus_fingerprint: str,
|
| 733 |
+
leakage_audit: Mapping[str, object],
|
| 734 |
+
) -> tuple[str, str]:
|
| 735 |
+
recipes = provenance.ordered_train_recipes
|
| 736 |
+
references = provenance.sampled_cell_references
|
| 737 |
+
if len(recipes) != int(sampled_recipes):
|
| 738 |
+
raise ValueError("ordered recipe provenance row count differs")
|
| 739 |
+
if len(references) != int(sampled_cells):
|
| 740 |
+
raise ValueError("sampled-cell provenance row count differs")
|
| 741 |
+
if recipes["recipe_order"].tolist() != list(range(len(recipes))):
|
| 742 |
+
raise ValueError("ordered recipe provenance is not in stable selection order")
|
| 743 |
+
if recipes["stream_recipe_index"].tolist() != list(range(len(recipes))):
|
| 744 |
+
raise ValueError("Model7 stream recipe order differs from persisted recipe order")
|
| 745 |
+
if references["sample_order"].tolist() != list(range(len(references))):
|
| 746 |
+
raise ValueError("sampled-cell provenance is not in stable chosen order")
|
| 747 |
+
if not recipes["split"].astype(str).eq("train").all():
|
| 748 |
+
raise ValueError("ordered recipe provenance contains a held-out split")
|
| 749 |
+
if recipes["heldout"].astype(bool).any():
|
| 750 |
+
raise ValueError("ordered recipe provenance contains held-out recipes")
|
| 751 |
+
recipe_identity = {
|
| 752 |
+
int(row.recipe_order): (
|
| 753 |
+
str(row.recipe_id),
|
| 754 |
+
str(row.block_id),
|
| 755 |
+
str(row.sample_key),
|
| 756 |
+
)
|
| 757 |
+
for row in recipes.itertuples(index=False)
|
| 758 |
+
}
|
| 759 |
+
for row in references.itertuples(index=False):
|
| 760 |
+
expected = recipe_identity.get(int(row.recipe_order))
|
| 761 |
+
actual = (str(row.recipe_id), str(row.block_id), str(row.sample_key))
|
| 762 |
+
if expected is None or actual != expected:
|
| 763 |
+
raise ValueError("sampled-cell reference does not bind its recipe identity")
|
| 764 |
+
if int(row.chosen_order_within_recipe) < 0 or int(row.ref_position_in_recipe) < 0:
|
| 765 |
+
raise ValueError("sampled-cell reference contains a negative order/index")
|
| 766 |
+
if int(row.segment_index) < 0 or int(row.row_index) < 0:
|
| 767 |
+
raise ValueError("sampled-cell reference contains a negative source coordinate")
|
| 768 |
+
if int(row.strict_row_index) != int(row.row_index):
|
| 769 |
+
raise ValueError("strict and compatibility row indices differ")
|
| 770 |
+
if not str(row.shard_id) or not str(row.count_zarr):
|
| 771 |
+
raise ValueError("sampled-cell reference lacks source-shard identity")
|
| 772 |
+
expected_occurrence = canonical_sha256(
|
| 773 |
+
{
|
| 774 |
+
"recipe_id": str(row.recipe_id),
|
| 775 |
+
"ref_position_in_recipe": int(row.ref_position_in_recipe),
|
| 776 |
+
}
|
| 777 |
+
)
|
| 778 |
+
if str(row.selection_occurrence_id) != expected_occurrence:
|
| 779 |
+
raise ValueError("sampled-cell occurrence identity differs")
|
| 780 |
+
expected_source = canonical_sha256(
|
| 781 |
+
{
|
| 782 |
+
"corpus_fingerprint": str(corpus_fingerprint),
|
| 783 |
+
"shard_id": str(row.shard_id),
|
| 784 |
+
"strict_row_index": int(row.strict_row_index),
|
| 785 |
+
}
|
| 786 |
+
)
|
| 787 |
+
if str(row.source_coordinate_id) != expected_source:
|
| 788 |
+
raise ValueError("sampled-cell source-coordinate identity differs")
|
| 789 |
+
for recipe_order, group in references.groupby("recipe_order", sort=False):
|
| 790 |
+
chosen = group["chosen_order_within_recipe"].astype(int).tolist()
|
| 791 |
+
if chosen != list(range(len(group))):
|
| 792 |
+
raise ValueError(
|
| 793 |
+
f"sampled-cell chosen order is not contiguous for recipe {recipe_order}"
|
| 794 |
+
)
|
| 795 |
+
if group["ref_position_in_recipe"].astype(int).duplicated().any():
|
| 796 |
+
raise ValueError(f"sampled-cell references repeat within recipe {recipe_order}")
|
| 797 |
+
recipe_sha256, refs_sha256 = _provenance_hashes(provenance)
|
| 798 |
+
if leakage_audit.get("ordered_recipe_ids_sha256") != recipe_sha256:
|
| 799 |
+
raise ValueError("ordered train-recipe provenance hash differs from audit")
|
| 800 |
+
if leakage_audit.get("sampled_cell_refs_sha256") != refs_sha256:
|
| 801 |
+
raise ValueError("sampled-cell provenance hash differs from audit")
|
| 802 |
+
if leakage_audit.get("production_ready") is not True:
|
| 803 |
+
raise ValueError("exact provenance is present but audit is not production-ready")
|
| 804 |
+
return recipe_sha256, refs_sha256
|
| 805 |
+
|
| 806 |
+
|
| 807 |
+
def _assemble_ladder(
|
| 808 |
+
*,
|
| 809 |
+
full_ranking: FullGeneRanking,
|
| 810 |
+
gene_panel: Any,
|
| 811 |
+
tier_sizes: Mapping[str, int] | Sequence[int],
|
| 812 |
+
sampled_cells: int,
|
| 813 |
+
sampled_recipes: int,
|
| 814 |
+
corpus_fingerprint: str,
|
| 815 |
+
min_measured_cells: int,
|
| 816 |
+
min_detected_cells: int,
|
| 817 |
+
leakage_audit: Mapping[str, object],
|
| 818 |
+
provenance: TrainSelectionProvenance | None = None,
|
| 819 |
+
sufficient_statistics: BoundSufficientStatistics | None = None,
|
| 820 |
+
model7_implementation: Mapping[str, object] | None = None,
|
| 821 |
+
) -> PanelLadderSelection:
|
| 822 |
+
if len(gene_panel) != full_ranking.n_genes:
|
| 823 |
+
raise ValueError("gene panel and full ranking have different lengths")
|
| 824 |
+
finite_tiers = _normalise_tier_sizes(tier_sizes)
|
| 825 |
+
largest = finite_tiers[-1][1]
|
| 826 |
+
if largest > full_ranking.n_eligible:
|
| 827 |
+
raise ValueError(
|
| 828 |
+
f"only {full_ranking.n_eligible} genes are eligible, fewer than tier {largest}"
|
| 829 |
+
)
|
| 830 |
+
_validate_leakage_audit(leakage_audit)
|
| 831 |
+
if provenance is None:
|
| 832 |
+
if leakage_audit.get("production_ready") is True:
|
| 833 |
+
raise ValueError("production-ready selection lacks exact provenance tables")
|
| 834 |
+
if sufficient_statistics is not None or model7_implementation is not None:
|
| 835 |
+
raise ValueError("production bindings require exact provenance tables")
|
| 836 |
+
else:
|
| 837 |
+
if sufficient_statistics is None or model7_implementation is None:
|
| 838 |
+
raise ValueError(
|
| 839 |
+
"exact provenance requires sufficient-statistics and Model7 bindings"
|
| 840 |
+
)
|
| 841 |
+
_validate_provenance(
|
| 842 |
+
provenance,
|
| 843 |
+
sampled_recipes=sampled_recipes,
|
| 844 |
+
sampled_cells=sampled_cells,
|
| 845 |
+
corpus_fingerprint=corpus_fingerprint,
|
| 846 |
+
leakage_audit=leakage_audit,
|
| 847 |
+
)
|
| 848 |
+
statistics_sha256 = _validate_sufficient_statistics_binding(
|
| 849 |
+
sufficient_statistics,
|
| 850 |
+
sampled_cells=sampled_cells,
|
| 851 |
+
sampled_recipes=sampled_recipes,
|
| 852 |
+
corpus_fingerprint=corpus_fingerprint,
|
| 853 |
+
min_measured_cells=min_measured_cells,
|
| 854 |
+
min_detected_cells=min_detected_cells,
|
| 855 |
+
mean_bins=int(sufficient_statistics.binding.get("mean_bins", -1)),
|
| 856 |
+
)
|
| 857 |
+
if leakage_audit.get("sufficient_statistics_sha256") != statistics_sha256:
|
| 858 |
+
raise ValueError("audit does not bind the supplied sufficient statistics")
|
| 859 |
+
model7_sha256 = _validate_model7_implementation(model7_implementation)
|
| 860 |
+
if leakage_audit.get("model7_implementation_sha256") != model7_sha256:
|
| 861 |
+
raise ValueError("audit does not bind the Model7 implementation")
|
| 862 |
+
eligible_order = full_ranking.ranked_positions[: full_ranking.n_eligible]
|
| 863 |
+
tiers: dict[str, np.ndarray] = {
|
| 864 |
+
name: np.sort(eligible_order[:size]).astype(np.int64, copy=False)
|
| 865 |
+
for name, size in finite_tiers
|
| 866 |
+
}
|
| 867 |
+
tiers["broad"] = np.sort(eligible_order).astype(np.int64, copy=False)
|
| 868 |
+
previous: set[int] = set()
|
| 869 |
+
for name, _ in finite_tiers:
|
| 870 |
+
current = set(int(value) for value in tiers[name])
|
| 871 |
+
if not previous.issubset(current):
|
| 872 |
+
raise RuntimeError("finite panel tiers are not nested")
|
| 873 |
+
previous = current
|
| 874 |
+
if not previous.issubset(set(int(value) for value in tiers["broad"])):
|
| 875 |
+
raise RuntimeError("broad panel does not contain every finite tier")
|
| 876 |
+
return PanelLadderSelection(
|
| 877 |
+
full_ranking=full_ranking,
|
| 878 |
+
tiers=tiers,
|
| 879 |
+
sampled_cells=int(sampled_cells),
|
| 880 |
+
sampled_recipes=int(sampled_recipes),
|
| 881 |
+
corpus_fingerprint=str(corpus_fingerprint),
|
| 882 |
+
gene_panel_sha256=gene_panel_identity_sha256(gene_panel),
|
| 883 |
+
min_measured_cells=int(min_measured_cells),
|
| 884 |
+
min_detected_cells=int(min_detected_cells),
|
| 885 |
+
leakage_audit=dict(leakage_audit),
|
| 886 |
+
provenance=provenance,
|
| 887 |
+
sufficient_statistics=sufficient_statistics,
|
| 888 |
+
model7_implementation=(
|
| 889 |
+
None if model7_implementation is None else dict(model7_implementation)
|
| 890 |
+
),
|
| 891 |
+
)
|
| 892 |
+
|
| 893 |
+
|
| 894 |
+
def build_panel_ladder(
|
| 895 |
+
*,
|
| 896 |
+
value_sum: np.ndarray,
|
| 897 |
+
value_square_sum: np.ndarray,
|
| 898 |
+
measured_cells: np.ndarray,
|
| 899 |
+
detected_cells: np.ndarray,
|
| 900 |
+
gene_panel: Any,
|
| 901 |
+
sampled_cells: int,
|
| 902 |
+
sampled_recipes: int,
|
| 903 |
+
corpus_fingerprint: str,
|
| 904 |
+
min_measured_cells: int,
|
| 905 |
+
min_detected_cells: int,
|
| 906 |
+
mean_bins: int = 20,
|
| 907 |
+
tier_sizes: Mapping[str, int] | Sequence[int] = DEFAULT_TIER_SIZES,
|
| 908 |
+
leakage_audit: Mapping[str, object] | None = None,
|
| 909 |
+
provenance: TrainSelectionProvenance | None = None,
|
| 910 |
+
sufficient_statistics_binding: Mapping[str, object] | None = None,
|
| 911 |
+
model7_implementation: Mapping[str, object] | None = None,
|
| 912 |
+
) -> PanelLadderSelection:
|
| 913 |
+
"""Build a fixture-friendly ladder directly from sufficient statistics."""
|
| 914 |
+
|
| 915 |
+
sufficient_statistics: BoundSufficientStatistics | None = None
|
| 916 |
+
if provenance is not None:
|
| 917 |
+
if sufficient_statistics_binding is None or model7_implementation is None:
|
| 918 |
+
raise ValueError(
|
| 919 |
+
"exact provenance requires matching statistics and Model7 bindings"
|
| 920 |
+
)
|
| 921 |
+
sufficient_statistics = BoundSufficientStatistics(
|
| 922 |
+
value_sum=np.asarray(value_sum, dtype=np.float64).copy(),
|
| 923 |
+
value_square_sum=np.asarray(value_square_sum, dtype=np.float64).copy(),
|
| 924 |
+
measured_cells=np.asarray(measured_cells, dtype=np.int64).copy(),
|
| 925 |
+
detected_cells=np.asarray(detected_cells, dtype=np.int64).copy(),
|
| 926 |
+
binding=dict(sufficient_statistics_binding),
|
| 927 |
+
)
|
| 928 |
+
_validate_sufficient_statistics_binding(
|
| 929 |
+
sufficient_statistics,
|
| 930 |
+
sampled_cells=sampled_cells,
|
| 931 |
+
sampled_recipes=sampled_recipes,
|
| 932 |
+
corpus_fingerprint=corpus_fingerprint,
|
| 933 |
+
min_measured_cells=min_measured_cells,
|
| 934 |
+
min_detected_cells=min_detected_cells,
|
| 935 |
+
mean_bins=mean_bins,
|
| 936 |
+
)
|
| 937 |
+
elif sufficient_statistics_binding is not None or model7_implementation is not None:
|
| 938 |
+
raise ValueError("statistics/implementation bindings require exact provenance")
|
| 939 |
+
ranking = rank_hvg_full_statistics(
|
| 940 |
+
value_sum=value_sum,
|
| 941 |
+
value_square_sum=value_square_sum,
|
| 942 |
+
measured_cells=measured_cells,
|
| 943 |
+
detected_cells=detected_cells,
|
| 944 |
+
marker_mask=_marker_mask(gene_panel),
|
| 945 |
+
min_measured_cells=min_measured_cells,
|
| 946 |
+
min_detected_cells=min_detected_cells,
|
| 947 |
+
mean_bins=mean_bins,
|
| 948 |
+
)
|
| 949 |
+
audit = leakage_audit or train_only_leakage_audit(
|
| 950 |
+
evidence={"statistics_origin": "caller_attested_train_only_fixture"}
|
| 951 |
+
)
|
| 952 |
+
return _assemble_ladder(
|
| 953 |
+
full_ranking=ranking,
|
| 954 |
+
gene_panel=gene_panel,
|
| 955 |
+
tier_sizes=tier_sizes,
|
| 956 |
+
sampled_cells=sampled_cells,
|
| 957 |
+
sampled_recipes=sampled_recipes,
|
| 958 |
+
corpus_fingerprint=corpus_fingerprint,
|
| 959 |
+
min_measured_cells=min_measured_cells,
|
| 960 |
+
min_detected_cells=min_detected_cells,
|
| 961 |
+
leakage_audit=audit,
|
| 962 |
+
provenance=provenance,
|
| 963 |
+
sufficient_statistics=sufficient_statistics,
|
| 964 |
+
model7_implementation=model7_implementation,
|
| 965 |
+
)
|
| 966 |
+
|
| 967 |
+
|
| 968 |
+
def panel_ladder_from_hvg_selection(
|
| 969 |
+
selection: HVGSelection,
|
| 970 |
+
gene_panel: Any,
|
| 971 |
+
*,
|
| 972 |
+
tier_sizes: Mapping[str, int] | Sequence[int] = DEFAULT_TIER_SIZES,
|
| 973 |
+
min_measured_cells: int | None = None,
|
| 974 |
+
min_detected_cells: int | None = None,
|
| 975 |
+
leakage_audit: Mapping[str, object] | None = None,
|
| 976 |
+
provenance: TrainSelectionProvenance | None = None,
|
| 977 |
+
) -> PanelLadderSelection:
|
| 978 |
+
"""Derive all tiers from one v1 train-only statistics pass."""
|
| 979 |
+
|
| 980 |
+
measured_min = (
|
| 981 |
+
max(16, int(0.1 * selection.sampled_cells))
|
| 982 |
+
if min_measured_cells is None
|
| 983 |
+
else int(min_measured_cells)
|
| 984 |
+
)
|
| 985 |
+
detected_min = (
|
| 986 |
+
max(20, int(0.01 * selection.sampled_cells))
|
| 987 |
+
if min_detected_cells is None
|
| 988 |
+
else int(min_detected_cells)
|
| 989 |
+
)
|
| 990 |
+
ranking = _full_ranking(
|
| 991 |
+
mean_log1p=selection.mean_log1p,
|
| 992 |
+
variance_log1p=selection.variance_log1p,
|
| 993 |
+
normalized_dispersion=selection.normalized_dispersion,
|
| 994 |
+
measured_cells=selection.measured_cells,
|
| 995 |
+
detected_cells=selection.detected_cells,
|
| 996 |
+
marker_mask=_marker_mask(gene_panel),
|
| 997 |
+
min_measured_cells=measured_min,
|
| 998 |
+
min_detected_cells=detected_min,
|
| 999 |
+
)
|
| 1000 |
+
audit = leakage_audit or train_only_leakage_audit(
|
| 1001 |
+
evidence={
|
| 1002 |
+
"selector": "pbisc_sdd.gene_selection.select_train_hvgs",
|
| 1003 |
+
"selector_split_argument": "train",
|
| 1004 |
+
}
|
| 1005 |
+
)
|
| 1006 |
+
return _assemble_ladder(
|
| 1007 |
+
full_ranking=ranking,
|
| 1008 |
+
gene_panel=gene_panel,
|
| 1009 |
+
tier_sizes=tier_sizes,
|
| 1010 |
+
sampled_cells=selection.sampled_cells,
|
| 1011 |
+
sampled_recipes=selection.sampled_recipes,
|
| 1012 |
+
corpus_fingerprint=selection.corpus_fingerprint,
|
| 1013 |
+
min_measured_cells=measured_min,
|
| 1014 |
+
min_detected_cells=detected_min,
|
| 1015 |
+
leakage_audit=audit,
|
| 1016 |
+
provenance=provenance,
|
| 1017 |
+
sufficient_statistics=None,
|
| 1018 |
+
model7_implementation=None,
|
| 1019 |
+
)
|
| 1020 |
+
|
| 1021 |
+
|
| 1022 |
+
def _build_model7_data_module(model7_root: Path) -> Any:
|
| 1023 |
+
root = Path(model7_root).expanduser().resolve()
|
| 1024 |
+
source = root / "src"
|
| 1025 |
+
if not source.is_dir():
|
| 1026 |
+
raise FileNotFoundError(f"Model 7 source directory not found: {source}")
|
| 1027 |
+
if str(source) not in sys.path:
|
| 1028 |
+
sys.path.insert(0, str(source))
|
| 1029 |
+
from model7_no_annotation.data_e2 import ( # type: ignore[import-not-found]
|
| 1030 |
+
E2FullDataConfig,
|
| 1031 |
+
build_e2_full_data_module,
|
| 1032 |
+
)
|
| 1033 |
+
|
| 1034 |
+
return build_e2_full_data_module(E2FullDataConfig(progress=False))
|
| 1035 |
+
|
| 1036 |
+
|
| 1037 |
+
def collect_train_panel_statistics(
|
| 1038 |
+
data_module: Any,
|
| 1039 |
+
*,
|
| 1040 |
+
recipes: int = 256,
|
| 1041 |
+
cells_per_recipe: int = 128,
|
| 1042 |
+
seed: int = 20260627,
|
| 1043 |
+
target_sum: float = 10_000.0,
|
| 1044 |
+
mean_bins: int = 20,
|
| 1045 |
+
progress: bool = True,
|
| 1046 |
+
) -> TrainPanelStatistics:
|
| 1047 |
+
"""Collect exact train statistics and ordered source references in one pass."""
|
| 1048 |
+
|
| 1049 |
+
if recipes <= 0 or cells_per_recipe <= 0:
|
| 1050 |
+
raise ValueError("recipes and cells_per_recipe must be positive")
|
| 1051 |
+
if not np.isfinite(target_sum) or target_sum <= 0:
|
| 1052 |
+
raise ValueError("target_sum must be finite and positive")
|
| 1053 |
+
if int(mean_bins) <= 0:
|
| 1054 |
+
raise ValueError("mean_bins must be positive")
|
| 1055 |
+
model7_implementation = bind_model7_implementation(data_module)
|
| 1056 |
+
model7_implementation_sha256 = _validate_model7_implementation(
|
| 1057 |
+
model7_implementation
|
| 1058 |
+
)
|
| 1059 |
+
train_recipes = data_module.split_manifest(
|
| 1060 |
+
"train", max_blocks=int(recipes), seed=int(seed)
|
| 1061 |
+
)
|
| 1062 |
+
if train_recipes.empty:
|
| 1063 |
+
raise RuntimeError("train split emitted no recipes for panel selection")
|
| 1064 |
+
required_recipe_columns = set(ORDERED_RECIPE_COLUMNS).difference({"recipe_order"})
|
| 1065 |
+
missing = sorted(required_recipe_columns.difference(train_recipes.columns))
|
| 1066 |
+
if missing:
|
| 1067 |
+
raise RuntimeError(f"train recipe manifest lacks provenance columns: {missing}")
|
| 1068 |
+
if not train_recipes["split"].astype(str).eq("train").all():
|
| 1069 |
+
raise RuntimeError("train split manifest returned held-out recipe rows")
|
| 1070 |
+
if train_recipes["heldout"].astype(bool).any():
|
| 1071 |
+
raise RuntimeError("train split manifest returned held-out recipes")
|
| 1072 |
+
if train_recipes["recipe_id"].astype(str).duplicated().any():
|
| 1073 |
+
raise RuntimeError("train split manifest returned duplicate recipe IDs")
|
| 1074 |
+
data_module.prime_pools(train_recipes)
|
| 1075 |
+
|
| 1076 |
+
panel_size = int(len(data_module.gene_panel))
|
| 1077 |
+
value_sum = np.zeros(panel_size, dtype=np.float64)
|
| 1078 |
+
square_sum = np.zeros(panel_size, dtype=np.float64)
|
| 1079 |
+
measured_cells = np.zeros(panel_size, dtype=np.int64)
|
| 1080 |
+
detected_cells = np.zeros(panel_size, dtype=np.int64)
|
| 1081 |
+
recipe_records: list[dict[str, object]] = []
|
| 1082 |
+
reference_records: list[dict[str, object]] = []
|
| 1083 |
+
sampled_cells = 0
|
| 1084 |
+
rows: Any = train_recipes.iterrows()
|
| 1085 |
+
if progress:
|
| 1086 |
+
from tqdm import tqdm
|
| 1087 |
+
|
| 1088 |
+
rows = tqdm(rows, total=len(train_recipes), desc="select train-only panel ladder")
|
| 1089 |
+
rng = np.random.default_rng(int(seed) + 97_531)
|
| 1090 |
+
gene_indices = np.asarray(data_module.gene_indices, dtype=np.int64)
|
| 1091 |
+
corpus_fingerprint = str(data_module.corpus_fingerprint)
|
| 1092 |
+
|
| 1093 |
+
for recipe_order, (_, recipe) in enumerate(rows):
|
| 1094 |
+
recipe_record = {
|
| 1095 |
+
"recipe_order": int(recipe_order),
|
| 1096 |
+
**{
|
| 1097 |
+
column: (
|
| 1098 |
+
bool(recipe[column])
|
| 1099 |
+
if column == "heldout"
|
| 1100 |
+
else int(recipe[column])
|
| 1101 |
+
if column
|
| 1102 |
+
in {
|
| 1103 |
+
"stream_recipe_index",
|
| 1104 |
+
"recipe_index",
|
| 1105 |
+
"schedule_slot",
|
| 1106 |
+
"k",
|
| 1107 |
+
"rng_seed",
|
| 1108 |
+
}
|
| 1109 |
+
else str(recipe[column])
|
| 1110 |
+
)
|
| 1111 |
+
for column in ORDERED_RECIPE_COLUMNS
|
| 1112 |
+
if column != "recipe_order"
|
| 1113 |
+
},
|
| 1114 |
+
}
|
| 1115 |
+
recipe_records.append(recipe_record)
|
| 1116 |
+
refs, pools = data_module._recipe_refs_and_pools(recipe)
|
| 1117 |
+
take = min(int(cells_per_recipe), len(refs))
|
| 1118 |
+
selected_indices = np.asarray(
|
| 1119 |
+
rng.choice(len(refs), size=take, replace=False), dtype=np.int64
|
| 1120 |
+
)
|
| 1121 |
+
selected_refs = [refs[int(index)] for index in selected_indices]
|
| 1122 |
+
for chosen_order, (ref_position, selected_ref) in enumerate(
|
| 1123 |
+
zip(selected_indices, selected_refs, strict=True)
|
| 1124 |
+
):
|
| 1125 |
+
segment, row_index = (int(selected_ref[0]), int(selected_ref[1]))
|
| 1126 |
+
if segment < 0 or segment >= len(pools):
|
| 1127 |
+
raise RuntimeError("recipe reference contains an invalid pool segment")
|
| 1128 |
+
pool = pools[segment]
|
| 1129 |
+
shard_id = str(pool.get("shard_id", ""))
|
| 1130 |
+
count_zarr = str(pool.get("count_zarr", ""))
|
| 1131 |
+
if not shard_id or not count_zarr or row_index < 0:
|
| 1132 |
+
raise RuntimeError("recipe reference lacks exact source identity")
|
| 1133 |
+
reference_records.append(
|
| 1134 |
+
{
|
| 1135 |
+
"sample_order": int(sampled_cells + chosen_order),
|
| 1136 |
+
"recipe_order": int(recipe_order),
|
| 1137 |
+
"chosen_order_within_recipe": int(chosen_order),
|
| 1138 |
+
"recipe_id": str(recipe["recipe_id"]),
|
| 1139 |
+
"block_id": str(recipe["block_id"]),
|
| 1140 |
+
"sample_key": str(recipe["sample_key"]),
|
| 1141 |
+
"ref_position_in_recipe": int(ref_position),
|
| 1142 |
+
"selection_occurrence_id": canonical_sha256(
|
| 1143 |
+
{
|
| 1144 |
+
"recipe_id": str(recipe["recipe_id"]),
|
| 1145 |
+
"ref_position_in_recipe": int(ref_position),
|
| 1146 |
+
}
|
| 1147 |
+
),
|
| 1148 |
+
"segment_index": segment,
|
| 1149 |
+
"shard_id": shard_id,
|
| 1150 |
+
"count_zarr": count_zarr,
|
| 1151 |
+
"source_coordinate_id": canonical_sha256(
|
| 1152 |
+
{
|
| 1153 |
+
"corpus_fingerprint": corpus_fingerprint,
|
| 1154 |
+
"shard_id": shard_id,
|
| 1155 |
+
"strict_row_index": row_index,
|
| 1156 |
+
}
|
| 1157 |
+
),
|
| 1158 |
+
"strict_row_index": row_index,
|
| 1159 |
+
"row_index": row_index,
|
| 1160 |
+
}
|
| 1161 |
+
)
|
| 1162 |
+
|
| 1163 |
+
matrix = data_module._load_sparse_refs(selected_refs, pools)[:, gene_indices]
|
| 1164 |
+
matrix = matrix.tocsr().astype(np.float64)
|
| 1165 |
+
library_size = np.asarray(matrix.sum(axis=1), dtype=np.float64).reshape(-1)
|
| 1166 |
+
row_scale = np.divide(
|
| 1167 |
+
float(target_sum),
|
| 1168 |
+
library_size,
|
| 1169 |
+
out=np.zeros_like(library_size),
|
| 1170 |
+
where=library_size > 0,
|
| 1171 |
+
)
|
| 1172 |
+
normalized = matrix.multiply(row_scale[:, None]).tocsr()
|
| 1173 |
+
logged = normalized.copy()
|
| 1174 |
+
logged.data = np.log1p(logged.data)
|
| 1175 |
+
value_sum += np.asarray(logged.sum(axis=0)).reshape(-1)
|
| 1176 |
+
squared = logged.copy()
|
| 1177 |
+
squared.data **= 2
|
| 1178 |
+
square_sum += np.asarray(squared.sum(axis=0)).reshape(-1)
|
| 1179 |
+
detected_cells += np.asarray((matrix > 0).sum(axis=0)).reshape(-1).astype(
|
| 1180 |
+
np.int64
|
| 1181 |
+
)
|
| 1182 |
+
segment_counts = np.bincount(
|
| 1183 |
+
np.asarray([segment for segment, _ in selected_refs], dtype=np.int64),
|
| 1184 |
+
minlength=len(pools),
|
| 1185 |
+
)
|
| 1186 |
+
for segment, count in enumerate(segment_counts):
|
| 1187 |
+
if int(count) <= 0:
|
| 1188 |
+
continue
|
| 1189 |
+
group = data_module._zarr_group(str(pools[segment]["count_zarr"]))
|
| 1190 |
+
mask = np.asarray(group["measurement_mask"][:], dtype=np.uint8)
|
| 1191 |
+
if mask.shape != (int(data_module.source_n_genes),) or not bool(
|
| 1192 |
+
np.isin(mask, (0, 1)).all()
|
| 1193 |
+
):
|
| 1194 |
+
raise RuntimeError("invalid source measurement_mask during panel selection")
|
| 1195 |
+
measured_cells += int(count) * mask[gene_indices]
|
| 1196 |
+
sampled_cells += take
|
| 1197 |
+
|
| 1198 |
+
ordered_recipes = pd.DataFrame.from_records(
|
| 1199 |
+
recipe_records, columns=ORDERED_RECIPE_COLUMNS
|
| 1200 |
+
)
|
| 1201 |
+
sampled_references = pd.DataFrame.from_records(
|
| 1202 |
+
reference_records, columns=SAMPLED_CELL_REFERENCE_COLUMNS
|
| 1203 |
+
)
|
| 1204 |
+
provenance = TrainSelectionProvenance(
|
| 1205 |
+
ordered_train_recipes=ordered_recipes,
|
| 1206 |
+
sampled_cell_references=sampled_references,
|
| 1207 |
+
)
|
| 1208 |
+
recipe_sha256, reference_sha256 = _provenance_hashes(provenance)
|
| 1209 |
+
min_measured_cells = max(16, int(0.1 * sampled_cells))
|
| 1210 |
+
min_detected_cells = max(20, int(0.01 * sampled_cells))
|
| 1211 |
+
statistics_binding = build_sufficient_statistics_binding(
|
| 1212 |
+
value_sum=value_sum,
|
| 1213 |
+
value_square_sum=square_sum,
|
| 1214 |
+
measured_cells=measured_cells,
|
| 1215 |
+
detected_cells=detected_cells,
|
| 1216 |
+
sampled_cells=sampled_cells,
|
| 1217 |
+
sampled_recipes=len(train_recipes),
|
| 1218 |
+
corpus_fingerprint=corpus_fingerprint,
|
| 1219 |
+
min_measured_cells=min_measured_cells,
|
| 1220 |
+
min_detected_cells=min_detected_cells,
|
| 1221 |
+
mean_bins=int(mean_bins),
|
| 1222 |
+
collection_parameters={
|
| 1223 |
+
"recipes": int(recipes),
|
| 1224 |
+
"cells_per_recipe": int(cells_per_recipe),
|
| 1225 |
+
"seed": int(seed),
|
| 1226 |
+
"target_sum": float(target_sum),
|
| 1227 |
+
"mean_bins": int(mean_bins),
|
| 1228 |
+
},
|
| 1229 |
+
)
|
| 1230 |
+
audit = train_only_leakage_audit(
|
| 1231 |
+
evidence={
|
| 1232 |
+
"collector": "pbisc_sdd.panel_ladder.collect_train_panel_statistics",
|
| 1233 |
+
"split_manifest_requests": ["train"],
|
| 1234 |
+
"heldout_recipe_rows": 0,
|
| 1235 |
+
"sampling_passes": 1,
|
| 1236 |
+
"stable_sample_order": "recipe order then RNG-chosen order within recipe",
|
| 1237 |
+
},
|
| 1238 |
+
ordered_recipe_ids_sha256=recipe_sha256,
|
| 1239 |
+
sampled_cell_refs_sha256=reference_sha256,
|
| 1240 |
+
sufficient_statistics_sha256=str(statistics_binding["binding_sha256"]),
|
| 1241 |
+
model7_implementation_sha256=model7_implementation_sha256,
|
| 1242 |
+
)
|
| 1243 |
+
_validate_provenance(
|
| 1244 |
+
provenance,
|
| 1245 |
+
sampled_recipes=len(train_recipes),
|
| 1246 |
+
sampled_cells=sampled_cells,
|
| 1247 |
+
corpus_fingerprint=corpus_fingerprint,
|
| 1248 |
+
leakage_audit=audit,
|
| 1249 |
+
)
|
| 1250 |
+
return TrainPanelStatistics(
|
| 1251 |
+
value_sum=value_sum,
|
| 1252 |
+
value_square_sum=square_sum,
|
| 1253 |
+
measured_cells=measured_cells,
|
| 1254 |
+
detected_cells=detected_cells,
|
| 1255 |
+
sampled_cells=sampled_cells,
|
| 1256 |
+
sampled_recipes=int(len(train_recipes)),
|
| 1257 |
+
corpus_fingerprint=corpus_fingerprint,
|
| 1258 |
+
gene_panel=data_module.gene_panel,
|
| 1259 |
+
leakage_audit=audit,
|
| 1260 |
+
provenance=provenance,
|
| 1261 |
+
min_measured_cells=min_measured_cells,
|
| 1262 |
+
min_detected_cells=min_detected_cells,
|
| 1263 |
+
mean_bins=int(mean_bins),
|
| 1264 |
+
sufficient_statistics_binding=statistics_binding,
|
| 1265 |
+
model7_implementation=model7_implementation,
|
| 1266 |
+
)
|
| 1267 |
+
|
| 1268 |
+
|
| 1269 |
+
def build_production_panel_ladder(
|
| 1270 |
+
statistics: TrainPanelStatistics,
|
| 1271 |
+
*,
|
| 1272 |
+
tier_sizes: Mapping[str, int] | Sequence[int] = DEFAULT_TIER_SIZES,
|
| 1273 |
+
) -> PanelLadderSelection:
|
| 1274 |
+
"""Assemble a ladder only from one collector-owned, fully bound statistics pass."""
|
| 1275 |
+
|
| 1276 |
+
return build_panel_ladder(
|
| 1277 |
+
value_sum=statistics.value_sum,
|
| 1278 |
+
value_square_sum=statistics.value_square_sum,
|
| 1279 |
+
measured_cells=statistics.measured_cells,
|
| 1280 |
+
detected_cells=statistics.detected_cells,
|
| 1281 |
+
gene_panel=statistics.gene_panel,
|
| 1282 |
+
sampled_cells=statistics.sampled_cells,
|
| 1283 |
+
sampled_recipes=statistics.sampled_recipes,
|
| 1284 |
+
corpus_fingerprint=statistics.corpus_fingerprint,
|
| 1285 |
+
min_measured_cells=statistics.min_measured_cells,
|
| 1286 |
+
min_detected_cells=statistics.min_detected_cells,
|
| 1287 |
+
mean_bins=statistics.mean_bins,
|
| 1288 |
+
tier_sizes=tier_sizes,
|
| 1289 |
+
leakage_audit=statistics.leakage_audit,
|
| 1290 |
+
provenance=statistics.provenance,
|
| 1291 |
+
sufficient_statistics_binding=statistics.sufficient_statistics_binding,
|
| 1292 |
+
model7_implementation=statistics.model7_implementation,
|
| 1293 |
+
)
|
| 1294 |
+
|
| 1295 |
+
|
| 1296 |
+
def select_train_panel_ladder(
|
| 1297 |
+
*,
|
| 1298 |
+
model7_root: Path = DEFAULT_MODEL7_ROOT,
|
| 1299 |
+
recipes: int = 256,
|
| 1300 |
+
cells_per_recipe: int = 128,
|
| 1301 |
+
seed: int = 20260627,
|
| 1302 |
+
mean_bins: int = 20,
|
| 1303 |
+
target_sum: float = 10_000.0,
|
| 1304 |
+
tier_sizes: Mapping[str, int] | Sequence[int] = DEFAULT_TIER_SIZES,
|
| 1305 |
+
progress: bool = True,
|
| 1306 |
+
) -> tuple[PanelLadderSelection, Any]:
|
| 1307 |
+
"""Collect a production-auditable train pass, then derive every panel width."""
|
| 1308 |
+
|
| 1309 |
+
data_module = _build_model7_data_module(Path(model7_root))
|
| 1310 |
+
statistics = collect_train_panel_statistics(
|
| 1311 |
+
data_module,
|
| 1312 |
+
recipes=recipes,
|
| 1313 |
+
cells_per_recipe=cells_per_recipe,
|
| 1314 |
+
seed=seed,
|
| 1315 |
+
target_sum=target_sum,
|
| 1316 |
+
mean_bins=mean_bins,
|
| 1317 |
+
progress=progress,
|
| 1318 |
+
)
|
| 1319 |
+
ladder = build_production_panel_ladder(statistics, tier_sizes=tier_sizes)
|
| 1320 |
+
return ladder, statistics.gene_panel
|
| 1321 |
+
|
| 1322 |
+
|
| 1323 |
+
def full_gene_statistics_table(
|
| 1324 |
+
ladder: PanelLadderSelection, gene_panel: Any
|
| 1325 |
+
) -> pd.DataFrame:
|
| 1326 |
+
"""Return one canonical-order row for every gene, including rejections."""
|
| 1327 |
+
|
| 1328 |
+
ranking = ladder.full_ranking
|
| 1329 |
+
if len(gene_panel) != ranking.n_genes:
|
| 1330 |
+
raise ValueError("gene panel and ladder have different lengths")
|
| 1331 |
+
table = gene_panel.reset_index(drop=True)[["gene_id", "gene_symbol"]].copy()
|
| 1332 |
+
canonical = np.arange(ranking.n_genes, dtype=np.int64)
|
| 1333 |
+
table.insert(0, "canonical_tensor_position", canonical)
|
| 1334 |
+
table.insert(0, "panel_position", canonical)
|
| 1335 |
+
table["universal_rank"] = ranking.universal_rank
|
| 1336 |
+
table["eligible_rank"] = pd.array(
|
| 1337 |
+
[value if value > 0 else pd.NA for value in ranking.eligible_rank],
|
| 1338 |
+
dtype="Int64",
|
| 1339 |
+
)
|
| 1340 |
+
table["eligible"] = ranking.eligible
|
| 1341 |
+
table["eligibility_reason"] = ranking.eligibility_reason
|
| 1342 |
+
table["is_priority_marker"] = ranking.marker_mask
|
| 1343 |
+
table["mean_log1p"] = ranking.mean_log1p
|
| 1344 |
+
table["variance_log1p"] = ranking.variance_log1p
|
| 1345 |
+
table["log_dispersion"] = ranking.log_dispersion
|
| 1346 |
+
table["normalized_dispersion"] = np.where(
|
| 1347 |
+
ranking.eligible, ranking.normalized_dispersion, np.nan
|
| 1348 |
+
)
|
| 1349 |
+
table["measured_cells"] = ranking.measured_cells
|
| 1350 |
+
table["detected_cells"] = ranking.detected_cells
|
| 1351 |
+
for name, positions in ladder.tiers.items():
|
| 1352 |
+
membership = np.zeros(ranking.n_genes, dtype=bool)
|
| 1353 |
+
membership[np.asarray(positions, dtype=np.int64)] = True
|
| 1354 |
+
table[f"in_tier_{name}"] = membership
|
| 1355 |
+
return table
|
| 1356 |
+
|
| 1357 |
+
|
| 1358 |
+
def _selected_genes_table(
|
| 1359 |
+
ladder: PanelLadderSelection, gene_panel: Any, positions: np.ndarray
|
| 1360 |
+
) -> pd.DataFrame:
|
| 1361 |
+
ranking = ladder.full_ranking
|
| 1362 |
+
table = gene_panel.iloc[positions][["gene_id", "gene_symbol"]].copy()
|
| 1363 |
+
table.insert(0, "panel_position", positions)
|
| 1364 |
+
table["mean_log1p"] = ranking.mean_log1p[positions]
|
| 1365 |
+
table["variance_log1p"] = ranking.variance_log1p[positions]
|
| 1366 |
+
table["normalized_dispersion"] = ranking.normalized_dispersion[positions]
|
| 1367 |
+
table["measured_cells"] = ranking.measured_cells[positions]
|
| 1368 |
+
table["detected_cells"] = ranking.detected_cells[positions]
|
| 1369 |
+
return table
|
| 1370 |
+
|
| 1371 |
+
|
| 1372 |
+
def _npy_bytes(array: np.ndarray) -> bytes:
|
| 1373 |
+
buffer = io.BytesIO()
|
| 1374 |
+
np.save(buffer, np.asarray(array, dtype=np.int64), allow_pickle=False)
|
| 1375 |
+
return buffer.getvalue()
|
| 1376 |
+
|
| 1377 |
+
|
| 1378 |
+
def _csv_bytes(table: pd.DataFrame) -> bytes:
|
| 1379 |
+
buffer = io.StringIO(newline="")
|
| 1380 |
+
table.to_csv(buffer, index=False)
|
| 1381 |
+
return buffer.getvalue().encode("utf-8")
|
| 1382 |
+
|
| 1383 |
+
|
| 1384 |
+
def _legacy_paths(path: Path) -> tuple[Path, Path, Path]:
|
| 1385 |
+
if not path.is_dir():
|
| 1386 |
+
raise ValueError("exact legacy replay requires an artifact directory")
|
| 1387 |
+
positions = path / "gene_positions.npy"
|
| 1388 |
+
selected = path / "selected_genes.csv"
|
| 1389 |
+
manifest = path / "manifest.json"
|
| 1390 |
+
missing = [candidate.name for candidate in (positions, selected, manifest) if not candidate.is_file()]
|
| 1391 |
+
if missing:
|
| 1392 |
+
raise FileNotFoundError(
|
| 1393 |
+
f"legacy replay directory is incomplete ({', '.join(missing)}): {path}"
|
| 1394 |
+
)
|
| 1395 |
+
return positions, selected, manifest
|
| 1396 |
+
|
| 1397 |
+
|
| 1398 |
+
def _selection_parameter_view(parameters: Mapping[str, object]) -> Mapping[str, object]:
|
| 1399 |
+
nested = parameters.get("selection")
|
| 1400 |
+
return nested if isinstance(nested, Mapping) else parameters
|
| 1401 |
+
|
| 1402 |
+
|
| 1403 |
+
def _parameters_equal(key: str, left: object, right: object) -> bool:
|
| 1404 |
+
if key in {"recipes", "cells_per_recipe", "mean_bins", "seed"}:
|
| 1405 |
+
return int(left) == int(right)
|
| 1406 |
+
if key == "target_sum":
|
| 1407 |
+
return float(left) == float(right)
|
| 1408 |
+
return left == right
|
| 1409 |
+
|
| 1410 |
+
|
| 1411 |
+
def _validate_selection_parameter_subset(
|
| 1412 |
+
actual_parameters: Mapping[str, object],
|
| 1413 |
+
expected_parameters: Mapping[str, object],
|
| 1414 |
+
*,
|
| 1415 |
+
error_prefix: str,
|
| 1416 |
+
) -> dict[str, object]:
|
| 1417 |
+
actual = _selection_parameter_view(actual_parameters)
|
| 1418 |
+
expected = _selection_parameter_view(expected_parameters)
|
| 1419 |
+
validated: dict[str, object] = {}
|
| 1420 |
+
for key in REPLAY_PARAMETER_KEYS:
|
| 1421 |
+
if key not in actual or key not in expected:
|
| 1422 |
+
raise ValueError(f"{error_prefix} parameter is missing: {key}")
|
| 1423 |
+
if not _parameters_equal(key, actual[key], expected[key]):
|
| 1424 |
+
raise ValueError(f"{error_prefix} parameter differs: {key}")
|
| 1425 |
+
validated[key] = actual[key]
|
| 1426 |
+
return validated
|
| 1427 |
+
|
| 1428 |
+
|
| 1429 |
+
def _validate_replay_parameters(
|
| 1430 |
+
*,
|
| 1431 |
+
legacy_parameters: Mapping[str, object],
|
| 1432 |
+
expected_parameters: Mapping[str, object],
|
| 1433 |
+
n_genes: int,
|
| 1434 |
+
) -> dict[str, object]:
|
| 1435 |
+
try:
|
| 1436 |
+
validated = _validate_selection_parameter_subset(
|
| 1437 |
+
legacy_parameters,
|
| 1438 |
+
expected_parameters,
|
| 1439 |
+
error_prefix="legacy replay",
|
| 1440 |
+
)
|
| 1441 |
+
except (TypeError, ValueError) as error:
|
| 1442 |
+
raise ReplayMismatchError(str(error)) from error
|
| 1443 |
+
if int(legacy_parameters.get("n_genes", -1)) != int(n_genes):
|
| 1444 |
+
raise ReplayMismatchError("legacy replay n_genes parameter differs")
|
| 1445 |
+
validated["n_genes"] = int(n_genes)
|
| 1446 |
+
return validated
|
| 1447 |
+
|
| 1448 |
+
|
| 1449 |
+
def build_exact_replay_proof(
|
| 1450 |
+
ladder: PanelLadderSelection,
|
| 1451 |
+
legacy_artifacts: Mapping[str, Path | str],
|
| 1452 |
+
*,
|
| 1453 |
+
gene_panel: Any | None = None,
|
| 1454 |
+
expected_parameters: Mapping[str, object] | None = None,
|
| 1455 |
+
) -> dict[str, object]:
|
| 1456 |
+
"""Prove requested tier files exactly reproduce legacy 2K/3K artifacts."""
|
| 1457 |
+
|
| 1458 |
+
proof_tiers: dict[str, object] = {}
|
| 1459 |
+
if legacy_artifacts and expected_parameters is None:
|
| 1460 |
+
raise ValueError("exact legacy replay requires expected selection parameters")
|
| 1461 |
+
if legacy_artifacts and gene_panel is None:
|
| 1462 |
+
raise ValueError("exact legacy replay requires the canonical gene panel")
|
| 1463 |
+
for raw_name, raw_path in legacy_artifacts.items():
|
| 1464 |
+
name = str(raw_name).lower()
|
| 1465 |
+
if name not in ladder.tiers or name == "broad":
|
| 1466 |
+
raise ValueError(f"legacy replay requested for unknown finite tier: {name}")
|
| 1467 |
+
source = Path(raw_path).expanduser().resolve()
|
| 1468 |
+
positions_path, selected_path, manifest_path = _legacy_paths(source)
|
| 1469 |
+
expected = np.asarray(ladder.tiers[name], dtype=np.int64)
|
| 1470 |
+
actual = np.load(positions_path, allow_pickle=False)
|
| 1471 |
+
array_exact = actual.dtype == np.int64 and np.array_equal(actual, expected)
|
| 1472 |
+
file_exact = sha256_file(positions_path) == _sha256_bytes(_npy_bytes(expected))
|
| 1473 |
+
entry: dict[str, object] = {
|
| 1474 |
+
"legacy_positions_path": str(positions_path),
|
| 1475 |
+
"legacy_positions_sha256": sha256_file(positions_path),
|
| 1476 |
+
"generated_positions_sha256": _sha256_bytes(_npy_bytes(expected)),
|
| 1477 |
+
"positions_array_exact": bool(array_exact),
|
| 1478 |
+
"positions_file_sha256_exact": bool(file_exact),
|
| 1479 |
+
}
|
| 1480 |
+
assert gene_panel is not None
|
| 1481 |
+
selected_exact = selected_path.read_bytes() == _csv_bytes(
|
| 1482 |
+
_selected_genes_table(ladder, gene_panel, expected)
|
| 1483 |
+
)
|
| 1484 |
+
legacy_manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
| 1485 |
+
if legacy_manifest.get("schema_version") != LEGACY_SELECTION_SCHEMA:
|
| 1486 |
+
raise ReplayMismatchError(f"legacy {name} manifest schema differs")
|
| 1487 |
+
if legacy_manifest.get("selection_scope") != "train_split_only":
|
| 1488 |
+
raise ReplayMismatchError(f"legacy {name} selection scope differs")
|
| 1489 |
+
if Path(str(legacy_manifest.get("positions_path", ""))).resolve() != positions_path:
|
| 1490 |
+
raise ReplayMismatchError(f"legacy {name} manifest positions path differs")
|
| 1491 |
+
if Path(str(legacy_manifest.get("selected_genes_path", ""))).resolve() != selected_path:
|
| 1492 |
+
raise ReplayMismatchError(f"legacy {name} manifest selected table path differs")
|
| 1493 |
+
if legacy_manifest.get("positions_sha256") != sha256_file(positions_path):
|
| 1494 |
+
raise ReplayMismatchError(
|
| 1495 |
+
f"legacy {name} manifest does not bind its positions file"
|
| 1496 |
+
)
|
| 1497 |
+
if legacy_manifest.get("selected_genes_sha256") != sha256_file(selected_path):
|
| 1498 |
+
raise ReplayMismatchError(
|
| 1499 |
+
f"legacy {name} manifest does not bind its selected-gene table"
|
| 1500 |
+
)
|
| 1501 |
+
if legacy_manifest.get("corpus_fingerprint") != ladder.corpus_fingerprint:
|
| 1502 |
+
raise ReplayMismatchError(f"legacy {name} corpus fingerprint differs")
|
| 1503 |
+
if int(legacy_manifest.get("n_selected_genes", -1)) != expected.size:
|
| 1504 |
+
raise ReplayMismatchError(f"legacy {name} selected-gene count differs")
|
| 1505 |
+
if int(legacy_manifest.get("sampled_cells", -1)) != ladder.sampled_cells:
|
| 1506 |
+
raise ReplayMismatchError(f"legacy {name} sampled-cell count differs")
|
| 1507 |
+
if int(legacy_manifest.get("sampled_recipes", -1)) != ladder.sampled_recipes:
|
| 1508 |
+
raise ReplayMismatchError(f"legacy {name} sampled-recipe count differs")
|
| 1509 |
+
legacy_parameters = legacy_manifest.get("parameters")
|
| 1510 |
+
if not isinstance(legacy_parameters, Mapping):
|
| 1511 |
+
raise ReplayMismatchError(f"legacy {name} selection parameters are missing")
|
| 1512 |
+
assert expected_parameters is not None
|
| 1513 |
+
validated_parameters = _validate_replay_parameters(
|
| 1514 |
+
legacy_parameters=legacy_parameters,
|
| 1515 |
+
expected_parameters=expected_parameters,
|
| 1516 |
+
n_genes=expected.size,
|
| 1517 |
+
)
|
| 1518 |
+
implementation_path = Path(str(legacy_manifest.get("implementation", ""))).resolve()
|
| 1519 |
+
if (
|
| 1520 |
+
not implementation_path.is_file()
|
| 1521 |
+
or legacy_manifest.get("implementation_sha256")
|
| 1522 |
+
!= sha256_file(implementation_path)
|
| 1523 |
+
):
|
| 1524 |
+
raise ReplayMismatchError(f"legacy {name} implementation binding differs")
|
| 1525 |
+
entry.update(
|
| 1526 |
+
{
|
| 1527 |
+
"legacy_selected_genes_path": str(selected_path),
|
| 1528 |
+
"legacy_selected_genes_sha256": sha256_file(selected_path),
|
| 1529 |
+
"selected_genes_file_exact": bool(selected_exact),
|
| 1530 |
+
"legacy_manifest_path": str(manifest_path),
|
| 1531 |
+
"legacy_manifest_sha256": sha256_file(manifest_path),
|
| 1532 |
+
"manifest_schema_verified": True,
|
| 1533 |
+
"manifest_hashes_verified": True,
|
| 1534 |
+
"selection_parameters_verified": validated_parameters,
|
| 1535 |
+
"legacy_implementation_verified": True,
|
| 1536 |
+
}
|
| 1537 |
+
)
|
| 1538 |
+
exact = array_exact and file_exact and selected_exact
|
| 1539 |
+
entry["exact"] = bool(exact)
|
| 1540 |
+
if not exact:
|
| 1541 |
+
raise ReplayMismatchError(f"legacy {name} replay is not byte-for-byte exact")
|
| 1542 |
+
proof_tiers[name] = entry
|
| 1543 |
+
requested = bool(legacy_artifacts)
|
| 1544 |
+
return {
|
| 1545 |
+
"schema_version": REPLAY_PROOF_SCHEMA,
|
| 1546 |
+
"requested": requested,
|
| 1547 |
+
"status": "pass" if requested else "not_requested",
|
| 1548 |
+
"all_exact": True if requested else None,
|
| 1549 |
+
"tiers": proof_tiers,
|
| 1550 |
+
}
|
| 1551 |
+
|
| 1552 |
+
|
| 1553 |
+
def _selection_code_bindings(
|
| 1554 |
+
model7_implementation: Mapping[str, object] | None = None,
|
| 1555 |
+
) -> dict[str, object]:
|
| 1556 |
+
implementation = Path(__file__).resolve()
|
| 1557 |
+
legacy_kernel = Path(rank_hvg_statistics.__code__.co_filename).resolve()
|
| 1558 |
+
files = {
|
| 1559 |
+
"panel_ladder": {
|
| 1560 |
+
"path": str(implementation),
|
| 1561 |
+
"sha256": sha256_file(implementation),
|
| 1562 |
+
},
|
| 1563 |
+
"legacy_ranking_kernel": {
|
| 1564 |
+
"path": str(legacy_kernel),
|
| 1565 |
+
"sha256": sha256_file(legacy_kernel),
|
| 1566 |
+
},
|
| 1567 |
+
}
|
| 1568 |
+
payload: dict[str, object] = {"files": files}
|
| 1569 |
+
if model7_implementation is not None:
|
| 1570 |
+
_validate_model7_implementation(model7_implementation)
|
| 1571 |
+
payload["model7_data_e2"] = dict(model7_implementation)
|
| 1572 |
+
return {**payload, "bundle_sha256": canonical_sha256(payload)}
|
| 1573 |
+
|
| 1574 |
+
|
| 1575 |
+
def _legacy_parameters(parameters: Mapping[str, object], n_genes: int) -> dict[str, object]:
|
| 1576 |
+
source: Mapping[str, object] = parameters
|
| 1577 |
+
nested = parameters.get("selection")
|
| 1578 |
+
if isinstance(nested, Mapping):
|
| 1579 |
+
source = nested
|
| 1580 |
+
result = {str(key): value for key, value in source.items() if key != "n_genes"}
|
| 1581 |
+
result["n_genes"] = int(n_genes)
|
| 1582 |
+
return result
|
| 1583 |
+
|
| 1584 |
+
|
| 1585 |
+
def _validate_production_ladder(
|
| 1586 |
+
ladder: PanelLadderSelection, gene_panel: Any
|
| 1587 |
+
) -> tuple[str, str, str, str] | None:
|
| 1588 |
+
if ladder.provenance is None:
|
| 1589 |
+
if (
|
| 1590 |
+
ladder.sufficient_statistics is not None
|
| 1591 |
+
or ladder.model7_implementation is not None
|
| 1592 |
+
or ladder.leakage_audit.get("production_ready") is True
|
| 1593 |
+
):
|
| 1594 |
+
raise ValueError("incomplete production binding on panel ladder")
|
| 1595 |
+
return None
|
| 1596 |
+
if ladder.sufficient_statistics is None or ladder.model7_implementation is None:
|
| 1597 |
+
raise ValueError("production ladder lacks statistics or Model7 binding")
|
| 1598 |
+
recipe_sha256, reference_sha256 = _validate_provenance(
|
| 1599 |
+
ladder.provenance,
|
| 1600 |
+
sampled_recipes=ladder.sampled_recipes,
|
| 1601 |
+
sampled_cells=ladder.sampled_cells,
|
| 1602 |
+
corpus_fingerprint=ladder.corpus_fingerprint,
|
| 1603 |
+
leakage_audit=ladder.leakage_audit,
|
| 1604 |
+
)
|
| 1605 |
+
mean_bins = int(ladder.sufficient_statistics.binding.get("mean_bins", -1))
|
| 1606 |
+
statistics_sha256 = _validate_sufficient_statistics_binding(
|
| 1607 |
+
ladder.sufficient_statistics,
|
| 1608 |
+
sampled_cells=ladder.sampled_cells,
|
| 1609 |
+
sampled_recipes=ladder.sampled_recipes,
|
| 1610 |
+
corpus_fingerprint=ladder.corpus_fingerprint,
|
| 1611 |
+
min_measured_cells=ladder.min_measured_cells,
|
| 1612 |
+
min_detected_cells=ladder.min_detected_cells,
|
| 1613 |
+
mean_bins=mean_bins,
|
| 1614 |
+
)
|
| 1615 |
+
if ladder.leakage_audit.get("sufficient_statistics_sha256") != statistics_sha256:
|
| 1616 |
+
raise ValueError("audit sufficient-statistics hash differs")
|
| 1617 |
+
model7_sha256 = _validate_model7_implementation(ladder.model7_implementation)
|
| 1618 |
+
if ladder.leakage_audit.get("model7_implementation_sha256") != model7_sha256:
|
| 1619 |
+
raise ValueError("audit Model7 implementation hash differs")
|
| 1620 |
+
recomputed = rank_hvg_full_statistics(
|
| 1621 |
+
value_sum=ladder.sufficient_statistics.value_sum,
|
| 1622 |
+
value_square_sum=ladder.sufficient_statistics.value_square_sum,
|
| 1623 |
+
measured_cells=ladder.sufficient_statistics.measured_cells,
|
| 1624 |
+
detected_cells=ladder.sufficient_statistics.detected_cells,
|
| 1625 |
+
marker_mask=_marker_mask(gene_panel),
|
| 1626 |
+
min_measured_cells=ladder.min_measured_cells,
|
| 1627 |
+
min_detected_cells=ladder.min_detected_cells,
|
| 1628 |
+
mean_bins=mean_bins,
|
| 1629 |
+
)
|
| 1630 |
+
for name in (
|
| 1631 |
+
"ranked_positions",
|
| 1632 |
+
"universal_rank",
|
| 1633 |
+
"eligible_rank",
|
| 1634 |
+
"eligible",
|
| 1635 |
+
"mean_log1p",
|
| 1636 |
+
"variance_log1p",
|
| 1637 |
+
"log_dispersion",
|
| 1638 |
+
"normalized_dispersion",
|
| 1639 |
+
"measured_cells",
|
| 1640 |
+
"detected_cells",
|
| 1641 |
+
"marker_mask",
|
| 1642 |
+
):
|
| 1643 |
+
actual = np.asarray(getattr(ladder.full_ranking, name))
|
| 1644 |
+
expected = np.asarray(getattr(recomputed, name))
|
| 1645 |
+
if not np.array_equal(actual, expected, equal_nan=True):
|
| 1646 |
+
raise ValueError(f"published ranking differs from bound statistics: {name}")
|
| 1647 |
+
if ladder.full_ranking.eligibility_reason != recomputed.eligibility_reason:
|
| 1648 |
+
raise ValueError("published eligibility reasons differ from bound statistics")
|
| 1649 |
+
eligible_order = recomputed.ranked_positions[: recomputed.n_eligible]
|
| 1650 |
+
for name, positions_value in ladder.tiers.items():
|
| 1651 |
+
prefix = recomputed.n_eligible if name == "broad" else len(positions_value)
|
| 1652 |
+
expected = np.sort(eligible_order[:prefix]).astype(np.int64, copy=False)
|
| 1653 |
+
if not np.array_equal(np.asarray(positions_value), expected):
|
| 1654 |
+
raise ValueError(f"tier {name} differs from bound universal ranking")
|
| 1655 |
+
return recipe_sha256, reference_sha256, statistics_sha256, model7_sha256
|
| 1656 |
+
|
| 1657 |
+
|
| 1658 |
+
def publish_panel_ladder(
|
| 1659 |
+
output_dir: Path | str,
|
| 1660 |
+
ladder: PanelLadderSelection,
|
| 1661 |
+
gene_panel: Any,
|
| 1662 |
+
*,
|
| 1663 |
+
parameters: Mapping[str, object],
|
| 1664 |
+
legacy_replay_artifacts: Mapping[str, Path | str] | None = None,
|
| 1665 |
+
) -> dict[str, object]:
|
| 1666 |
+
"""Publish a hash-bound ladder once; an existing target is never modified."""
|
| 1667 |
+
|
| 1668 |
+
output = Path(output_dir).expanduser().resolve()
|
| 1669 |
+
if output.exists() or output.is_symlink():
|
| 1670 |
+
raise FileExistsError(f"refusing to overwrite panel ladder: {output}")
|
| 1671 |
+
if gene_panel_identity_sha256(gene_panel) != ladder.gene_panel_sha256:
|
| 1672 |
+
raise ValueError("gene panel changed after the ladder was built")
|
| 1673 |
+
_validate_leakage_audit(ladder.leakage_audit)
|
| 1674 |
+
production_bindings = _validate_production_ladder(ladder, gene_panel)
|
| 1675 |
+
provenance_hashes = (
|
| 1676 |
+
None
|
| 1677 |
+
if production_bindings is None
|
| 1678 |
+
else (production_bindings[0], production_bindings[1])
|
| 1679 |
+
)
|
| 1680 |
+
statistics_sha256 = (
|
| 1681 |
+
None if production_bindings is None else production_bindings[2]
|
| 1682 |
+
)
|
| 1683 |
+
model7_sha256 = None if production_bindings is None else production_bindings[3]
|
| 1684 |
+
output.parent.mkdir(parents=True, exist_ok=True)
|
| 1685 |
+
|
| 1686 |
+
parameter_payload = dict(parameters)
|
| 1687 |
+
if ladder.sufficient_statistics is not None:
|
| 1688 |
+
collected_parameters = ladder.sufficient_statistics.binding.get(
|
| 1689 |
+
"collection_parameters"
|
| 1690 |
+
)
|
| 1691 |
+
if not isinstance(collected_parameters, Mapping):
|
| 1692 |
+
raise ValueError("bound sufficient statistics lack collection parameters")
|
| 1693 |
+
_validate_selection_parameter_subset(
|
| 1694 |
+
parameter_payload,
|
| 1695 |
+
collected_parameters,
|
| 1696 |
+
error_prefix="published selection",
|
| 1697 |
+
)
|
| 1698 |
+
parameters_sha256 = canonical_sha256(parameter_payload)
|
| 1699 |
+
code = _selection_code_bindings(ladder.model7_implementation)
|
| 1700 |
+
code_files = code["files"]
|
| 1701 |
+
assert isinstance(code_files, Mapping)
|
| 1702 |
+
implementation = code_files["panel_ladder"]
|
| 1703 |
+
assert isinstance(implementation, Mapping)
|
| 1704 |
+
audit_file_sha256 = _sha256_bytes(_json_file_bytes(ladder.leakage_audit))
|
| 1705 |
+
provenance_binding: dict[str, object] = {
|
| 1706 |
+
"ordered_train_recipes_sha256": (
|
| 1707 |
+
None if provenance_hashes is None else provenance_hashes[0]
|
| 1708 |
+
),
|
| 1709 |
+
"sampled_cell_references_sha256": (
|
| 1710 |
+
None if provenance_hashes is None else provenance_hashes[1]
|
| 1711 |
+
),
|
| 1712 |
+
"leakage_audit_sha256": audit_file_sha256,
|
| 1713 |
+
"sufficient_statistics_sha256": statistics_sha256,
|
| 1714 |
+
"model7_implementation_sha256": model7_sha256,
|
| 1715 |
+
}
|
| 1716 |
+
binding_core = {
|
| 1717 |
+
"corpus_fingerprint": ladder.corpus_fingerprint,
|
| 1718 |
+
"gene_panel_sha256": ladder.gene_panel_sha256,
|
| 1719 |
+
"selection_code_bundle_sha256": code["bundle_sha256"],
|
| 1720 |
+
"parameters_sha256": parameters_sha256,
|
| 1721 |
+
"provenance": provenance_binding,
|
| 1722 |
+
}
|
| 1723 |
+
binding_sha256 = canonical_sha256(binding_core)
|
| 1724 |
+
|
| 1725 |
+
stage = Path(tempfile.mkdtemp(prefix=f".{output.name}.staging-", dir=output.parent))
|
| 1726 |
+
try:
|
| 1727 |
+
ranked_path = stage / "ranked_gene_positions.npy"
|
| 1728 |
+
np.save(ranked_path, ladder.full_ranking.ranked_positions, allow_pickle=False)
|
| 1729 |
+
statistics_path = stage / "full_gene_statistics.csv"
|
| 1730 |
+
full_gene_statistics_table(ladder, gene_panel).to_csv(statistics_path, index=False)
|
| 1731 |
+
audit_path = stage / "leakage_audit.json"
|
| 1732 |
+
_write_json(audit_path, ladder.leakage_audit)
|
| 1733 |
+
if sha256_file(audit_path) != audit_file_sha256:
|
| 1734 |
+
raise RuntimeError("leakage audit serialization is not deterministic")
|
| 1735 |
+
|
| 1736 |
+
provenance_manifest: dict[str, object]
|
| 1737 |
+
if ladder.provenance is None:
|
| 1738 |
+
provenance_manifest = {
|
| 1739 |
+
"status": "incomplete",
|
| 1740 |
+
"ordered_train_recipes_path": None,
|
| 1741 |
+
"ordered_train_recipes_sha256": None,
|
| 1742 |
+
"ordered_train_recipes_rows": 0,
|
| 1743 |
+
"sampled_cell_references_path": None,
|
| 1744 |
+
"sampled_cell_references_sha256": None,
|
| 1745 |
+
"sampled_cell_references_rows": 0,
|
| 1746 |
+
}
|
| 1747 |
+
else:
|
| 1748 |
+
assert provenance_hashes is not None
|
| 1749 |
+
recipes_path = stage / "ordered_train_recipes.csv"
|
| 1750 |
+
references_path = stage / "sampled_cell_references.csv"
|
| 1751 |
+
recipes_path.write_bytes(
|
| 1752 |
+
_csv_bytes(ladder.provenance.ordered_train_recipes)
|
| 1753 |
+
)
|
| 1754 |
+
references_path.write_bytes(
|
| 1755 |
+
_csv_bytes(ladder.provenance.sampled_cell_references)
|
| 1756 |
+
)
|
| 1757 |
+
if sha256_file(recipes_path) != provenance_hashes[0]:
|
| 1758 |
+
raise RuntimeError("ordered train-recipe serialization drifted")
|
| 1759 |
+
if sha256_file(references_path) != provenance_hashes[1]:
|
| 1760 |
+
raise RuntimeError("sampled-cell reference serialization drifted")
|
| 1761 |
+
provenance_manifest = {
|
| 1762 |
+
"status": "complete",
|
| 1763 |
+
"ordered_train_recipes_path": str(output / recipes_path.name),
|
| 1764 |
+
"ordered_train_recipes_sha256": provenance_hashes[0],
|
| 1765 |
+
"ordered_train_recipes_rows": len(
|
| 1766 |
+
ladder.provenance.ordered_train_recipes
|
| 1767 |
+
),
|
| 1768 |
+
"ordered_train_recipes_columns": list(ORDERED_RECIPE_COLUMNS),
|
| 1769 |
+
"sampled_cell_references_path": str(output / references_path.name),
|
| 1770 |
+
"sampled_cell_references_sha256": provenance_hashes[1],
|
| 1771 |
+
"sampled_cell_references_rows": len(
|
| 1772 |
+
ladder.provenance.sampled_cell_references
|
| 1773 |
+
),
|
| 1774 |
+
"sampled_cell_references_columns": list(
|
| 1775 |
+
SAMPLED_CELL_REFERENCE_COLUMNS
|
| 1776 |
+
),
|
| 1777 |
+
"source_coordinate_contract": (
|
| 1778 |
+
"corpus_fingerprint + shard_id + strict_row_index"
|
| 1779 |
+
),
|
| 1780 |
+
"selection_occurrence_contract": (
|
| 1781 |
+
"recipe_id + ref_position_in_recipe; ordered by sample_order"
|
| 1782 |
+
),
|
| 1783 |
+
}
|
| 1784 |
+
|
| 1785 |
+
sufficient_statistics_manifest: dict[str, object]
|
| 1786 |
+
if ladder.sufficient_statistics is None:
|
| 1787 |
+
sufficient_statistics_manifest = {
|
| 1788 |
+
"status": "incomplete",
|
| 1789 |
+
"binding_path": None,
|
| 1790 |
+
"binding_file_sha256": None,
|
| 1791 |
+
"binding_sha256": None,
|
| 1792 |
+
"arrays": {},
|
| 1793 |
+
}
|
| 1794 |
+
else:
|
| 1795 |
+
assert statistics_sha256 is not None
|
| 1796 |
+
sufficient_dir = stage / "sufficient_statistics"
|
| 1797 |
+
sufficient_dir.mkdir(parents=True, exist_ok=False)
|
| 1798 |
+
binding_path = sufficient_dir / "binding.json"
|
| 1799 |
+
_write_json(binding_path, ladder.sufficient_statistics.binding)
|
| 1800 |
+
array_files: dict[str, object] = {}
|
| 1801 |
+
for name, array in (
|
| 1802 |
+
("value_sum", ladder.sufficient_statistics.value_sum),
|
| 1803 |
+
("value_square_sum", ladder.sufficient_statistics.value_square_sum),
|
| 1804 |
+
("measured_cells", ladder.sufficient_statistics.measured_cells),
|
| 1805 |
+
("detected_cells", ladder.sufficient_statistics.detected_cells),
|
| 1806 |
+
):
|
| 1807 |
+
path = sufficient_dir / f"{name}.npy"
|
| 1808 |
+
np.save(path, array, allow_pickle=False)
|
| 1809 |
+
array_files[name] = {
|
| 1810 |
+
"path": str(output / "sufficient_statistics" / path.name),
|
| 1811 |
+
"sha256": sha256_file(path),
|
| 1812 |
+
"dtype": np.asarray(array).dtype.name,
|
| 1813 |
+
"shape": [int(np.asarray(array).size)],
|
| 1814 |
+
}
|
| 1815 |
+
sufficient_statistics_manifest = {
|
| 1816 |
+
"status": "complete",
|
| 1817 |
+
"binding_path": str(
|
| 1818 |
+
output / "sufficient_statistics" / "binding.json"
|
| 1819 |
+
),
|
| 1820 |
+
"binding_file_sha256": sha256_file(binding_path),
|
| 1821 |
+
"binding_sha256": statistics_sha256,
|
| 1822 |
+
"arrays": array_files,
|
| 1823 |
+
}
|
| 1824 |
+
|
| 1825 |
+
replay_proof = build_exact_replay_proof(
|
| 1826 |
+
ladder,
|
| 1827 |
+
{} if legacy_replay_artifacts is None else legacy_replay_artifacts,
|
| 1828 |
+
gene_panel=gene_panel,
|
| 1829 |
+
expected_parameters=parameter_payload,
|
| 1830 |
+
)
|
| 1831 |
+
replay_path = stage / "replay_proof.json"
|
| 1832 |
+
_write_json(replay_path, replay_proof)
|
| 1833 |
+
|
| 1834 |
+
tier_entries: dict[str, object] = {}
|
| 1835 |
+
finite_names = [name for name in ladder.tiers if name != "broad"]
|
| 1836 |
+
for name, positions_value in ladder.tiers.items():
|
| 1837 |
+
positions = np.asarray(positions_value, dtype=np.int64)
|
| 1838 |
+
tier_dir = stage / "tiers" / name
|
| 1839 |
+
tier_dir.mkdir(parents=True, exist_ok=False)
|
| 1840 |
+
positions_path = tier_dir / "gene_positions.npy"
|
| 1841 |
+
np.save(positions_path, positions, allow_pickle=False)
|
| 1842 |
+
selected_path = tier_dir / "selected_genes.csv"
|
| 1843 |
+
_selected_genes_table(ladder, gene_panel, positions).to_csv(
|
| 1844 |
+
selected_path, index=False
|
| 1845 |
+
)
|
| 1846 |
+
final_tier_dir = output / "tiers" / name
|
| 1847 |
+
entry: dict[str, object] = {
|
| 1848 |
+
"n_genes": int(positions.size),
|
| 1849 |
+
"rank_prefix_length": int(positions.size),
|
| 1850 |
+
"tensor_order": "canonical_gene_panel_order",
|
| 1851 |
+
"gene_positions_path": str(final_tier_dir / "gene_positions.npy"),
|
| 1852 |
+
"gene_positions_sha256": sha256_file(positions_path),
|
| 1853 |
+
"selected_genes_path": str(final_tier_dir / "selected_genes.csv"),
|
| 1854 |
+
"selected_genes_sha256": sha256_file(selected_path),
|
| 1855 |
+
}
|
| 1856 |
+
if name == "broad":
|
| 1857 |
+
entry["policy"] = "all_eligible_genes"
|
| 1858 |
+
else:
|
| 1859 |
+
legacy_manifest_path = tier_dir / "legacy_selection_manifest.v1.json"
|
| 1860 |
+
legacy_manifest = {
|
| 1861 |
+
"schema_version": LEGACY_SELECTION_SCHEMA,
|
| 1862 |
+
"selection_scope": "train_split_only",
|
| 1863 |
+
"corpus_fingerprint": ladder.corpus_fingerprint,
|
| 1864 |
+
"sampled_cells": ladder.sampled_cells,
|
| 1865 |
+
"sampled_recipes": ladder.sampled_recipes,
|
| 1866 |
+
"n_selected_genes": int(positions.size),
|
| 1867 |
+
"positions_path": str(final_tier_dir / "gene_positions.npy"),
|
| 1868 |
+
"positions_sha256": sha256_file(positions_path),
|
| 1869 |
+
"selected_genes_path": str(final_tier_dir / "selected_genes.csv"),
|
| 1870 |
+
"selected_genes_sha256": sha256_file(selected_path),
|
| 1871 |
+
"implementation": str(implementation["path"]),
|
| 1872 |
+
"implementation_sha256": str(implementation["sha256"]),
|
| 1873 |
+
"algorithm": (
|
| 1874 |
+
"universal train-only measurement-aware HVG ranking; "
|
| 1875 |
+
"this tier is a rank prefix emitted in canonical tensor order"
|
| 1876 |
+
),
|
| 1877 |
+
"parameters": _legacy_parameters(parameter_payload, positions.size),
|
| 1878 |
+
"parent_panel_ladder": {
|
| 1879 |
+
"schema_version": PANEL_LADDER_SCHEMA,
|
| 1880 |
+
"manifest_path": str(output / "manifest.json"),
|
| 1881 |
+
"binding_sha256": binding_sha256,
|
| 1882 |
+
"tier": name,
|
| 1883 |
+
},
|
| 1884 |
+
}
|
| 1885 |
+
_write_json(legacy_manifest_path, legacy_manifest)
|
| 1886 |
+
entry["legacy_selection_manifest_path"] = str(
|
| 1887 |
+
final_tier_dir / "legacy_selection_manifest.v1.json"
|
| 1888 |
+
)
|
| 1889 |
+
entry["legacy_selection_manifest_sha256"] = sha256_file(
|
| 1890 |
+
legacy_manifest_path
|
| 1891 |
+
)
|
| 1892 |
+
tier_entries[name] = entry
|
| 1893 |
+
|
| 1894 |
+
manifest: dict[str, object] = {
|
| 1895 |
+
"schema_version": PANEL_LADDER_SCHEMA,
|
| 1896 |
+
"selection_scope": "train_split_only",
|
| 1897 |
+
"production_ready": bool(ladder.leakage_audit.get("production_ready")),
|
| 1898 |
+
"corpus_fingerprint": ladder.corpus_fingerprint,
|
| 1899 |
+
"gene_panel_sha256": ladder.gene_panel_sha256,
|
| 1900 |
+
"sampled_cells": ladder.sampled_cells,
|
| 1901 |
+
"sampled_recipes": ladder.sampled_recipes,
|
| 1902 |
+
"n_full_genes": ladder.full_ranking.n_genes,
|
| 1903 |
+
"n_eligible_genes": ladder.full_ranking.n_eligible,
|
| 1904 |
+
"n_rejected_genes": (
|
| 1905 |
+
ladder.full_ranking.n_genes - ladder.full_ranking.n_eligible
|
| 1906 |
+
),
|
| 1907 |
+
"ranking_contract": {
|
| 1908 |
+
"tier_independent": True,
|
| 1909 |
+
"ranked_population": "all_canonical_genes_eligible_first",
|
| 1910 |
+
"rank_base": 1,
|
| 1911 |
+
"tensor_order": "canonical_gene_panel_order",
|
| 1912 |
+
"finite_tier_policy": "universal_eligible_rank_prefix",
|
| 1913 |
+
"broad_tier_policy": "all_eligible_genes",
|
| 1914 |
+
"min_measured_cells": ladder.min_measured_cells,
|
| 1915 |
+
"min_detected_cells": ladder.min_detected_cells,
|
| 1916 |
+
},
|
| 1917 |
+
"ranked_gene_positions_path": str(output / "ranked_gene_positions.npy"),
|
| 1918 |
+
"ranked_gene_positions_sha256": sha256_file(ranked_path),
|
| 1919 |
+
"full_gene_statistics_path": str(output / "full_gene_statistics.csv"),
|
| 1920 |
+
"full_gene_statistics_sha256": sha256_file(statistics_path),
|
| 1921 |
+
"leakage_audit_path": str(output / "leakage_audit.json"),
|
| 1922 |
+
"leakage_audit_sha256": sha256_file(audit_path),
|
| 1923 |
+
"provenance": provenance_manifest,
|
| 1924 |
+
"sufficient_statistics": sufficient_statistics_manifest,
|
| 1925 |
+
"replay_proof_path": str(output / "replay_proof.json"),
|
| 1926 |
+
"replay_proof_sha256": sha256_file(replay_path),
|
| 1927 |
+
"tiers_are_nested": True,
|
| 1928 |
+
"finite_tiers": finite_names,
|
| 1929 |
+
"tiers": tier_entries,
|
| 1930 |
+
"parameters": parameter_payload,
|
| 1931 |
+
"parameters_sha256": parameters_sha256,
|
| 1932 |
+
"selection_code": code,
|
| 1933 |
+
"bindings": {**binding_core, "binding_sha256": binding_sha256},
|
| 1934 |
+
}
|
| 1935 |
+
_write_json(stage / "manifest.json", manifest)
|
| 1936 |
+
if output.exists() or output.is_symlink():
|
| 1937 |
+
raise FileExistsError(f"refusing to overwrite panel ladder: {output}")
|
| 1938 |
+
stage.rename(output)
|
| 1939 |
+
return manifest
|
| 1940 |
+
except BaseException:
|
| 1941 |
+
if stage.exists():
|
| 1942 |
+
shutil.rmtree(stage)
|
| 1943 |
+
raise
|
| 1944 |
+
|
| 1945 |
+
|
| 1946 |
+
# A concise alias for callers that used the v1 ``save_*`` naming convention.
|
| 1947 |
+
save_panel_ladder = publish_panel_ladder
|
| 1948 |
+
|
| 1949 |
+
|
| 1950 |
+
__all__ = [
|
| 1951 |
+
"BoundSufficientStatistics",
|
| 1952 |
+
"DEFAULT_TIER_SIZES",
|
| 1953 |
+
"FullGeneRanking",
|
| 1954 |
+
"LEAKAGE_AUDIT_SCHEMA",
|
| 1955 |
+
"MODEL7_IMPLEMENTATION_SCHEMA",
|
| 1956 |
+
"ORDERED_RECIPE_COLUMNS",
|
| 1957 |
+
"PANEL_LADDER_SCHEMA",
|
| 1958 |
+
"PanelLadderSelection",
|
| 1959 |
+
"REPLAY_PROOF_SCHEMA",
|
| 1960 |
+
"ReplayMismatchError",
|
| 1961 |
+
"SAMPLED_CELL_REFERENCE_COLUMNS",
|
| 1962 |
+
"SUFFICIENT_STATISTICS_SCHEMA",
|
| 1963 |
+
"TrainPanelStatistics",
|
| 1964 |
+
"TrainSelectionProvenance",
|
| 1965 |
+
"build_exact_replay_proof",
|
| 1966 |
+
"build_panel_ladder",
|
| 1967 |
+
"build_production_panel_ladder",
|
| 1968 |
+
"build_sufficient_statistics_binding",
|
| 1969 |
+
"bind_model7_implementation",
|
| 1970 |
+
"canonical_sha256",
|
| 1971 |
+
"collect_train_panel_statistics",
|
| 1972 |
+
"full_gene_statistics_table",
|
| 1973 |
+
"gene_panel_identity_sha256",
|
| 1974 |
+
"panel_ladder_from_hvg_selection",
|
| 1975 |
+
"publish_panel_ladder",
|
| 1976 |
+
"rank_hvg_full_statistics",
|
| 1977 |
+
"save_panel_ladder",
|
| 1978 |
+
"select_train_panel_ladder",
|
| 1979 |
+
"sha256_file",
|
| 1980 |
+
"train_only_leakage_audit",
|
| 1981 |
+
]
|
provenance/rights.tsv
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
accession_hint count_bytes dataset_id license n_shards permission_evidence public_redistribution rights_status source_url
|
| 2 |
+
1674012519 001_A_collection_436154da-bcf1-4130-9c8b-120ff9a888_Perez_et_al._lupus_PBMC_cell-type-specific_molecular_genetic_associations_to_lup 12 not_authorized_by_this_inventory unverified
|
| 3 |
+
1925707386 005_A_collection_dde06e0f-ab3b-46be-96a2-a8082383c4_OneK1K_Yazar_et_al._single-cell_eQTL_mapping 10 not_authorized_by_this_inventory unverified
|
| 4 |
+
3874884767 006_A_collection_ced320a1-29f3-47c1-a735-513c7084d5_AIDA_Asian_Immune_Diversity_Atlas 8 not_authorized_by_this_inventory unverified
|
| 5 |
+
57475830 007_A_collection_e1a9ca56-f2ee-435d-980a-4f49ab7a95_Miao_et_al._RA_PBMC_disease_activity-associated_PBMC_subsets 1 not_authorized_by_this_inventory unverified
|
| 6 |
+
4889243412 009_A_Human_Immune_Health_Atlas_Human_Immune_Health_Atlas_AIFI_immune_dynamics_across_healthy_age 8 not_authorized_by_this_inventory unverified
|
| 7 |
+
1800929514 010_A_collection_4a9fd4d7-d870-4265-89a5-ad51ab811d_ScaleBio_single-cell_RNA_sequencing_of_human_PBMCs 3 not_authorized_by_this_inventory unverified
|
| 8 |
+
567968438 053_B_collection_b0cf0afa-ec40-4d65-b570-ed4ceacc68_Integrated_analysis_of_multimodal_single-cell_data_CITE-seq_PBMC 2 not_authorized_by_this_inventory unverified
|
| 9 |
+
233558795 058_B_collection_eb735cc9-d0a7-48fa-b255-db726bf365_COVID_PBMC_nasal_swab_donors_with_immunodeficiencies_and_autoimmune_conditions 1 not_authorized_by_this_inventory unverified
|
| 10 |
+
GSE274680 10927410946 061_A_GSE274680_Savage_Allen_RA_at-risk_longitudinal_progression_PBMC_multi-omic_cohort 239 not_authorized_by_this_inventory unverified
|
| 11 |
+
GSE271896 35417293038 065_A_GSE271896_GSE271896_Sound_Life_deep_longitudinal_immune_profiling 59 not_authorized_by_this_inventory unverified
|
| 12 |
+
254462666 071_C_JDM_CITE-seq_PBMC_CELLxGENE_JDM_CITE-seq_PBMC_CELLxGENE 1 not_authorized_by_this_inventory unverified
|
| 13 |
+
1884471566 074_A_COMBAT_CELLxGENE_collection_COMBAT_CELLxGENE_collection 8 not_authorized_by_this_inventory unverified
|
| 14 |
+
68478910 081_B_Single-cell_atlas_of_peripheral_immune_respon_Single-cell_atlas_of_peripheral_immune_response_to_SARS-CoV-2 1 not_authorized_by_this_inventory unverified
|
| 15 |
+
917978258 093_C_Local_and_systemic_SARS-CoV-2_response_CELLxG_Local_and_systemic_SARS-CoV-2_response_CELLxGENE 4 not_authorized_by_this_inventory unverified
|
| 16 |
+
GSE275067 13697675475 200_A_GSE275067_Immunobiology_of_Aging_Cohort_PBMC_Profiling 16 not_authorized_by_this_inventory unverified
|
| 17 |
+
GSE161918 915236708 202_B_GSE161918_Time-resolved_Systems_Immunology_Reveals_a_Late_Juncture_Linked_to_Fatal_COVID-1 3 not_authorized_by_this_inventory unverified
|
| 18 |
+
1178278860 203_B_CELLxGENE_665714af_Ancestral_and_environmental_diversity_shape_the_immune_landscape_in_Indonesia 4 not_authorized_by_this_inventory unverified
|
| 19 |
+
2049058595 204_B_CELLxGENE_cHSPC_aging_MDS_Human_circulating_hematopoietic_stem_and_progenitor_cells_in_aging_cytopenia_and 10 not_authorized_by_this_inventory unverified
|
| 20 |
+
GSE132802 99560863 300b_A_GSE132802_DRESS_DiHS_PBMC_only_scRNAseq 1 not_authorized_by_this_inventory unverified
|
| 21 |
+
GSE163121 48148244 301_A_GSE163121_SLE_healthy_Bcell_PBMC_scRNAseq 1 not_authorized_by_this_inventory unverified
|
| 22 |
+
GSE314010 183985142 302_A_GSE314010_SLE_IL36_stim_PBMC_scRNAseq 1 not_authorized_by_this_inventory unverified
|
| 23 |
+
27863147358 304_A_Parse_10M_PBMC_12donor_90cytokines 39 not_authorized_by_this_inventory unverified
|