Repository navigation
[experimental] Spatial index of points (RFC 3) and shapes (RFC 4) - #13
Draft
LucaMarconato wants to merge 21 commits into
Draft
LucaMarconato wants to merge 21 commits into
LucaMarconato wants to merge 21 commits into
Conversation
…ader, points format 0.3 - build_points_spatial_index / write_points_with_spatial_index: random priority p, levels as bands, tile-major table and feature-major tables, tile_offsets, in Parquet or Zarr (df:/enum: conventions) - PointsSpatialIndex / read_points_spatial_index: query by box, level, budget and features - feature index: dense as in RFC 3, or sparse (CSR over features, a proposed fix for whole-transcriptome panels) - PointsFormatV03; _read_points reads the Zarr storage Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi! I'm the It looks like you correctly set up a CI job that uses the autofix.ci GitHub Action, but the autofix.ci GitHub App has not been installed for this repository. This means that autofix.ci unfortunately does not have the permissions to fix this pull request. If you are the repository owner, please install the app and then restart the CI workflow! 😃 |
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
…-data benchmark script - build_shapes_spatial_index: sort shapes by the tile of their centroid (optionally on the grid of an indexed points element), GeoArrow geometry, tile_offsets and margin; reorder the annotating table to the shapes order with X as CSR and layers['X_csc'] as CSC; optionally the centroids as indexed points - ShapesSpatialIndex: query by box (grown by the margin), gene values from the CSC layer, CSR rows - benchmarks/spatial_index_real_data.py: queries with and without the index on real data Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…data test; asv benchmark Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… once; vectorized feature index With row groups of about one tile and 27k features, a full dictionary per row group was 9 GB of the 23 GB tile-major table of the Atera breast dataset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…feature column Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ly the footers a query needs; example notebooks generator Opening the Atera breast index went from 0.45 s (66.7k row-group footers) to 3 ms; a whole-slide query of one gene from 0.79 s to 0.06 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xed element into a store Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a tables annotate the labels); resumable Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a-db): tiled points and tiled cells Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…offsets, area-weighted Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RFC 3: same layout in Parquet and Zarr (spatial/, feature/<key>/), spatial_index in zarr.json plus a Parquet sidecar (part files in order, first rows, global categories); sparse feature index only; offsets int32 when the rows fit; p stored as k with p = k / 2^p_bits (16 bits by default, more if the coarsest level needs it), an existing p kept; all spatial axes in the grid (a single tile along z); tile size for the median tile; Parquet row groups of 250k-1M rows holding several tiles. RFC 4: the grid of the shapes chosen by the rule of thumb (>50% of the shapes within their tile), optionally nested with the grid of the points; margin and table in spatial_index; spatial/shapes.parquet with the sidecar; the table must annotate the shapes. spatialdata: GeoArrow is the default geometry encoding of shapes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arse tiles extend beyond it) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts can represent Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and shapes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o p = P(l) is in a finer band Found by the real-data check on Atera breast (one point with p = 1/4 read at level 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ements without spatial_index Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oints; tiled cells and table) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <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.
Requested by Luca · project thread
Experimental implementation of RFC 3: tiled and multiscale points (draft on scverse/spatialdata-spec#98), to test the spec on real data (10x Atera). napari side: LucaMarconato/napari-spatialdata#1. Proposed spec fixes, benchmarks and sizes: https://claude.ai/artifact/4H6Svd7NRVhE9x1v8inNaM
What's in it
build_points_spatial_index(sdata, name, storage="parquet"|"zarr", ...): rewrites a points element of a disk-backedSpatialDatasorted and indexed, in points format 0.3 (Parquet,PointsFormatV03) or 0.3-experimental (Zarr,PointsFormatV03Experimental).write_points_with_spatial_index(points, path, ...)does the same for any dask/pandas dataframe.target_points_per_tile), merge rule for the levels and default rates; pass B draws p, assigns bands/tiles and counts; pass C scatters partitions into bucket files; pass D sorts each bucket and writes the tile-major and feature-major tables and their offsets.points.parquet/(tile-major, row groups aligned to tiles),tile_offsets/<l>,feature/<key>/{points.parquet,tile_offsets}. Zarr storage:spatial/points(df:+enum:conventions, sharded), same offsets.PointsSpatialIndex/read_points_spatial_index(path):query(box_min, box_max, level=, budget=, features=, use_feature_index=).feature_index="dense"follows the RFC (int64[n_features, N_tiles+1]per band);"sparse"is a proposed fix (CSR over features of the non-empty tiles), since the dense one does not scale to whole-transcriptome panels (27k features × ~500k tiles).feature/<key>/categories;part_offsetsso readers open only the footers they need.build_shapes_spatial_index(cells sorted by centroid tile on the points grid, GeoArrow, margin, table reordered to the shapes withXCSR +layers["X_csc"], optional indexed centroids),ShapesSpatialIndex; shapes format 0.4.examples/spatial_index/: two notebooks executed on the Atera kidney dataset of spatialdata-db.benchmarks/spatial_index_benchmark.py(asv, synthetic),spatial_index_real_data.py,spatial_index_shapes_real_data.py.Testing
tests/io/test_spatial_index.py: Parquet/Zarr × dense/sparse, query vs brute force at every level, budget, feature-major vs tile-major equality, rebuild keeps p, merge rule example of the RFC.tests/iopasses. CI tests are small and fast (7 tests, ~7 s);tests/io/test_spatial_index_real_data.pychecks real indexed stores locally (skipped unlessSPATIALDATA_SPATIAL_INDEX_REAL_DATAis set) and passes on Atera breast (Parquet, Zarr).🤖 Generated with Claude Code