Skip to content

Fix LoadXenium for standalone gene panels - #10514

Open
YoukaiFromAccounting wants to merge 1 commit into
mainfrom
fix-loadxenium-geneonlypanel
Open

YoukaiFromAccounting wants to merge 1 commit into
mainfrom
fix-loadxenium-geneonlypanel

Conversation

@YoukaiFromAccounting

Copy link
Copy Markdown
Contributor

Fixes #9142

This PR fixes LoadXenium() for standalone gene panels containing only Gene Expression features.

Read10X_h5() normally returns a named list when multiple feature types are present (ie: gene expression, negative control probes, negative control codewords), but returns a bare dgCMatrix when only one feature type is present. LoadXenium() had previously assumed data$matrix was always a list and attempted to access data$matrix[["Gene Expression"]], which would result in the following error when using LoadXenium to load in standalone gene panels:

Error in `CreateAssayObject()`:
! No cell names (colnames) names present in the input matrix

This PR makes a small change in LoadXenium() to use the matrix directly when data$matrix is not a list, while defaulting to the existing behaviour for datasets with multiple feature types.

Reproducible example

library(Seurat)
library(Matrix)

counts <- sparseMatrix(
  i = c(1, 2),
  j = c(1, 2),
  x = c(1, 1),
  dimnames = list(
    c("Gene1", "Gene2"),
    c("Cell1", "Cell2")
  )
)

data <- list(matrix = counts)

class(data$matrix)
is.list(data$matrix)

# Previous behavior of counts = data$matrix[["Gene Expression"]] (used in LoadXenium) will error
data$matrix[["Gene Expression"]]

This fix was adapted from prior changes suggested by @BenjaminDEMAILLE in #10489.

Copilot AI lite review requested due to automatic review settings September 18, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A regression test for standalone single-feature Xenium panels is missing.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes LoadXenium() for standalone Xenium gene panels by supporting bare sparse matrices returned when only one feature type is present.

Changes:

  • Uses the matrix directly for non-list inputs.
  • Preserves existing extraction for multi-feature lists.
File summaries
File Description
R/convenience.R Updates Xenium count-matrix selection.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread R/convenience.R
Comment on lines +270 to +274
counts = if (is.list(data$matrix)) {
data$matrix[["Gene Expression"]]
} else {
data$matrix
},
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.

LoadXenium() issue on the 480genes standalone panel, Xenium V1

2 participants