Restore the original cell order after the FCS roundtrip - #128
Closed
rcannood wants to merge 3 commits into
Closed
Conversation
* Add fcs_cell_order() to anndata_to_fcs.R * Use it in gaussnorm and the six cytonorm methods * Check that cytonorm returns the same number of cells per sample
ghar1821
reviewed
Jul 30, 2026
ghar1821
left a comment
Contributor
There was a problem hiding this comment.
The changes here would "reshuffle" the output of a method if the method has somehow reordered the cells when performing the correction. But we should be penalising this because it means the method has done something it should not have done. Thus we should not try to correct it.
Hence this pull request should not go ahead.
LuLeom
reviewed
Jul 30, 2026
LuLeom
left a comment
Contributor
There was a problem hiding this comment.
BatchAdjust ordering check was meant to control the behaviour of the implementation, as it is the more fragile one. Methods that shuffle rows should be penalised
Contributor
|
Closing this without merging. See comments. |
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
anndata_to_fcs()builds one flowFrame per sample, soflowCore::fsApply(fset, exprs)gives the cells back grouped per sample.gaussnormand the sixcytonorm_*methods then attach that matrix to the obs of the input AnnData, which is in the original cell order:As long as the cells in the input happen to be contiguous per sample and in first-appearance order, the two orders coincide and everything is fine -- which is presumably why this hasn't shown up. But nothing in
file_censored_split1.yamlguarantees it, and if it ever doesn't hold, every cell gets paired with another cell's expression values. Silently. It would look like a badly performing method rather than a bug.batchadjust_*already guards against this explicitly with itsOriginal_IDcolumn; this PR does the equivalent for the other two families:fcs_cell_order()tosrc/utils/anndata_to_fcs.R, which returns the AnnData row indices in the order the concatenated matrix has them, looked up by the FlowSet's own sample names. It errors out if the FlowSet doesn't cover exactly the cells of the AnnData object.methods/gaussnormand in the sixmethods/cytonorm_*variants.CytoNorm.normalize()returned the same number of cells per sample as it was given, so the assumption that it preserves frame order fails loudly rather than silently.This is a no-op when the current implicit assumption holds --
order(fcs_cell_order(...))is the identity permutation for sample-contiguous input -- so it should not change any score unless there was a real problem to begin with. That also makes it a cheap way to find out whether there was one: if a score moves, the ordering was wrong.I haven't been able to run
viash testfor these locally, so CI and a test benchmark run are the real check here.Found while reviewing the task ahead of the next full benchmark run -- see also the sibling PRs.
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!