Repository navigation
fix: detect the header of Visium tissue positions files from their contents - #10534
Open
MMatinGerami wants to merge 1 commit into
Open
MMatinGerami wants to merge 1 commit into
MMatinGerami wants to merge 1 commit into
Conversation
…ntents Read10X_Coordinates() decided whether a tissue positions CSV has a header from its file name alone. A headed file with the older tissue_positions_list.csv name (common on GEO) was read with the header as a data row, so every column became character and Read10X_Image() failed with "cannot derive coordinates from non-numeric matrix". A headerless file named tissue_positions.csv lost its first spot. Closes satijalab#9240
MMatinGerami
force-pushed
the
fix/read10x-coordinates-header
branch
from
October 29, 2026 02:26
17e30cf to
d825e11
Compare
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
Read10X_Coordinates()decided whether a tissue positions CSV has a header from the file name alone (header = basename(filename) == "tissue_positions.csv"). Files are often renamed, for example on GEO, so:tissue_positions_list.csvis read with its header as a data row, every column becomes character, andRead10X_Image()fails withcannot derive coordinates from non-numeric matrix(the case in Error in .local(obj, ...) : cannot derive coordinates from non-numeric matrix #9240);tissue_positions.csvsilently loses its first spot.This PR detects the header from the first line instead: in a data row the second field (
in_tissue) is always 0 or 1, so the line is treated as a header otherwise (quotes are stripped first).Type of change
Motivation
Users loading Visium data downloaded from GEO keep hitting #9240 (reports up to Dec 2025), and the header assumption was identified in the issue thread.
Tests & examples
A new test in
tests/testthat/test_load_10X.Rwrites the bundledtissue_positions_list.csvwith a header under a GEO-style_listname, and without a header under thetissue_positions.csvname, and checks that both read as numeric coordinates with the right number of spots and give the same result as the original file. Before the fix 7 expectations fail (character columns; 4993 and 4991 rows instead of 4992); with the fixtest_load_10X.Rpasses (10 tests, 66 expectations), as doestest_spatial.R.Related issues
Closes #9240
Checklist
feat/*,fix/*,docs/*)devtools::document()has been run (not needed: no roxygen or exported signature changed)devtools::check()passes with no errors or warnings (not run locally; I ran the affected test files)