Conversation
…enes The per-batch results are combined with a groupby, which sorts the genes by name. The original order was only restored in the n_top_genes branch, so with the default cutoffs subset=True applied a name-sorted mask by position and kept the wrong genes. Restore the order of adata.var_names for both branches.
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.
highly_variable_geneswithbatch_keyandsubset=Truekeeps the wrong genes whenn_top_genesis not set #4370With
batch_keyset, the per-batch results are combined withdf.groupby(df.index), which sorts the genes by name. #3042 restored the original order, but only in then_top_genesbranch. With the default mean/dispersion cutoffs the frame stayed name-sorted, sosubset=Trueapplied the mask by position and kept the wrong genes (on pbmc3k with two batches only 269 of the 1857 kept genes were actual HVGs).inplace=Falsealso returned the rows in sorted order.The fix reindexes to
adata.var_namesonce after both branches instead of only inside theif.New test
test_subset_consistency_cutoffsrunsseuratandcell_rangerwithn_top_genes=None, with and withoutbatch_key, on data with unsortedvar_names. The two batched cases fail onmainand pass here, the unbatched ones pass on both.