Feat/task 029x spatial exploration - #36
Merged
Merged
Conversation
Adds genevector.benchmarks.synthetic with the layout-only subset of grafiti's synthetic generator. Preserves the (df, marker_assignments) return contract and create_anndata_from_synthetic conversion. Strips preprocessing and plotting helpers. Substrate for TASK 027 (diagnostic overlay) and TASK 028 (spatial bench harness). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds apply_overlay() and build_pathology() under genevector.benchmarks.synthetic. Overlay extends var_names with 5 paracrine L/R pairs, 5 niche genes, 3 T-rare distinguishing genes, and 5 housekeeping controls (23 total). Splits T cells into T_stromal / T_intratumoral / T_rare by local tumor density; preserves coarse label in obs["phenotype_coarse"]. Ground-truth dict (JSON-serializable) records all gene categories, their source/target phenotypes, niche coupling parameters, and T-subtype cell counts. Schema versioned at "1.0". Substrate for TASK 028 (harness) and TASK 029 (eval). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds genevector.benchmarks.spatial — a config-driven runner that trains
GeneVector on the synthetic pathology FOV across {mi, pearson, spearman,
graph_xcorr, graph_xcorr_shuffled}. Each run writes its embedding,
metadata (target, graph_variant, epochs_run, final_loss, wall time, n_genes,
n_cells), and a per-seed manifest under benchmarks_artifacts/spatial/.
The shuffled variant uses a degree-preserving randomization
(networkx.double_edge_swap) to provide a structure-free graph_xcorr
control. The spatial graph itself is built via squidpy's k-NN
spatial_neighbors and symmetrized (squidpy's k-NN connectivities are
asymmetric).
Includes a CLI (scripts/run_spatial_benchmark.py) with a --quick smoke
mode and 7 tests covering config defaults, variant resolution, graph
symmetry, degree-preserving shuffle, and an end-to-end run across all
five variants. The full FOV1 run is gated behind pytest.mark.slow.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds evaluate_gene_pair_recovery, evaluate_phenotype_typing, and evaluate_ablation. Reads embeddings from TASK 028 artifacts and produces ROC-AUC for gene-pair recovery (paracrine, niche, housekeeping) plus macro-F1 + per-class F1 for phenotype assignment. Ablation summary computes deltas between graph_xcorr (real), graph_xcorr_shuffled, and mi baseline — answers whether the spatial structure or the target form drives gains. Includes report writer (Markdown tables, mean ± std across seeds) and CLI at scripts/run_spatial_eval.py. Sub-task 029b: fix --quick flag in run_spatial_benchmark.py to be a defaults-preset rather than a cap; --quick --epochs N now respects N. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds example/spatial_benchmark_exploration.py — #%%-cell script that loads existing TASK 028 artifacts and walks through eval results with inline prose explaining what's working (niche AUC) and what isn't (paracrine AUC < 0.5, T_rare F1 = 0). Includes diagnostics for embedding collapse, marker dict construction, and per-cell phenotype probabilities. Tool for understanding TASK 029 results before iterating on the eval. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds Cell 0 constants (RETRAIN, ARTIFACTS_ROOT, SEED, TRAIN_OVERRIDES) and a new Cell 2 that calls run_benchmark() directly when RETRAIN=True, so users can iterate on hyperparameters without leaving the notebook. Renumbers downstream cells (3..12); updates inline cell references in the T_rare hypothesis markdown. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two fixes for CI test collection on the spatial benchmark suite: - layout.py used PEP 604 union syntax (`int | None`) at runtime in a function default; add `from __future__ import annotations` so it parses on Python 3.9. - _build_spatial_graph imported squidpy, which is not a runtime dep and not installed in CI. Replace with sklearn.neighbors.kneighbors_graph (already a runtime dep) and symmetrize via union — same semantics. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
adding notebooks for looking at spatial signaling identification.