feat: add density map support to Xenium Explorer transcript writer#411
Open
jackytamkc wants to merge 1 commit intogustaveroussy:mainfrom
Open
feat: add density map support to Xenium Explorer transcript writer#411jackytamkc wants to merge 1 commit intogustaveroussy:mainfrom
jackytamkc wants to merge 1 commit intogustaveroussy:mainfrom
Conversation
While making paper figures I noticed that the density map toggle in Xenium Explorer v4.0+ no longer works with SOPA-converted data, though it worked in Explorer <4.0. Investigation revealed that SOPA's write_transcripts() was missing several data structures that native Xenium transcripts.zarr.zip files include. This adds writing of: - density/gene/ and density/codeword/ (CSR sparse transcript density at 10µm bins) - gene_category and codeword_category (boolean classification matrices) - metrics_density (float32 3D QC density grid at 20µm bins) - Associated root-level metrics_density_* attributes Claude was used to help with the coding. Reference format was derived from native Xenium tiny datasets (XOA 3.0 and 4.0). Verified working with Xenium Explorer on an in-house CosMx dataset converted via SOPA. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
While making paper figures I noticed that the density map toggle in Xenium Explorer v4.0+ no longer works with SOPA-converted data, though it worked in Explorer <4.0. Investigation revealed that
write_transcripts()insopa/io/explorer/points.pyonly writes thegrids/group, but native Xeniumtranscripts.zarr.zipfiles include additional arrays that Explorer v4+ requires for the density map.What's missing vs native Xenium format
density/gene/density/codeword/gene_categorycodeword_categorymetrics_densityChanges
sopa/io/explorer/points.py: Added_write_density()and_classify_gene_names()helper functions._write_density()is called at the end ofwrite_transcripts()to write all missing arrays into the zarr group.sopa/io/explorer/_constants.py: AddedDENSITY_GRID_SIZE(10µm) andMETRICS_DENSITY_SPACING(20µm) constants.No version bump, no new dependencies (uses
scipy.sparsewhich is already a SOPA dependency), no changes toconverter.pyor any other file.How it was verified
Claude was used to help with the coding part.
Test plan
.exploreroutput in Xenium Explorer v4.0+ and verify the density map toggle works🤖 Generated with Claude Code