Add scButterfly method (Multiome GEX↔ATAC) - #20
Open
benjaminfreyuu wants to merge 1 commit into
Open
Conversation
Adds scButterfly (Cao et al., Nat. Commun. 2024, doi:10.1038/s41467-024-47418-x), a dual-VAE + adversarial translator, as a train/predict method scoped to Multiome (GEX<->ATAC). Direction is detected from uns["modality"], covering both swap (ATAC->GEX) and normal (GEX->ATAC) variants. Train serializes the real scButterfly weights; predict reconstructs the model, reruns the (deterministic) preprocessing on the train data, loads the weights and runs inference, so it generalises to unseen test cells. Registered in run_benchmark and given a Multiome-only fixture step in test_resources.sh. Both components pass `viash ns test`. Co-Authored-By: Claude Opus 4.8 <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.
Summary
Adds scButterfly (Cao et al., Nat. Commun. 2024, doi:10.1038/s41467-024-47418-x) — a dual-VAE + adversarial translator for single-cell cross-modality prediction — as a train/predict method.
Butterflyclass. Direction is detected fromuns["modality"], covering bothswap(ATAC→GEX) andnormal(GEX→ATAC) variants. CITE-seq/ADT is out of scope and raises a clearValueError.What's included
src/methods/scbutterfly/— wrapper +scbutterfly_train+scbutterfly_predict, plus shared helpers (butterfly_common.py,chrom_utils.py).src/workflows/run_benchmark/{main.nf,config.vsh.yaml}.scripts/create_datasets/test_resources.sh— Multiome-only fixture-generation step (mirrorsnovel/simple_mlp).Design notes
scipy==1.9.3,scvi-tools==0.19.0,episcanpy==0.3.2) that won't build on the sharedopenproblems/base_*Python. The engine usespython:3.9+ torch cu117 wheels (CUDA bundled, so thegpulabel still works), scButterfly--no-deps+ the pinned stack, andopenproblemsfromopenproblems-bio/core(as the base images do).state_dicts (<model>/model/*.pt) +metadata.pkl; predict reconstructs the architecture and loads them, so it generalises to unseentest_mod1.data_preprocessingrefits HVG/peak-filter/TF-IDF on its input), so predict rebuilds the paired object from the train data and re-runs the deterministic preprocessing before loading weights.input_train_mod1is therefore wired into predict.size_averageloss kwarg; clamp BCE input to [0,1] (float32 sigmoid can drift >1.0); make.cuda()a no-op when no GPU is present.Verification
Verified locally:
viash ns test -s src/methods/scbutterfly— passes both components.bmmc_multiome/swapand.../normal: output matchestest_mod2in shape and var order, no NaNs, correctmethod_id/dataset_id.Needs CI / infra validation:
.cuda()shim; the native GPU path was not exercised).run_wfwrapper and fullrun_benchmarkrun (blocked locally by nextflow/JDK version constraints + component build size). The wrapper follows the standard train/predict pattern.test_resources.sh, which regenerates and syncs it).🤖 Generated with Claude Code