Merge scanorama back into one component and fix its scrambled output - #113
Merged
Conversation
* both outputs come from a single `correct_scanpy(return_dimred=True)` run, so there is no reason to run scanorama twice * put the cells and genes back in the order of the input -- scanorama returns one object per batch with the genes sorted by name, so both axes were permuted with respect to the `obs` and `var` they were labelled with * dropped the `merge_adata()` helper along with the deprecated `AnnData.concatenate()` it wrapped
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
Reverts the split from #88 and fixes the bug that motivated it.
The low score that #88 set out to correct wasn't caused by reporting two output types in one entry -- it was caused by
methods/scanoramascrambling its own output along both axes:scanorama.correct_scanpy()returns one object per batch, soAnnData.concatenate()produced the cells grouped by batch, whileobs=adata.obs[[]]labelled them with the original ordervar=adata.var[[]]labelled them with the original orderBoth outputs were affected, and since
transformderivesX_emband the kNN graph fromcorrected_countsfor a feature method, every metric was scored on mismatched data -- not justhvg_overlap. Splitting the component happened to fix the embedding side, becausescanorama_integratescattersX_scanoramaback into the original row order instead of concatenating.scanorama_correctkept the bug, so its 0.3051 is still not meaningful.So this PR puts the two components back together and fixes the ordering instead. Both outputs come from a single
correct_scanpy(return_dimred=True)run, which is what the component did before #88, so there's no reason to run scanorama twice. If we ever want the modes as separate entries, an argument is a cheaper way to get there than two components.Verification
Mean per-cell correlation between
corrected_countsand the input cell it claims to describe, onresources_test/task_batch_integration/cxg_immune_cell_atlas:scanorama_correcton mainscanoramain this PR+0.7900 is exactly the value you get by taking main's output and manually undoing the two permutations, so the fix recovers the intended result rather than changing it.
No regression on the embedding side:
X_embfrom this component is bit-identical toscanorama_integrateon main (600 x 100, max abs diff 0.000e+00), which also confirmscorrect_scanpy(return_dimred=True, dimred=100)andintegrate_scanpy(dimred=100)compute the same thing.viash test src/methods/scanorama/config.vsh.yamlsucceeds.Also dropped the
merge_adata()helper, which only existed to wrap the deprecatedAnnData.concatenate().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!