Repository navigation
GRASS-MIL 1.1.0: one default path, niche analysis as primary results, validity fixes - #23
Merged
Merged
Conversation
- data: one input config for CSV/h5ad/SCE, labels attached at load time, splits drawn at setup (stratified, patient-grouped), data.unit (region|tile|polygon), one ego-graph sampler subclassing PyG's ShaDow sampler, fingerprinted processed graphs, fixed PCA serialisation - models: GINE encoder, projected gated attention, logit-space pooling; one manual-optimisation training path with gradient clipping after AMP unscaling, probe head fitted in setup, Cox/regression objectives over a hyperbatch, modules rebuilt from their checkpoints alone - configs: model/task/regime groups; finetune is the default regime; regimes renamed (finetune, finetune_reg, attention_only, mlp_head, mlp_head_frozen, pretrain) - CLIs: train, nested-cv (refit without validation), extract, predict Tests, niche analysis and docs follow in later commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NqExFvaq8RhDYBj6RShCMk
…rs optional - grass_mil.niches: niche discovery in the attention-head space (cosine HDBSCAN on a sample, k-NN assignment), niches numbered by margin with Background for unassigned cells; per-niche composition, empirical association and attention-weighted margin with a bootstrap CI over units; per-niche Moran's I, neighbourhood enrichment, cross-L at r* and contact enrichment; niche co-localisation; optional survival (Cox per niche share, Kaplan-Meier of score tertiles); figures following the preprint panels - grass_mil.niches.replication: grass-mil-metaclusters on the same discovery - grass_mil.spatial: one implementation of every statistic, shared by the niche descriptors and grass-mil-spatial-stats - remove the report/plugin stack, grass-mil-scores, the instance export and the evaluation package - packaging: 1.1.0, seven entry points, dependencies trimmed to imports Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NqExFvaq8RhDYBj6RShCMk
Data (inputs, graphs, units, labels, splits, PCA, stale-graph guard), sampling (exact k-hop ego-graphs, every cell scored once, fixed roots, interior roots, radius cap), models (pooling identity, Cox loss, probe folding, augmentations, clipping hook, freezing), training (every regime, regression, survival, rebuild from checkpoint, no-validation runs), nested CV (selection fallbacks, refit without validation), prediction, extraction, niches, spatial statistics, replication, configs and entry points, and the whole workflow through the installed commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NqExFvaq8RhDYBj6RShCMk
…ross-L titles Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NqExFvaq8RhDYBj6RShCMk
- README: the method, install, quick start, a workflow table, changing the defaults, documentation and citation; no preprint-reproduction section - docs/: data preparation, training and evaluation, niche analysis and a configuration reference replace the sixteen previous pages (including the method-correspondence page and the generated repository map) - vignettes: rewritten and executed on squidpy's MIBI-TOF data (tiles as units, a CD8-infiltration phenotype): pretraining, the default regime, niches, nested cross-validation, replication and model-free statistics; outputs carry no local paths - CI: one test workflow on Python 3.11/3.12 and macOS with torch-sparse, one pre-commit workflow; no release drafter; real coverage thresholds; weekly dependabot; a short PR template - environment.yaml installs the package; Makefile targets test/test-all; CHANGELOG 1.1.0 - spatial-stats compares patients or units (compare_by); niches are numbered by the margin statistic the table reports; random splits stratify only when every patient has one class Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NqExFvaq8RhDYBj6RShCMk
Training and evaluation - Cox loss: tied times share the Breslow risk set; survival heads start from a ridge-Cox probe; Harrell's C counts censoring at an event time as at risk - the last, smaller hyperbatch of an epoch is stepped before validation - nested CV refuses folds that split a unit or patient, and refits keep the inner runs' learning-rate schedule (finetune.schedule_epochs) - class labels must be integers 0..C-1; patient metrics need one target per patient; explicit splits may not overlap - PCA fit_on=train uses the split setup() draws; per-sample PCA removed; PCA from the feature covariance - InputSpec carries feature names, edge features and a preprocessing fingerprint; predict and extract refuse cohorts preprocessed differently; predict scores the roots the test split scores - CSV features=all keeps numeric columns; non-finite inputs are refused - checkpoints load with weights_only=True and once per command Niche statistics - margins are relative to the model's mean instance logit (recorded at extraction) instead of the head bias, whose offset set every margin's sign - margin intervals resample patients (NaN with one patient) - cross-L relative to random labelling (cancels window and edge effects) - Moran's I tested with exact randomisation moments; enrichment adds a size-free log2 ratio, which spatial-stats compares - Cox fit with step halving and convergence check; outcomes with missing values dropped - cell caches resume only over files of the same checkpoint - transfer consensus shares are descriptive (no in-sample tests) Simplifications: one strict-config helper and one plain() helper, one group-test and patient-label helper, vectorised attention and contact counts, per-unit slices in Cells, sample-weight path and freeze_head removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NqExFvaq8RhDYBj6RShCMk
Restores the bias-omitted margin of the method; the single-patient NaN interval stays. Vignettes re-executed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NqExFvaq8RhDYBj6RShCMk
data.pyg.org has no page per bare PyTorch version (torch-2.4.1.html is a 404); point at the CPU wheels (torch-<version>+cpu.html), which serve CUDA builds of PyTorch too since ego-graph sampling runs on the CPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NqExFvaq8RhDYBj6RShCMk
From a new-user walkthrough of the docs: - README: "Your first cohort" with a project layout, the cohort file in configs/experiment with --config-dir, hydra.run.dir per step and what to look at in every output folder - data preparation: sample / region / unit / patient defined; scripts for the manifest and for patient-grouped, class-stratified folds - training: plain explanations of BGRL, the probe and the hyperbatch; which nested-CV number to report; a small-cohorts section (frozen encoder, probe penalty, selection on the loss) - niche analysis: how to read the margins, small-cohort clustering settings, +clustering keys for metaclusters; configuration: command-line basics - the template reads ./data by default and shows --config-dir - commands print their checkpoint, summary and output folders; warnings for a large probe head, warmup >= pretraining steps, no niches found and single-class outer folds; the nested-CV summary reports the task's metric whatever metric selects the epochs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NqExFvaq8RhDYBj6RShCMk
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.
What does this change?
GRASS-MIL 1.1.0 turns the 1.0.0 paper companion into a package with one default path: BGRL pretraining, then
finetunewith an automatically fitted probe head, then nested CV, per-cell extraction and niche analysis. SeeCHANGELOG.mdfor the full list.Breaking: commands, configuration keys and file formats changed. Graphs and checkpoints from 1.0.0 must be rebuilt.
Regimes renamed, with
finetuneas the default:linear_ftall→finetune,linear_ftall_reg→finetune_reg,linear_probehead→attention_only,mil→mlp_head,mil_frozen→mlp_head_frozen,pretrain_a3→pretrain. The probe head is now fitted automatically, sograss-mil-probeis gone.grass-mil-nichesreports the primary results:grass-mil-metaclustersandgrass-mil-spatial-statsare optional.Removed:
grass-mil-report,-eval,-loocv,-scoresand-probe;Configuration:
data.inputblock for CSV, TSV, h5ad and SCE;data.unit(region,tileorpolygon);task(classification,regressionorsurvival), each with its own selection metric.Fixes:
grass-mil-predictreports AUROC, works withoutregime=, and refuses cohorts preprocessed differently from training.Docs:
squidpy.datasets.mibitof().