Archive 4 checkpoints (1-4)
Browse files- paper-releases/pbisc-diffusion/updates/20261015T141849Z-rare-cell-7k-8k-panels/diffusion/dataset/server_1/model8/plans/rare_gene_context_expansion_20261015/coordination/ilc_training_support/audit_training_ilc.py +349 -0
- paper-releases/pbisc-diffusion/updates/20261015T141849Z-rare-cell-7k-8k-panels/diffusion/dataset/server_1/model8/plans/rare_gene_context_expansion_20261015/coordination/ilc_training_support/cgroup_resource_observation.txt +10 -0
- paper-releases/pbisc-diffusion/updates/20261015T141849Z-rare-cell-7k-8k-panels/diffusion/dataset/server_1/model8/plans/rare_gene_context_expansion_20261015/coordination/ilc_training_support/codetection_diagnostics.csv +92 -0
- paper-releases/pbisc-diffusion/updates/20261015T141849Z-rare-cell-7k-8k-panels/diffusion/dataset/server_1/model8/plans/rare_gene_context_expansion_20261015/coordination/ilc_training_support/codetection_diagnostics.py +34 -0
paper-releases/pbisc-diffusion/updates/20261015T141849Z-rare-cell-7k-8k-panels/diffusion/dataset/server_1/model8/plans/rare_gene_context_expansion_20261015/coordination/ilc_training_support/audit_training_ilc.py
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Bounded, CPU-only source-labelled TRAIN ILC marker support audit.
|
| 3 |
+
|
| 4 |
+
Reuses the chunk/row algorithm in corpus_macrophage_markers_20261015.
|
| 5 |
+
Selection is fixed by source L1 annotation and registered split, never expression.
|
| 6 |
+
"""
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import argparse
|
| 10 |
+
from collections import defaultdict
|
| 11 |
+
import hashlib
|
| 12 |
+
import json
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
import resource
|
| 15 |
+
import time
|
| 16 |
+
|
| 17 |
+
import h5py
|
| 18 |
+
import numpy as np
|
| 19 |
+
import pandas as pd
|
| 20 |
+
import pyarrow.parquet as pq
|
| 21 |
+
import zarr
|
| 22 |
+
|
| 23 |
+
ROOT = Path(__file__).resolve().parent
|
| 24 |
+
PLAN = ROOT.parents[1]
|
| 25 |
+
M = PLAN.parents[1]
|
| 26 |
+
M7 = M.parent / 'model_7_no_annotation_sh_hwang/data'
|
| 27 |
+
E2 = M7 / 'e2_full_source'
|
| 28 |
+
BLOCK = Path('/home/sj_server_1/PBISC/PBISC-data/single-cell-data-block-blood')
|
| 29 |
+
KEY = ['dataset_id', 'donor_id', 'sample_id']
|
| 30 |
+
SOURCE_CT = Path('/home/sj_server_1/PBISC/paper-release-20260928/manuscript/source_data/corpus/corpus_celltypes.csv')
|
| 31 |
+
zarr.config.set({'async.concurrency': 2, 'threading.max_workers': 2})
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def sha(path: Path) -> str:
|
| 35 |
+
h = hashlib.sha256()
|
| 36 |
+
with Path(path).open('rb') as f:
|
| 37 |
+
for b in iter(lambda: f.read(1 << 20), b''): h.update(b)
|
| 38 |
+
return h.hexdigest()
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def receipt(path: Path) -> dict:
|
| 42 |
+
p = Path(path)
|
| 43 |
+
return {'path': str(p), 'bytes': p.stat().st_size, 'sha256': sha(p)}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def dump(name: str, value: dict | list) -> None:
|
| 47 |
+
(ROOT / name).write_text(json.dumps(value, indent=2) + '\n')
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def targets() -> pd.DataFrame:
|
| 51 |
+
p = ROOT / 'locked_target_genes.csv'
|
| 52 |
+
t = pd.read_csv(p)
|
| 53 |
+
assert len(t) == 48 and not t.gene_id.duplicated().any()
|
| 54 |
+
return t
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def prepare() -> None:
|
| 58 |
+
start = time.time()
|
| 59 |
+
target_source = PLAN / 'ilc_targeted_audit_genes.csv'
|
| 60 |
+
t = pd.read_csv(target_source)
|
| 61 |
+
t.to_csv(ROOT / 'locked_target_genes.csv', index=False)
|
| 62 |
+
t = targets()
|
| 63 |
+
cols = t.raw_panel_position.to_numpy(dtype=int)
|
| 64 |
+
var = pd.read_parquet(E2 / 'metadata/var.parquet')
|
| 65 |
+
assert len(var) == 20097
|
| 66 |
+
assert var.iloc[cols].gene_id.tolist() == t.gene_id.tolist()
|
| 67 |
+
assert var.iloc[cols].gene_symbol.tolist() == t.gene_symbol.tolist()
|
| 68 |
+
assert var.iloc[cols].panel_index.tolist() == cols.tolist()
|
| 69 |
+
cfgp = M / 'runs/f01_6k_1x_seed20260627/effective_config.json'
|
| 70 |
+
cfg = json.loads(cfgp.read_text())['data']
|
| 71 |
+
assert cfg['n_genes'] == 6000
|
| 72 |
+
manifest_path = Path(cfg['gene_selection_manifest'])
|
| 73 |
+
position_path = Path(cfg['gene_positions_path'])
|
| 74 |
+
assert sha(manifest_path) == cfg['gene_selection_manifest_sha256']
|
| 75 |
+
assert sha(position_path) == cfg['gene_positions_sha256']
|
| 76 |
+
manifest = json.loads(manifest_path.read_text())
|
| 77 |
+
selected_path = Path(manifest['selected_genes_path'])
|
| 78 |
+
assert sha(selected_path) == manifest['selected_genes_sha256']
|
| 79 |
+
selected = pd.read_csv(selected_path)
|
| 80 |
+
assert len(selected) == 6000 and not selected.gene_id.duplicated().any()
|
| 81 |
+
assert np.array_equal(np.load(position_path), selected.panel_position)
|
| 82 |
+
assert var.iloc[selected.panel_position].gene_id.tolist() == selected.gene_id.tolist()
|
| 83 |
+
assert np.array_equal(t.in_final6k, t.gene_id.isin(selected.gene_id))
|
| 84 |
+
records = [receipt(p) for p in [target_source, ROOT / 'locked_target_genes.csv',
|
| 85 |
+
E2 / 'metadata/var.parquet', SOURCE_CT, cfgp, manifest_path, position_path, selected_path]]
|
| 86 |
+
si_path = M7 / 'e2_full_index/metadata/sample_index.parquet'
|
| 87 |
+
si = pd.read_parquet(si_path)
|
| 88 |
+
for k in KEY: si[k] = si[k].astype(str)
|
| 89 |
+
assert not si.duplicated(KEY).any()
|
| 90 |
+
records.append(receipt(si_path))
|
| 91 |
+
ct = pd.read_csv(SOURCE_CT)
|
| 92 |
+
expected = ct[ct.celltype_l1 == 'ILC'].groupby('dataset_prefix').n_cells.sum().to_dict()
|
| 93 |
+
assert sum(expected.values()) == 19329
|
| 94 |
+
files = [p for p in sorted((E2 / 'metadata/obs_sc.parquet').glob('*.parquet'))
|
| 95 |
+
if any(p.stem.startswith(k + '_') for k in expected)
|
| 96 |
+
and not p.name.endswith('__strict_overlay.parquet')]
|
| 97 |
+
selected_rows, checks, all_ilc = [], [], defaultdict(int)
|
| 98 |
+
for fi, ep in enumerate(files):
|
| 99 |
+
bp = BLOCK / 'metadata/obs_sc.parquet' / ep.name
|
| 100 |
+
eq, bq = pq.ParquetFile(ep), pq.ParquetFile(bp)
|
| 101 |
+
assert eq.metadata.num_rows == bq.metadata.num_rows
|
| 102 |
+
bcols = ['source_row_index', 'row_index', 'celltype_l1']
|
| 103 |
+
extra = [x for x in ['source_celltype_l1', 'label_original', 'source_file'] if x in bq.schema.names]
|
| 104 |
+
bi = iter(bq.iter_batches(batch_size=32768, columns=bcols + extra, use_threads=False))
|
| 105 |
+
offset = n_ilc = n_train = 0
|
| 106 |
+
for eb in eq.iter_batches(batch_size=32768, columns=KEY + ['source_row_index', 'row_index'], use_threads=False):
|
| 107 |
+
e, b = eb.to_pandas(), next(bi).to_pandas()
|
| 108 |
+
assert len(e) == len(b) and np.array_equal(e.source_row_index, b.source_row_index)
|
| 109 |
+
assert np.array_equal(e.row_index, np.arange(offset, offset + len(e)))
|
| 110 |
+
keep = b.celltype_l1.astype(str).eq('ILC').to_numpy()
|
| 111 |
+
if keep.any():
|
| 112 |
+
v = e.loc[keep].copy()
|
| 113 |
+
for k in KEY: v[k] = v[k].astype(str)
|
| 114 |
+
v['shard_row'] = v.row_index
|
| 115 |
+
v['block_pre_qc_row_index'] = b.loc[keep, 'row_index'].to_numpy()
|
| 116 |
+
v['source_label'] = b.loc[keep, 'celltype_l1'].astype(str).to_numpy()
|
| 117 |
+
for c in extra: v[c] = b.loc[keep, c].astype(str).to_numpy()
|
| 118 |
+
v = v.merge(si[KEY + ['split', 'sample_key']], on=KEY, how='left', validate='many_to_one')
|
| 119 |
+
assert v.split.notna().all()
|
| 120 |
+
prefix = next(k for k in expected if ep.stem.startswith(k + '_'))
|
| 121 |
+
all_ilc[prefix] += len(v)
|
| 122 |
+
n_ilc += len(v)
|
| 123 |
+
v = v[v.split == 'train'].copy()
|
| 124 |
+
v['shard_id'] = ep.stem
|
| 125 |
+
n_train += len(v)
|
| 126 |
+
if len(v): selected_rows.append(v)
|
| 127 |
+
offset += len(e)
|
| 128 |
+
assert next(bi, None) is None and offset == eq.metadata.num_rows
|
| 129 |
+
checks.append({'shard_id': ep.stem, 'metadata_rows': offset, 'source_ilc': n_ilc,
|
| 130 |
+
'train_ilc': n_train, 'source_identity_and_physical_order_match': True})
|
| 131 |
+
records.extend([receipt(ep), receipt(bp)])
|
| 132 |
+
if fi % 20 == 0 or fi + 1 == len(files): print(f'metadata {fi+1}/{len(files)}', flush=True)
|
| 133 |
+
assert dict(all_ilc) == expected, (dict(all_ilc), expected)
|
| 134 |
+
v = pd.concat(selected_rows, ignore_index=True)
|
| 135 |
+
assert len(v) == 16439 and not v.duplicated(['shard_id', 'shard_row']).any()
|
| 136 |
+
v.to_parquet(ROOT / 'selected_training_ilc.parquet', index=False)
|
| 137 |
+
rows_by_sid = {x['shard_id']: x['metadata_rows'] for x in checks}
|
| 138 |
+
plans = []
|
| 139 |
+
for sid, d in v.groupby('shard_id', sort=True):
|
| 140 |
+
zp = BLOCK / 'counts/sc_counts' / (sid + '.zarr')
|
| 141 |
+
g = zarr.open_group(str(zp), mode='r')
|
| 142 |
+
for p in sorted(zp.glob('**/zarr.json')): records.append(receipt(p))
|
| 143 |
+
assert g.attrs['shape'] == [rows_by_sid[sid], 20097] and g.attrs['shard_id'] == sid
|
| 144 |
+
mask = np.asarray(g['measurement_mask'][:])[cols].astype(bool)
|
| 145 |
+
ptr = np.asarray(g['indptr'][:], dtype=np.int64)
|
| 146 |
+
for a in ['indptr', 'measurement_mask']:
|
| 147 |
+
for p in sorted((zp / a / 'c').glob('*')):
|
| 148 |
+
if p.is_file(): records.append(receipt(p))
|
| 149 |
+
r = d.shard_row.to_numpy()
|
| 150 |
+
size = g['indices'].chunks[0]
|
| 151 |
+
assert size == g['data'].chunks[0] == 1000000
|
| 152 |
+
chunks = sorted(set(c for rr in r for c in range(int(ptr[rr]) // size, (int(ptr[rr+1]) - 1) // size + 1)))
|
| 153 |
+
paths = [zp / a / 'c' / str(c) for c in chunks for a in ['indices', 'data']]
|
| 154 |
+
plans.append({'shard_id': sid, 'cells': len(d), 'chunks': chunks,
|
| 155 |
+
'compressed_bytes': sum(p.stat().st_size for p in paths if p.exists()),
|
| 156 |
+
'decoded_bytes_upper_bound': len(chunks) * size * 12,
|
| 157 |
+
'selected_nnz': int((ptr[r+1]-ptr[r]).sum()), 'measured': mask.tolist(),
|
| 158 |
+
'source_count_matrix': g.attrs['source_count_matrix'], 'source_path': g.attrs['source_path']})
|
| 159 |
+
plan = {'status': 'prepared', 'source_ilc': sum(all_ilc.values()), 'train_ilc': len(v),
|
| 160 |
+
'source_ilc_by_dataset_prefix': all_ilc, 'metadata_shards_scanned': len(files),
|
| 161 |
+
'metadata_rows_scanned': sum(x['metadata_rows'] for x in checks),
|
| 162 |
+
'selected_shards': len(plans), 'compressed_bytes': sum(x['compressed_bytes'] for x in plans),
|
| 163 |
+
'decoded_bytes_upper_bound': sum(x['decoded_bytes_upper_bound'] for x in plans),
|
| 164 |
+
'plans': plans, 'metadata_checks': checks, 'input_sources': records,
|
| 165 |
+
'elapsed_seconds': time.time()-start}
|
| 166 |
+
dump('extraction_plan.json', plan)
|
| 167 |
+
print(json.dumps({k: plan[k] for k in ['source_ilc', 'train_ilc', 'selected_shards', 'compressed_bytes', 'decoded_bytes_upper_bound', 'elapsed_seconds']}), flush=True)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def extract() -> None:
|
| 171 |
+
start = time.time()
|
| 172 |
+
plan = json.loads((ROOT / 'extraction_plan.json').read_text())
|
| 173 |
+
# Coordinator reviewed the 12.40 GiB cost gate and authorized this exact local subset.
|
| 174 |
+
assert plan['compressed_bytes'] <= 13 * 2**30, 'Cost exceeds coordinator-reviewed 12.40 GiB subset'
|
| 175 |
+
t = targets(); cols = t.raw_panel_position.to_numpy(dtype=int)
|
| 176 |
+
v = pd.read_parquet(ROOT / 'selected_training_ilc.parquet')
|
| 177 |
+
out = np.zeros((len(v), len(cols)), dtype=np.int64)
|
| 178 |
+
measured = np.zeros_like(out, dtype=bool)
|
| 179 |
+
totals = np.zeros(len(v), dtype=np.int64)
|
| 180 |
+
chunks_read, shard_checks = [], []
|
| 181 |
+
dataset_timings = []; ds_started = time.time(); ds_bytes = 0; current_ds = None
|
| 182 |
+
for pi, pp in enumerate(plan['plans']):
|
| 183 |
+
sid = pp['shard_id']; d = v[v.shard_id == sid].sort_values('shard_row')
|
| 184 |
+
ds = str(d.dataset_id.iloc[0])
|
| 185 |
+
if current_ds is None: current_ds = ds
|
| 186 |
+
elif ds != current_ds:
|
| 187 |
+
timing = {'dataset_id': current_ds, 'seconds': time.time()-ds_started, 'compressed_bytes': ds_bytes,
|
| 188 |
+
'process_peak_rss_kib': resource.getrusage(resource.RUSAGE_SELF).ru_maxrss}
|
| 189 |
+
dataset_timings.append(timing); print(json.dumps({'dataset_done': timing}), flush=True)
|
| 190 |
+
current_ds = ds; ds_started = time.time(); ds_bytes = 0
|
| 191 |
+
zp = BLOCK / 'counts/sc_counts' / (sid + '.zarr')
|
| 192 |
+
g = zarr.open_group(str(zp), mode='r')
|
| 193 |
+
mask = np.asarray(g['measurement_mask'][:])[cols].astype(bool)
|
| 194 |
+
assert mask.tolist() == pp['measured']
|
| 195 |
+
measured[d.index] = mask
|
| 196 |
+
ptr = np.asarray(g['indptr'][:], dtype=np.int64)
|
| 197 |
+
segs = defaultdict(list); size = 1000000
|
| 198 |
+
for oi, r in zip(d.index, d.shard_row):
|
| 199 |
+
a, b = int(ptr[r]), int(ptr[r+1])
|
| 200 |
+
while a < b:
|
| 201 |
+
c = a // size; end = min(b, (c+1)*size)
|
| 202 |
+
segs[c].append((int(oi), a-c*size, end-c*size)); a = end
|
| 203 |
+
assert sorted(segs) == pp['chunks']
|
| 204 |
+
nnz = 0
|
| 205 |
+
for c, pieces in sorted(segs.items()):
|
| 206 |
+
a, b = c*size, min((c+1)*size, g['indices'].shape[0])
|
| 207 |
+
ix = np.asarray(g['indices'][a:b], dtype=np.int32)
|
| 208 |
+
val = np.asarray(g['data'][a:b])
|
| 209 |
+
assert (val >= 0).all() and np.array_equal(val, val.astype(np.int64))
|
| 210 |
+
val = val.astype(np.int64)
|
| 211 |
+
for oi, lo, hi in pieces:
|
| 212 |
+
ids, values = ix[lo:hi], val[lo:hi]
|
| 213 |
+
totals[oi] += values.sum(); nnz += hi-lo
|
| 214 |
+
for j, col in enumerate(cols): out[oi, j] += values[ids == col].sum()
|
| 215 |
+
for arr in ['indices', 'data']:
|
| 216 |
+
p = zp / arr / 'c' / str(c)
|
| 217 |
+
if p.exists(): chunks_read.append(receipt(p))
|
| 218 |
+
assert nnz == pp['selected_nnz']
|
| 219 |
+
shard_checks.append({'shard_id': sid, 'cells': len(d), 'selected_nnz': nnz, 'chunks': len(segs)})
|
| 220 |
+
ds_bytes += pp['compressed_bytes']
|
| 221 |
+
print(f'expression {pi+1}/{len(plan["plans"])} {sid[:6]} cells={len(d)}', flush=True)
|
| 222 |
+
assert (totals > 0).all() and (out[~measured] == 0).all()
|
| 223 |
+
for j, gid in enumerate(t.gene_id):
|
| 224 |
+
v[gid] = out[:, j]
|
| 225 |
+
v[gid + '__measured'] = measured[:, j]
|
| 226 |
+
v['total_counts_20097'] = totals
|
| 227 |
+
v.to_parquet(ROOT / 'training_ilc_marker_counts.parquet', index=False)
|
| 228 |
+
dump('expression_chunk_receipts.json', chunks_read)
|
| 229 |
+
dataset_timings.append({'dataset_id': current_ds, 'seconds': time.time()-ds_started, 'compressed_bytes': ds_bytes,
|
| 230 |
+
'process_peak_rss_kib': resource.getrusage(resource.RUSAGE_SELF).ru_maxrss})
|
| 231 |
+
dump('extraction_result.json', {'status': 'extracted', 'cells': len(v), 'genes': len(t),
|
| 232 |
+
'elapsed_seconds': time.time()-start, 'shard_checks': shard_checks,
|
| 233 |
+
'process_peak_rss_kib': resource.getrusage(resource.RUSAGE_SELF).ru_maxrss, 'dataset_timings': dataset_timings,
|
| 234 |
+
'chunk_receipts': receipt(ROOT / 'expression_chunk_receipts.json')})
|
| 235 |
+
summarize(v, t)
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
def summarize(v: pd.DataFrame, t: pd.DataFrame) -> None:
|
| 239 |
+
tables = {'overall': [], 'by_dataset': [], 'by_donor': []}
|
| 240 |
+
grouped = [('overall', {}, v)]
|
| 241 |
+
grouped += [('by_dataset', {'dataset_id': k}, d) for k, d in v.groupby('dataset_id', sort=True)]
|
| 242 |
+
grouped += [('by_donor', dict(zip(KEY[:2], k)), d) for k, d in v.groupby(KEY[:2], sort=True)]
|
| 243 |
+
for level, labels, d in grouped:
|
| 244 |
+
for r in t.itertuples(index=False):
|
| 245 |
+
eligible = d[r.gene_id + '__measured']
|
| 246 |
+
det = eligible & d[r.gene_id].gt(0)
|
| 247 |
+
e, p = d[eligible], d[det]
|
| 248 |
+
n = len(e)
|
| 249 |
+
tables[level].append({**labels, 'gene_id': r.gene_id, 'gene_symbol': r.gene_symbol,
|
| 250 |
+
'raw_panel_position': int(r.raw_panel_position), 'source_labelled_ilc_cells': len(d),
|
| 251 |
+
'measured_eligible_cells': n, 'unmeasured_cells': len(d)-n, 'detected_cells': len(p),
|
| 252 |
+
'detection_fraction_among_measured': len(p)/n if n else None,
|
| 253 |
+
'total_raw_counts': int(e[r.gene_id].sum()),
|
| 254 |
+
'mean_raw_counts_among_measured': float(e[r.gene_id].mean()) if n else None,
|
| 255 |
+
'measured_dataset_scoped_donors': len(e[KEY[:2]].drop_duplicates()),
|
| 256 |
+
'detected_dataset_scoped_donors': len(p[KEY[:2]].drop_duplicates()),
|
| 257 |
+
'measured_samples': e.sample_key.nunique(), 'detected_samples': p.sample_key.nunique(),
|
| 258 |
+
'in_final6k': bool(r.in_final6k), 'in_7k': bool(r.in_7k), 'in_8k': bool(r.in_8k),
|
| 259 |
+
'sentinel': bool(r.sentinel)})
|
| 260 |
+
for name, rows in tables.items(): pd.DataFrame(rows).to_csv(ROOT / f'marker_support_{name}.csv', index=False)
|
| 261 |
+
depths = []
|
| 262 |
+
for name, d in [('ALL', v)] + list(v.groupby('dataset_id', sort=True)):
|
| 263 |
+
q = d.total_counts_20097.quantile([0, .1, .25, .5, .75, .9, 1]).to_dict()
|
| 264 |
+
depths.append({'dataset_id': name, 'cells': len(d), 'source_donor_ids': d.donor_id.nunique(),
|
| 265 |
+
'samples': d.sample_key.nunique(), **{f'canonical_count_q{k}': x for k, x in q.items()}})
|
| 266 |
+
pd.DataFrame(depths).to_csv(ROOT / 'native_depth_support.csv', index=False)
|
| 267 |
+
v.groupby(['dataset_id', 'source_label', 'label_original'], dropna=False).size().rename('cells').reset_index().to_csv(ROOT / 'source_label_support.csv', index=False)
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def verify() -> None:
|
| 271 |
+
t = targets(); cols = t.raw_panel_position.to_numpy(dtype=int); ids = t.gene_id.tolist()
|
| 272 |
+
var = pd.read_parquet(E2 / 'metadata/var.parquet')
|
| 273 |
+
v = pd.read_parquet(ROOT / 'training_ilc_marker_counts.parquet')
|
| 274 |
+
physical, direct, original, original_gaps = [], [], [], []
|
| 275 |
+
first_ds, boundary_ds = set(), set()
|
| 276 |
+
for sid, d in v.groupby('shard_id', sort=True):
|
| 277 |
+
zp = BLOCK / 'counts/sc_counts' / (sid + '.zarr')
|
| 278 |
+
g = zarr.open_group(str(zp), mode='r')
|
| 279 |
+
ep = E2 / 'metadata/obs_sc.parquet' / (sid + '.parquet')
|
| 280 |
+
bp = BLOCK / 'metadata/obs_sc.parquet' / (sid + '.parquet')
|
| 281 |
+
e = pq.read_table(ep, columns=['row_index', 'source_row_index']).to_pandas()
|
| 282 |
+
b = pq.read_table(bp, columns=['row_index', 'source_row_index', 'celltype_l1']).to_pandas()
|
| 283 |
+
rows = d.shard_row.to_numpy()
|
| 284 |
+
assert np.array_equal(e.iloc[rows].row_index, rows)
|
| 285 |
+
assert np.array_equal(e.iloc[rows].source_row_index, d.source_row_index)
|
| 286 |
+
assert np.array_equal(b.iloc[rows].source_row_index, d.source_row_index)
|
| 287 |
+
assert b.iloc[rows].celltype_l1.astype(str).eq('ILC').all()
|
| 288 |
+
assert g.attrs['shape'] == [len(e), len(var)]
|
| 289 |
+
physical.append({'shard_id': sid, 'cells': len(d), 'physical_identity_pass': True,
|
| 290 |
+
'block_pre_qc_row_different': int((b.iloc[rows].row_index.to_numpy() != rows).sum())})
|
| 291 |
+
ds = str(d.dataset_id.iloc[0]); chosen = set()
|
| 292 |
+
if ds not in first_ds: chosen.update([d.index[0], d.index[-1]])
|
| 293 |
+
ptr = np.asarray(g['indptr'][:])
|
| 294 |
+
boundary = ptr[rows] // 1000000 != (ptr[rows+1]-1) // 1000000
|
| 295 |
+
if ds not in boundary_ds and boundary.any():
|
| 296 |
+
chosen.add(d.index[np.flatnonzero(boundary)[0]]); boundary_ds.add(ds)
|
| 297 |
+
for ix in sorted(chosen):
|
| 298 |
+
r = v.loc[ix]; a, stop = map(int, ptr[int(r.shard_row):int(r.shard_row)+2])
|
| 299 |
+
ri, rv = np.asarray(g['indices'][a:stop]), np.asarray(g['data'][a:stop])
|
| 300 |
+
observed = np.array([rv[ri == c].sum() for c in cols])
|
| 301 |
+
assert np.array_equal(observed, r[ids].to_numpy(dtype=np.int64))
|
| 302 |
+
assert int(rv.sum()) == int(r.total_counts_20097)
|
| 303 |
+
rec = {'dataset_id': ds, 'shard_id': sid, 'shard_row': int(r.shard_row),
|
| 304 |
+
'counts': observed.tolist(), 'row_sum': int(rv.sum()),
|
| 305 |
+
'crosses_chunk_boundary': a // 1000000 != (stop-1) // 1000000}
|
| 306 |
+
direct.append(rec)
|
| 307 |
+
if ds not in first_ds:
|
| 308 |
+
hp = Path('/home/sj_server_1/gblee') / g.attrs['source_path']
|
| 309 |
+
if not hp.is_file():
|
| 310 |
+
original_gaps.append({'dataset_id': ds, 'recorded_path': str(hp),
|
| 311 |
+
'reason': 'Historical original H5AD path is absent locally; canonical CSR replay remains available and verified.'})
|
| 312 |
+
first_ds.add(ds)
|
| 313 |
+
continue
|
| 314 |
+
with h5py.File(hp, 'r') as h:
|
| 315 |
+
key = g.attrs['source_count_matrix']; vg = h['raw/var' if key.startswith('raw/') else 'var']
|
| 316 |
+
rawids = [x.decode() if isinstance(x, bytes) else str(x) for x in vg[vg.attrs['_index']][:]]
|
| 317 |
+
assert len(rawids) == len(set(rawids))
|
| 318 |
+
rawpos = {gid: j for j, gid in enumerate(rawids)}; mx = h[key]
|
| 319 |
+
assert mx.attrs['encoding-type'] == 'csr_matrix'
|
| 320 |
+
aa, zz = map(int, mx['indptr'][int(r.source_row_index):int(r.source_row_index)+2])
|
| 321 |
+
oi, ov = mx['indices'][aa:zz], mx['data'][aa:zz]
|
| 322 |
+
raw_counts = np.array([ov[oi == rawpos[gid]].sum() if gid in rawpos else 0 for gid in ids])
|
| 323 |
+
raw_mask = np.array([gid in rawpos for gid in ids])
|
| 324 |
+
assert np.array_equal(raw_counts, observed)
|
| 325 |
+
assert np.array_equal(raw_mask, r[[gid + '__measured' for gid in ids]].to_numpy(dtype=bool))
|
| 326 |
+
canonical = np.array([rawpos[gid] for gid in var.gene_id if gid in rawpos])
|
| 327 |
+
assert ov[np.isin(oi, canonical)].sum() == r.total_counts_20097
|
| 328 |
+
selected_bytes_hash = hashlib.sha256(oi.tobytes() + ov.tobytes()).hexdigest()
|
| 329 |
+
original.append({'dataset_id': ds, 'path': str(hp), 'bytes': hp.stat().st_size,
|
| 330 |
+
'mtime_ns': hp.stat().st_mtime_ns, 'matrix': key, 'source_row_index': int(r.source_row_index),
|
| 331 |
+
'shard_id': sid, 'shard_row': int(r.shard_row), '48_counts_match': True,
|
| 332 |
+
'48_measurement_mask_matches_original_gene_axis': True, 'canonical_count_sum_matches': True,
|
| 333 |
+
'original_selected_row_indices_values_sha256': selected_bytes_hash,
|
| 334 |
+
'original_gene_axis_sha256': hashlib.sha256('\n'.join(rawids).encode()).hexdigest()})
|
| 335 |
+
first_ds.add(ds)
|
| 336 |
+
assert len(original) + len(original_gaps) == v.dataset_id.nunique() == 12
|
| 337 |
+
assert len(original) >= 4
|
| 338 |
+
assert sum(x['cells'] for x in physical) == 16439
|
| 339 |
+
dump('verification.json', {'status': 'PASS', 'physical_rows': physical, 'direct_csr_rows': direct,
|
| 340 |
+
'original_h5ad_rows': original, 'raw_positions': cols.tolist(), 'gene_ids': ids,
|
| 341 |
+
'original_source_gaps': original_gaps,
|
| 342 |
+
'source_label_is_not_independently_verified_biological_identity': True})
|
| 343 |
+
print(json.dumps({'status': 'PASS', 'cells': len(v), 'shards': len(physical),
|
| 344 |
+
'direct_csr_rows': len(direct), 'original_h5ad_rows': len(original)}), flush=True)
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
if __name__ == '__main__':
|
| 348 |
+
ap = argparse.ArgumentParser(); ap.add_argument('stage', choices=['prepare', 'extract', 'verify'])
|
| 349 |
+
globals()[ap.parse_args().stage]()
|
paper-releases/pbisc-diffusion/updates/20261015T141849Z-rare-cell-7k-8k-panels/diffusion/dataset/server_1/model8/plans/rare_gene_context_expansion_20261015/coordination/ilc_training_support/cgroup_resource_observation.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
OOMPolicy=kill
|
| 2 |
+
MemoryCurrent=2147188736
|
| 3 |
+
MemoryPeak=2149576704
|
| 4 |
+
CPUUsageNSec=79003112000
|
| 5 |
+
CPUQuotaPerSecUSec=2s
|
| 6 |
+
MemoryHigh=2147483648
|
| 7 |
+
MemoryMax=3221225472
|
| 8 |
+
MemorySwapMax=0
|
| 9 |
+
OOMScoreAdjust=500
|
| 10 |
+
ActiveState=active
|
paper-releases/pbisc-diffusion/updates/20261015T141849Z-rare-cell-7k-8k-panels/diffusion/dataset/server_1/model8/plans/rare_gene_context_expansion_20261015/coordination/ilc_training_support/codetection_diagnostics.csv
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dataset_id,pattern,eligible_cells,positive_cells,fraction,detection_rule,interpretation
|
| 2 |
+
ALL,IL7R_and_KLRB1,16439,6936,0.421923474663909,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 3 |
+
ALL,CD3D_or_CD3E,16439,2188,0.13309812032362064,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 4 |
+
ALL,NKG7_and_GNLY,16439,1401,0.0852241620536529,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 5 |
+
ALL,IL7R_and_KLRB1_with_CD3D_or_CD3E,16439,1381,0.08400754303789769,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 6 |
+
ALL,IL7R_and_KLRB1_with_NKG7_and_GNLY,16439,1106,0.06727903157126346,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 7 |
+
ALL,CD3D_or_CD3E_with_NKG7_and_GNLY,16439,515,0.031327939655696815,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 8 |
+
ALL,all_three_patterns,16439,402,0.024454042216679846,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 9 |
+
005_A_collection_dde06e0f-ab3b-46be-96a2-a8082383c4_OneK1K_Yazar_et_al._single-cell_eQTL_mapping,IL7R_and_KLRB1,350,202,0.5771428571428572,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 10 |
+
005_A_collection_dde06e0f-ab3b-46be-96a2-a8082383c4_OneK1K_Yazar_et_al._single-cell_eQTL_mapping,CD3D_or_CD3E,350,92,0.26285714285714284,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 11 |
+
005_A_collection_dde06e0f-ab3b-46be-96a2-a8082383c4_OneK1K_Yazar_et_al._single-cell_eQTL_mapping,NKG7_and_GNLY,350,109,0.31142857142857144,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 12 |
+
005_A_collection_dde06e0f-ab3b-46be-96a2-a8082383c4_OneK1K_Yazar_et_al._single-cell_eQTL_mapping,IL7R_and_KLRB1_with_CD3D_or_CD3E,350,57,0.16285714285714287,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 13 |
+
005_A_collection_dde06e0f-ab3b-46be-96a2-a8082383c4_OneK1K_Yazar_et_al._single-cell_eQTL_mapping,IL7R_and_KLRB1_with_NKG7_and_GNLY,350,65,0.18571428571428572,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 14 |
+
005_A_collection_dde06e0f-ab3b-46be-96a2-a8082383c4_OneK1K_Yazar_et_al._single-cell_eQTL_mapping,CD3D_or_CD3E_with_NKG7_and_GNLY,350,47,0.13428571428571429,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 15 |
+
005_A_collection_dde06e0f-ab3b-46be-96a2-a8082383c4_OneK1K_Yazar_et_al._single-cell_eQTL_mapping,all_three_patterns,350,32,0.09142857142857143,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 16 |
+
006_A_collection_ced320a1-29f3-47c1-a735-513c7084d5_AIDA_Asian_Immune_Diversity_Atlas,IL7R_and_KLRB1,556,453,0.814748201438849,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 17 |
+
006_A_collection_ced320a1-29f3-47c1-a735-513c7084d5_AIDA_Asian_Immune_Diversity_Atlas,CD3D_or_CD3E,556,141,0.25359712230215825,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 18 |
+
006_A_collection_ced320a1-29f3-47c1-a735-513c7084d5_AIDA_Asian_Immune_Diversity_Atlas,NKG7_and_GNLY,556,58,0.10431654676258993,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 19 |
+
006_A_collection_ced320a1-29f3-47c1-a735-513c7084d5_AIDA_Asian_Immune_Diversity_Atlas,IL7R_and_KLRB1_with_CD3D_or_CD3E,556,103,0.18525179856115107,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 20 |
+
006_A_collection_ced320a1-29f3-47c1-a735-513c7084d5_AIDA_Asian_Immune_Diversity_Atlas,IL7R_and_KLRB1_with_NKG7_and_GNLY,556,47,0.08453237410071943,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 21 |
+
006_A_collection_ced320a1-29f3-47c1-a735-513c7084d5_AIDA_Asian_Immune_Diversity_Atlas,CD3D_or_CD3E_with_NKG7_and_GNLY,556,29,0.052158273381294966,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 22 |
+
006_A_collection_ced320a1-29f3-47c1-a735-513c7084d5_AIDA_Asian_Immune_Diversity_Atlas,all_three_patterns,556,21,0.03776978417266187,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 23 |
+
009_A_Human_Immune_Health_Atlas_Human_Immune_Health_Atlas_AIFI_immune_dynamics_across_healthy_age,IL7R_and_KLRB1,661,550,0.8320726172465961,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 24 |
+
009_A_Human_Immune_Health_Atlas_Human_Immune_Health_Atlas_AIFI_immune_dynamics_across_healthy_age,CD3D_or_CD3E,661,138,0.2087745839636914,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 25 |
+
009_A_Human_Immune_Health_Atlas_Human_Immune_Health_Atlas_AIFI_immune_dynamics_across_healthy_age,NKG7_and_GNLY,661,116,0.17549167927382753,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 26 |
+
009_A_Human_Immune_Health_Atlas_Human_Immune_Health_Atlas_AIFI_immune_dynamics_across_healthy_age,IL7R_and_KLRB1_with_CD3D_or_CD3E,661,123,0.18608169440242056,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 27 |
+
009_A_Human_Immune_Health_Atlas_Human_Immune_Health_Atlas_AIFI_immune_dynamics_across_healthy_age,IL7R_and_KLRB1_with_NKG7_and_GNLY,661,99,0.14977307110438728,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 28 |
+
009_A_Human_Immune_Health_Atlas_Human_Immune_Health_Atlas_AIFI_immune_dynamics_across_healthy_age,CD3D_or_CD3E_with_NKG7_and_GNLY,661,37,0.05597579425113464,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 29 |
+
009_A_Human_Immune_Health_Atlas_Human_Immune_Health_Atlas_AIFI_immune_dynamics_across_healthy_age,all_three_patterns,661,33,0.049924357034795766,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 30 |
+
010_A_collection_4a9fd4d7-d870-4265-89a5-ad51ab811d_ScaleBio_single-cell_RNA_sequencing_of_human_PBMCs,IL7R_and_KLRB1,631,180,0.28526148969889065,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 31 |
+
010_A_collection_4a9fd4d7-d870-4265-89a5-ad51ab811d_ScaleBio_single-cell_RNA_sequencing_of_human_PBMCs,CD3D_or_CD3E,631,137,0.21711568938193343,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 32 |
+
010_A_collection_4a9fd4d7-d870-4265-89a5-ad51ab811d_ScaleBio_single-cell_RNA_sequencing_of_human_PBMCs,NKG7_and_GNLY,631,33,0.05229793977812995,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 33 |
+
010_A_collection_4a9fd4d7-d870-4265-89a5-ad51ab811d_ScaleBio_single-cell_RNA_sequencing_of_human_PBMCs,IL7R_and_KLRB1_with_CD3D_or_CD3E,631,31,0.0491283676703645,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 34 |
+
010_A_collection_4a9fd4d7-d870-4265-89a5-ad51ab811d_ScaleBio_single-cell_RNA_sequencing_of_human_PBMCs,IL7R_and_KLRB1_with_NKG7_and_GNLY,631,9,0.014263074484944533,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 35 |
+
010_A_collection_4a9fd4d7-d870-4265-89a5-ad51ab811d_ScaleBio_single-cell_RNA_sequencing_of_human_PBMCs,CD3D_or_CD3E_with_NKG7_and_GNLY,631,11,0.017432646592709985,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 36 |
+
010_A_collection_4a9fd4d7-d870-4265-89a5-ad51ab811d_ScaleBio_single-cell_RNA_sequencing_of_human_PBMCs,all_three_patterns,631,1,0.001584786053882726,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 37 |
+
053_B_collection_b0cf0afa-ec40-4d65-b570-ed4ceacc68_Integrated_analysis_of_multimodal_single-cell_data_CITE-seq_PBMC,IL7R_and_KLRB1,85,77,0.9058823529411765,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 38 |
+
053_B_collection_b0cf0afa-ec40-4d65-b570-ed4ceacc68_Integrated_analysis_of_multimodal_single-cell_data_CITE-seq_PBMC,CD3D_or_CD3E,85,27,0.3176470588235294,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 39 |
+
053_B_collection_b0cf0afa-ec40-4d65-b570-ed4ceacc68_Integrated_analysis_of_multimodal_single-cell_data_CITE-seq_PBMC,NKG7_and_GNLY,85,9,0.10588235294117647,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 40 |
+
053_B_collection_b0cf0afa-ec40-4d65-b570-ed4ceacc68_Integrated_analysis_of_multimodal_single-cell_data_CITE-seq_PBMC,IL7R_and_KLRB1_with_CD3D_or_CD3E,85,25,0.29411764705882354,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 41 |
+
053_B_collection_b0cf0afa-ec40-4d65-b570-ed4ceacc68_Integrated_analysis_of_multimodal_single-cell_data_CITE-seq_PBMC,IL7R_and_KLRB1_with_NKG7_and_GNLY,85,8,0.09411764705882353,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 42 |
+
053_B_collection_b0cf0afa-ec40-4d65-b570-ed4ceacc68_Integrated_analysis_of_multimodal_single-cell_data_CITE-seq_PBMC,CD3D_or_CD3E_with_NKG7_and_GNLY,85,4,0.047058823529411764,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 43 |
+
053_B_collection_b0cf0afa-ec40-4d65-b570-ed4ceacc68_Integrated_analysis_of_multimodal_single-cell_data_CITE-seq_PBMC,all_three_patterns,85,3,0.03529411764705882,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 44 |
+
065_A_GSE271896_GSE271896_Sound_Life_deep_longitudinal_immune_profiling,IL7R_and_KLRB1,4616,3833,0.8303726169844021,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 45 |
+
065_A_GSE271896_GSE271896_Sound_Life_deep_longitudinal_immune_profiling,CD3D_or_CD3E,4616,791,0.17136048526863085,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 46 |
+
065_A_GSE271896_GSE271896_Sound_Life_deep_longitudinal_immune_profiling,NKG7_and_GNLY,4616,688,0.14904679376083188,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 47 |
+
065_A_GSE271896_GSE271896_Sound_Life_deep_longitudinal_immune_profiling,IL7R_and_KLRB1_with_CD3D_or_CD3E,4616,687,0.14883015597920277,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 48 |
+
065_A_GSE271896_GSE271896_Sound_Life_deep_longitudinal_immune_profiling,IL7R_and_KLRB1_with_NKG7_and_GNLY,4616,586,0.12694974003466206,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 49 |
+
065_A_GSE271896_GSE271896_Sound_Life_deep_longitudinal_immune_profiling,CD3D_or_CD3E_with_NKG7_and_GNLY,4616,216,0.04679376083188908,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 50 |
+
065_A_GSE271896_GSE271896_Sound_Life_deep_longitudinal_immune_profiling,all_three_patterns,4616,190,0.04116117850953206,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 51 |
+
093_C_Local_and_systemic_SARS-CoV-2_response_CELLxG_Local_and_systemic_SARS-CoV-2_response_CELLxGENE,IL7R_and_KLRB1,310,201,0.6483870967741936,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 52 |
+
093_C_Local_and_systemic_SARS-CoV-2_response_CELLxG_Local_and_systemic_SARS-CoV-2_response_CELLxGENE,CD3D_or_CD3E,310,134,0.432258064516129,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 53 |
+
093_C_Local_and_systemic_SARS-CoV-2_response_CELLxG_Local_and_systemic_SARS-CoV-2_response_CELLxGENE,NKG7_and_GNLY,310,167,0.5387096774193548,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 54 |
+
093_C_Local_and_systemic_SARS-CoV-2_response_CELLxG_Local_and_systemic_SARS-CoV-2_response_CELLxGENE,IL7R_and_KLRB1_with_CD3D_or_CD3E,310,95,0.3064516129032258,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 55 |
+
093_C_Local_and_systemic_SARS-CoV-2_response_CELLxG_Local_and_systemic_SARS-CoV-2_response_CELLxGENE,IL7R_and_KLRB1_with_NKG7_and_GNLY,310,113,0.36451612903225805,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 56 |
+
093_C_Local_and_systemic_SARS-CoV-2_response_CELLxG_Local_and_systemic_SARS-CoV-2_response_CELLxGENE,CD3D_or_CD3E_with_NKG7_and_GNLY,310,99,0.3193548387096774,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 57 |
+
093_C_Local_and_systemic_SARS-CoV-2_response_CELLxG_Local_and_systemic_SARS-CoV-2_response_CELLxGENE,all_three_patterns,310,67,0.2161290322580645,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 58 |
+
200_A_GSE275067_Immunobiology_of_Aging_Cohort_PBMC_Profiling,IL7R_and_KLRB1,1671,1345,0.8049072411729503,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 59 |
+
200_A_GSE275067_Immunobiology_of_Aging_Cohort_PBMC_Profiling,CD3D_or_CD3E,1671,283,0.16935966487133453,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 60 |
+
200_A_GSE275067_Immunobiology_of_Aging_Cohort_PBMC_Profiling,NKG7_and_GNLY,1671,198,0.118491921005386,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 61 |
+
200_A_GSE275067_Immunobiology_of_Aging_Cohort_PBMC_Profiling,IL7R_and_KLRB1_with_CD3D_or_CD3E,1671,232,0.13883901855176542,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 62 |
+
200_A_GSE275067_Immunobiology_of_Aging_Cohort_PBMC_Profiling,IL7R_and_KLRB1_with_NKG7_and_GNLY,1671,166,0.09934171154997008,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 63 |
+
200_A_GSE275067_Immunobiology_of_Aging_Cohort_PBMC_Profiling,CD3D_or_CD3E_with_NKG7_and_GNLY,1671,59,0.0353081986834231,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 64 |
+
200_A_GSE275067_Immunobiology_of_Aging_Cohort_PBMC_Profiling,all_three_patterns,1671,49,0.029323758228605626,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 65 |
+
300b_A_GSE132802_DRESS_DiHS_PBMC_only_scRNAseq,IL7R_and_KLRB1,9,4,0.4444444444444444,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 66 |
+
300b_A_GSE132802_DRESS_DiHS_PBMC_only_scRNAseq,CD3D_or_CD3E,9,8,0.8888888888888888,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 67 |
+
300b_A_GSE132802_DRESS_DiHS_PBMC_only_scRNAseq,NKG7_and_GNLY,9,3,0.3333333333333333,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 68 |
+
300b_A_GSE132802_DRESS_DiHS_PBMC_only_scRNAseq,IL7R_and_KLRB1_with_CD3D_or_CD3E,9,4,0.4444444444444444,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 69 |
+
300b_A_GSE132802_DRESS_DiHS_PBMC_only_scRNAseq,IL7R_and_KLRB1_with_NKG7_and_GNLY,9,3,0.3333333333333333,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 70 |
+
300b_A_GSE132802_DRESS_DiHS_PBMC_only_scRNAseq,CD3D_or_CD3E_with_NKG7_and_GNLY,9,3,0.3333333333333333,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 71 |
+
300b_A_GSE132802_DRESS_DiHS_PBMC_only_scRNAseq,all_three_patterns,9,3,0.3333333333333333,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 72 |
+
301_A_GSE163121_SLE_healthy_Bcell_PBMC_scRNAseq,IL7R_and_KLRB1,21,11,0.5238095238095238,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 73 |
+
301_A_GSE163121_SLE_healthy_Bcell_PBMC_scRNAseq,CD3D_or_CD3E,21,6,0.2857142857142857,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 74 |
+
301_A_GSE163121_SLE_healthy_Bcell_PBMC_scRNAseq,NKG7_and_GNLY,21,3,0.14285714285714285,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 75 |
+
301_A_GSE163121_SLE_healthy_Bcell_PBMC_scRNAseq,IL7R_and_KLRB1_with_CD3D_or_CD3E,21,3,0.14285714285714285,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 76 |
+
301_A_GSE163121_SLE_healthy_Bcell_PBMC_scRNAseq,IL7R_and_KLRB1_with_NKG7_and_GNLY,21,1,0.047619047619047616,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 77 |
+
301_A_GSE163121_SLE_healthy_Bcell_PBMC_scRNAseq,CD3D_or_CD3E_with_NKG7_and_GNLY,21,1,0.047619047619047616,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 78 |
+
301_A_GSE163121_SLE_healthy_Bcell_PBMC_scRNAseq,all_three_patterns,21,0,0.0,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 79 |
+
302_A_GSE314010_SLE_IL36_stim_PBMC_scRNAseq,IL7R_and_KLRB1,44,31,0.7045454545454546,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 80 |
+
302_A_GSE314010_SLE_IL36_stim_PBMC_scRNAseq,CD3D_or_CD3E,44,12,0.2727272727272727,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 81 |
+
302_A_GSE314010_SLE_IL36_stim_PBMC_scRNAseq,NKG7_and_GNLY,44,12,0.2727272727272727,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 82 |
+
302_A_GSE314010_SLE_IL36_stim_PBMC_scRNAseq,IL7R_and_KLRB1_with_CD3D_or_CD3E,44,8,0.18181818181818182,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 83 |
+
302_A_GSE314010_SLE_IL36_stim_PBMC_scRNAseq,IL7R_and_KLRB1_with_NKG7_and_GNLY,44,9,0.20454545454545456,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 84 |
+
302_A_GSE314010_SLE_IL36_stim_PBMC_scRNAseq,CD3D_or_CD3E_with_NKG7_and_GNLY,44,5,0.11363636363636363,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 85 |
+
302_A_GSE314010_SLE_IL36_stim_PBMC_scRNAseq,all_three_patterns,44,3,0.06818181818181818,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 86 |
+
304_A_Parse_10M_PBMC_12donor_90cytokines,IL7R_and_KLRB1,7485,49,0.0065464261857047425,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 87 |
+
304_A_Parse_10M_PBMC_12donor_90cytokines,CD3D_or_CD3E,7485,419,0.05597862391449566,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 88 |
+
304_A_Parse_10M_PBMC_12donor_90cytokines,NKG7_and_GNLY,7485,5,0.0006680026720106881,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 89 |
+
304_A_Parse_10M_PBMC_12donor_90cytokines,IL7R_and_KLRB1_with_CD3D_or_CD3E,7485,13,0.0017368069472277889,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 90 |
+
304_A_Parse_10M_PBMC_12donor_90cytokines,IL7R_and_KLRB1_with_NKG7_and_GNLY,7485,0,0.0,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 91 |
+
304_A_Parse_10M_PBMC_12donor_90cytokines,CD3D_or_CD3E_with_NKG7_and_GNLY,7485,4,0.0005344021376085504,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
| 92 |
+
304_A_Parse_10M_PBMC_12donor_90cytokines,all_three_patterns,7485,0,0.0,Each named gene raw count > 0; all six genes measured in all selected cells,"Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity"
|
paper-releases/pbisc-diffusion/updates/20261015T141849Z-rare-cell-7k-8k-panels/diffusion/dataset/server_1/model8/plans/rare_gene_context_expansion_20261015/coordination/ilc_training_support/codetection_diagnostics.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Descriptive positive-count overlaps; these are not annotation rules."""
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import pandas as pd
|
| 6 |
+
from audit_training_ilc import ROOT
|
| 7 |
+
|
| 8 |
+
v = pd.read_parquet(ROOT / 'training_ilc_marker_counts.parquet')
|
| 9 |
+
t = pd.read_csv(ROOT / 'locked_target_genes.csv')
|
| 10 |
+
genes = ['IL7R', 'KLRB1', 'CD3D', 'CD3E', 'NKG7', 'GNLY']
|
| 11 |
+
gid = t[t.gene_symbol.isin(genes)].set_index('gene_symbol').gene_id.to_dict()
|
| 12 |
+
assert len(gid) == 6
|
| 13 |
+
assert all(v[gid[g] + '__measured'].all() for g in genes)
|
| 14 |
+
positive = {g: v[gid[g]].gt(0) for g in genes}
|
| 15 |
+
both_il = positive['IL7R'] & positive['KLRB1']
|
| 16 |
+
any_cd3 = positive['CD3D'] | positive['CD3E']
|
| 17 |
+
both_nk = positive['NKG7'] & positive['GNLY']
|
| 18 |
+
patterns = {'IL7R_and_KLRB1': both_il,
|
| 19 |
+
'CD3D_or_CD3E': any_cd3,
|
| 20 |
+
'NKG7_and_GNLY': both_nk,
|
| 21 |
+
'IL7R_and_KLRB1_with_CD3D_or_CD3E': both_il & any_cd3,
|
| 22 |
+
'IL7R_and_KLRB1_with_NKG7_and_GNLY': both_il & both_nk,
|
| 23 |
+
'CD3D_or_CD3E_with_NKG7_and_GNLY': any_cd3 & both_nk,
|
| 24 |
+
'all_three_patterns': both_il & any_cd3 & both_nk}
|
| 25 |
+
rows = []
|
| 26 |
+
for ds, d in [('ALL', v)] + list(v.groupby('dataset_id', sort=True)):
|
| 27 |
+
for name, mask in patterns.items():
|
| 28 |
+
n = int(mask.loc[d.index].sum())
|
| 29 |
+
rows.append({'dataset_id': ds, 'pattern': name, 'eligible_cells': len(d),
|
| 30 |
+
'positive_cells': n, 'fraction': n/len(d),
|
| 31 |
+
'detection_rule': 'Each named gene raw count > 0; all six genes measured in all selected cells',
|
| 32 |
+
'interpretation': 'Descriptive overlap within source-labelled ILC records only; not classifier, relabelling or validated identity'})
|
| 33 |
+
pd.DataFrame(rows).to_csv(ROOT / 'codetection_diagnostics.csv', index=False)
|
| 34 |
+
print(pd.DataFrame(rows).query('dataset_id == "ALL"')[['pattern', 'positive_cells', 'fraction']].to_string(index=False))
|