fix #391: convert GEF gene names to Unicode in bins reader path#437
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix #391: convert GEF gene names to Unicode in bins reader path#437cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
The BgefR (bins) code path in read_gef() was not converting gene names
from byte strings to Unicode strings, unlike the CgefR (cell_bins) path
which already called .astype('U'). This caused all gene name comparisons
with Unicode-based reference data (e.g., H5AD files) to fail silently
in Python 3, since b'GeneX' != 'GeneX'.
Changes:
- stereo/io/reader.py: Add .astype('U') for gene_names and gene_id in
both the filtered and unfiltered BgefR code paths, matching the
existing CgefR behavior.
- stereo/algorithm/single_r/single_r.py: Improve the SingleR error
message to include sample gene names and their types from both test
and reference datasets for easier debugging.
Co-authored-by: wanruiwen-genomics-cn <wanruiwen-genomics-cn@users.noreply.github.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
When reading GEF files with
bin_type='bins', theBgefRreader path did not convert gene names from byte strings (returned bygefpy) to Unicode strings. This caused all downstream gene name comparisons — such as those in SingleR annotation — to fail silently, sinceb'GeneX' != 'GeneX'in Python 3. Thecell_binspath (CgefR) already performed this conversion correctly.Changes
stereo/io/reader.py: Added.astype('U')conversion forgene_namesandgene_idin both the filtered (gene_list/region) and unfiltered BgefR code paths, matching the existing CgefR behavior.stereo/algorithm/single_r/single_r.py: Improved the SingleR gene intersection error message to include sample gene names and their Python types from both test and reference datasets, making future debugging much easier.Verification
Classification
Closes #391