Repository navigation
Restore the per-cell scale of senkin_tmp and ss_opm predictions - #80
Merged
Merged
Conversation
Both 2022 competition solutions predict a z-scored profile per cell (the competition scored per-cell Pearson only). Mapping that back with one global slope and intercept gave every predicted cell the same mean and standard deviation, so per-gene correlations, overall correlations and RMSE/MAE scored the missing per-cell level rather than the methods. src/utils/cell_scale.py predicts each cell's target mean and log standard deviation from its input (ridge regression on a truncated SVD of the normalized input plus two sequencing-depth features) and restores them, with the spread shrunk by one least-squares factor fitted on training-cell predictions (out-of-fold for senkin_tmp). Per-cell correlations are unchanged. ss_opm_predict keeps the old global map for model bundles trained before this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 8 tasks
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.
Describe your changes
Problem
senkin_tmpandss_opmare the two 2022 Kaggle solutions, and that competition scored only the mean per-cell Pearson correlation. Both predict a z-scored profile per cell, and the wrappers mapped it back to the target scale with one global slope and intercept. Every predicted cell therefore has the same mean and standard deviation: 0.5955 and ~0.45 onbmmc_cite, where the true per-cell mean ranges from 0.16 to 2.83.Per-cell correlations are unaffected. Per-gene correlations, overall correlations and RMSE/MAE, however, scored that missing information rather than the methods. On the rc7 leaderboard both methods rank 2nd–3rd on per-cell Pearson for GEX → ADT and 10th–12th on per-protein Pearson.
Change
src/utils/cell_scale.py(new):RidgeCV) on a 64-component truncated SVD of the normalized input plus log total counts and log detected features.numpy.savez, not a pickle, so it loads safely in the predict image.senkin_tmp_train: replaces the global affine map withCellScale.ss_opm_train/ss_opm_predict: train fits and savescell_scale.npz; predict applies it. Model bundles without that file, such as the S3 test resources, still get the old global map.Validation
1. Offline comparison of estimators. On saved predictions, the per-cell z-scores were rescaled with each candidate estimate and scored against the test solution. Ridge on SVD plus depth features beat kNN and LightGBM on correlations. Restoring the full per-cell standard deviation raised RMSE wherever the per-cell correlation is low (GEX → ATAC: 0.51 → 0.65), hence the shrinkage factor. With it, every correlation and error improved or held, apart from three small losses on the multiome targets: ATAC → GEX 2021 MAE (+0.005 end to end), and GEX → ATAC 2022 per-gene Pearson (−0.002) and RMSE (+0.0005).
2. End-to-end runs of the changed components on the full datasets, against the runs of the current code on the same data, scored like the benchmark's metric components:
senkin_tmp on 2022 GEX → ADT is still running (Slurm job 40930275);
code/cell_scale_check/compare_scores.pyadds it when it finishes.viash test(native engine) passes forss_opm_train,ss_opm_predict(old bundle → fallback path) andsenkin_tmp_train.ss_opm_predictwas also run on a bundle withcell_scale.npzproduced by the train test.Checklist before requesting a review
I have performed a self-review of my code
Check the correct box. Does this PR contain:
Proposed changes are described in the CHANGELOG.md
CI Tests succeed and look good!