Skip to content

fix: keep FlyBase gene nan when reading 10x mtx - #4329

Draft
joncarse wants to merge 2 commits into
scverse:mainfrom
joncarse:fix/read-10x-na-like-gene-symbols
Draft

fix: keep FlyBase gene nan when reading 10x mtx#4329
joncarse wants to merge 2 commits into
scverse:mainfrom
joncarse:fix/read-10x-na-like-gene-symbols

Conversation

@joncarse

Copy link
Copy Markdown
Contributor

FlyBase has a real gene named nan. read_10x_mtx reads genes.tsv / features.tsv with pd.read_csv, and pandas treats nan as missing by default, so that symbol disappeared. That showed up as calculate_qc_metrics blowing up after var_names.str.startswith(...) (#1259, also #1708), or as a silently wrong identifier.

This keeps lowercase nan as 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 import pandas._libs; a test compares that copy to pandas so we notice if it drifts.

barcodes.tsv is unchanged.

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.98%. Comparing base (a656a33) to head (f0819da).
✅ All tests successful. No failed tests found.

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           
Flag Coverage Δ
hatch-test.low-vers 79.07% <100.00%> (+<0.01%) ⬆️
hatch-test.pre 81.86% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/io/_read.py 80.74% <100.00%> (+0.14%) ⬆️

@joncarse

Copy link
Copy Markdown
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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ValueError: cannot convert float NaN to integer

1 participant