Skip to content

Address review comments and rewrite bbknn_ts in the component style - #2

Open
rcannood wants to merge 2 commits into
cmclean:feature/task_batch_integration/add-bbknn_ts-methodfrom
openproblems-bio:era-combat-bbknn-review-comments-and-rewrite
Open

Address review comments and rewrite bbknn_ts in the component style#2
rcannood wants to merge 2 commits into
cmclean:feature/task_batch_integration/add-bbknn_ts-methodfrom
openproblems-bio:era-combat-bbknn-review-comments-and-rewrite

Conversation

@rcannood

Copy link
Copy Markdown

Describe your changes

Everything in #1, plus a rewrite of the integration code in the OpenProblems component style. The two PRs are alternatives -- take this one if you're fine with the generated code being reorganised, take #1 if you'd rather keep it verbatim.

On top of #1:

  • the script is now a regular component script: imports at the top, one ## VIASH START block, a batch_aware_knn() helper and a linear body with the usual print(..., flush=True) steps (279 -> 144 lines)
  • the graph construction is vectorised per query batch. The per-cell dictionaries that kept the minimum distance per neighbour turn out to be a no-op: the batches partition the cells, so each (cell, neighbour) pair is produced by exactly one query. That removes two nested Python loops over every cell and every candidate, which on a 300k-cell dataset was ~150M dict operations
  • dropped the degenerate-data fallback (n_obs <= 1, n_comps <= 0), which can't trigger on a benchmark dataset -- a component should fail loudly there rather than emit a placeholder embedding

The rewrite is output-identical, not just close. Running your original code and this one in the same image on resources_test/task_batch_integration/cxg_immune_cell_atlas:

X_emb distances connectivities
original vs rewrite, same image exactly equal exactly equal exactly equal
original :1.0.0 vs rewrite :1 2e-06 relative same sparsity pattern, max diff 3.8e-06 bit-identical

32562 nonzeros in every run. The second row is purely the docker tag bump (numpy 2.2.6 -> 2.5.2, scanpy 1.10.4 -> 1.12.3), which the old tag forces anyway since it fails check_config against the current common/ submodule.

viash test src/methods/era_combat_bbknn/config.vsh.yaml succeeds.

Note that the branch still needs a merge with main before it can go in -- run_benchmark has moved on quite a bit since September.

Checklist before requesting a review

  • I have performed a self-review of my code

  • Check the correct box. Does this PR contain:

    • Breaking changes
    • New functionality
    • Major changes
    • Minor changes
    • Bug fixes
  • Proposed changes are described in the CHANGELOG.md

  • CI Tests succeed and look good!

* renamed the component to `era_combat_bbknn`, after the ERA system and the two algorithms it combines
* `method_types: [embedding, graph]`: the custom kNN graph is evaluated as is
* `preferred_normalization: counts`: the method does its own normalisation
* pass `--n_pca_components`, `--n_neighbors_per_batch` and `--total_k_neighbors` through to the integration code, they were unused
* store a minimal output object instead of the mutated input
* updated the reference to the Nature paper and the links to the renamed `google-research/era` repo
* `openproblems/base_python:1` and `[hightime, highmem, midcpu]`, in line with the other methods
The graph construction is vectorised per query batch, which gives the exact same
distances and connectivities on the test resource -- the per-cell dictionaries only
ever held one distance per neighbour, since the batches partition the cells.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant