Skip to content

read_10x_mtx cannot deal with numerical gene symbols #3909

Closed

Description

@arteymix

Please make sure these conditions are met

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of scanpy.
  • (optional) I have confirmed this bug exists on the main branch of scanpy.

What happened?

The read_10x_mtx function uses Pandas' defaults for reading tabular data which results in numerical gene IDs such as NCBI gene IDs to be interpreted as number. This does not work with make_unique=True because it will attempt to concatenate a unique suffix to a float.

Minimal code sample

import scanpy
a = scanpy.read_10x_mtx('./GSE227313/1505436_Sorted_vHipp_D1_replicateB', var_names='gene_ids')

Error output

/home/guillaume/Projets/gemmapy/.venv/lib64/python3.14/site-packages/anndata/_core/anndata.py:865: UserWarning: 
AnnData expects .var.index to contain strings, but got values like:
    [109979, 18952, 109978, 18950, 18951]
    Inferred to be: integer
  names = self._prep_dim_index(names, "var")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/guillaume/Projets/gemmapy/.venv/lib64/python3.14/site-packages/legacy_api_wrap/__init__.py", line 88, in fn_compatible
    return fn(*args_all, **kw)
  File "/home/guillaume/Projets/gemmapy/.venv/lib64/python3.14/site-packages/scanpy/readwrite.py", line 582, in read_10x_mtx
    return adata[:, gex_rows].copy()
           ~~~~~^^^^^^^^^^^^^
  File "/home/guillaume/Projets/gemmapy/.venv/lib64/python3.14/site-packages/anndata/_core/anndata.py", line 1049, in __getitem__
    oidx, vidx = self._normalize_indices(index)
                 ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/home/guillaume/Projets/gemmapy/.venv/lib64/python3.14/site-packages/anndata/_core/anndata.py", line 1030, in _normalize_indices
    return _normalize_indices(index, self.obs_names, self.var_names)
  File "/home/guillaume/Projets/gemmapy/.venv/lib64/python3.14/site-packages/anndata/_core/index.py", line 36, in _normalize_indices
    ax1 = _normalize_index(ax1, names1)
  File "/home/guillaume/Projets/gemmapy/.venv/lib64/python3.14/site-packages/anndata/_core/index.py", line 46, in _normalize_index
    raise TypeError(msg)
TypeError: Don’t call _normalize_index with non-categorical/string names and non-range index Index([   109979,     18952,    109978,     18950,     18951,    108645,
       102640821, 102640825,    626832,    626834,
       ...
           19263,     19264, 100043034,     19261,     20248,     19262,
           20249,     19260,    403088, 100043033],
      dtype='int64', length=24428)

Versions

Details
scanpy	1.11.5
----	----
matplotlib	3.10.7
scipy	1.16.3
PyYAML	6.0.3
joblib	1.5.2
pandas	2.3.3
cycler	0.12.1
natsort	8.4.0
scikit-learn	1.7.2
threadpoolctl	3.6.0
typing	3.10.0.0
llvmlite	0.46.0
numpy	2.3.5
donfig	0.8.1.post1
anndata	0.12.6
session-info2	0.2.3
pytz	2025.2
typing_extensions	4.15.0
numcodecs	0.16.5
pillow	12.0.0
pyparsing	3.2.5
legacy-api-wrap	1.5
packaging	25.0
h5py	3.15.1
kiwisolver	1.4.9
six	1.17.0
python-dateutil	2.9.0.post0
setuptools	80.9.0
zarr	3.1.5
numba	0.63.0
google-crc32c	1.7.1
----	----
Python	3.14.0 (main, Oct 17 2025, 00:00:00) [GCC 15.2.1 20251022 (Red Hat 15.2.1-3)]
OS	Linux-6.17.9-300.fc43.x86_64-x86_64-with-glibc2.42
CPU	16 logical CPU cores
GPU	No GPU found
Updated	2025-12-09 23:51

Activity

  1. added
    Triage 🩺This issue needs to be triaged by a maintainer
    on Dec 9, 2025
  2. added theissue type on Dec 9, 2025
  3. added
    Area - IOReading and writing
    and removed
    Triage 🩺This issue needs to be triaged by a maintainer
    on Dec 23, 2025
  4. added this to the 1.12.0 milestone on Dec 23, 2025
  5. flying-sheep commented on Dec 23, 2025

    @flying-sheep
    Member

    Thanks for the report! Please try installing #3932 and tell me if it works:

    pip install 'scanpy @ git+https://github.com/scverse/scanpy.git@pa/10x-numeric-genes'

    Also where did you get that metadata from? It’s not on GEO.

  6. arteymix commented on Dec 24, 2025

    @arteymix
    Author

    We generate 10x MEX files in Gemma to serialize our single-cell data, and some of our platforms uses NCBI gene identifiers.

    We have a Python SDK, and I've been working on integrating single-cell data with scanpy at PavlidisLab/gemmapy#39.

    You can retrieve an example from https://gemma.msl.ubc.ca/rest/v2/datasets/GSE208707/data/singleCell. We bundle multiple sets of MEX files in a TAR archive.

    I will test your branch once I'm back from vacations.

  7. flying-sheep commented on Jan 5, 2026

    @flying-sheep
    Member

    OK, I added a test to the PR, it’ll work.

  8. self-assigned this
    on Jan 5, 2026
  9. arteymix commented on Jan 5, 2026

    @arteymix
    Author

    I just tested the branch, and it's working on our data.

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

Metadata

Metadata

Assignees

Labels

Area - IOReading and writing

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions