fix: keep FlyBase gene nan when reading 10x mtx - #4329
Open
joncarse wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4329 +/- ##
=======================================
Coverage 81.98% 81.98%
=======================================
Files 134 134
Lines 13235 13237 +2
=======================================
+ Hits 10851 10853 +2
Misses 2384 2384
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Contributor
Author
|
I doubt "nan" will ever appear as truly meaning a nullish value in any TSV file. If this is a concern we can technically filter out "nan" only for Drosophila analyses. But then again maybe someone will try to splice it into another organism :) |
joncarse
commented
Aug 30, 2026
| if var_names == "gene_symbols": | ||
| assert adata.var_names[0] == "nan" | ||
| assert not pd.isna(adata.var_names[0]) | ||
| adata.var["mt"] = adata.var_names.str.startswith("mt:") |
Contributor
Author
joncarse
commented
Aug 30, 2026
| here avoids a private import in ``read_10x_mtx``. On failure, update | ||
| ``_PANDAS_STR_NA_VALUES`` in ``scanpy.io._read``. | ||
| """ | ||
| from pandas._libs.parsers import STR_NA_VALUES |
Contributor
Author
There was a problem hiding this comment.
I wanted to protect against drift in future pandas versions but didn't want production code to import a private ("_") pandas member. Thought putting it as a test is a good tradeoff
joncarse
force-pushed
the
fix/read-10x-na-like-gene-symbols
branch
from
September 9, 2026 00:55
f0819da to
7200f5b
Compare
joncarse
force-pushed
the
fix/read-10x-na-like-gene-symbols
branch
from
September 10, 2026 13:37
7200f5b to
155cc30
Compare
joncarse
marked this pull request as ready for review
September 10, 2026 14:06
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.
FlyBase has a real gene named
nan.read_10x_mtxreadsgenes.tsv/features.tsvwithpd.read_csv, and pandas treatsnanas missing by default, so that symbol disappeared. That showed up ascalculate_qc_metricsblowing up aftervar_names.str.startswith(...)(#1259, also #1708), or as a silently wrong identifier.This keeps lowercase
nanas a gene name and still treats the rest of pandas’ NA tokens (NaN,NA, and so on) as missing. The default token list is copied in the reader so production code does not importpandas._libs; a test compares that copy to pandas so we notice if it drifts.barcodes.tsvis unchanged.