Repository navigation
Conversation
`.sync_shapes_on_drop()` matched a table's instances against `instances(y)`, which is `seq_len(nrow(y))` for a shape element without an `instance_key`. Shape elements that do carry the ids, in a column named after the table's instance key, were still matched by row position: with ids from 0, attaching the table dropped the last shape, and attaching a subset of the table kept the wrong shapes. For an element without an `instance_key`, that column is now used when the element has it, as in `.sync_tables_on_crop()` and `getTable()`. If the table already has all of `instances(y)`, nothing is dropped and the element is put back as is, so a whole table numbered by row position keeps all shapes even if the element has a column named after the table's instance key, as can happen with `setTable()` and `mask()`. A subset of such a table is matched on the column. Other elements are matched as before.
CuiweiG
force-pushed
the
fix-252-shape-sync
branch
from
November 16, 2026 07:30
e7b2660 to
8721758
Compare
This branch has not been deployed
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.
Refs #252.
.sync_shapes_on_drop()matchesinstances(t)againstinstances(y), which isseq_len(nrow(y))for a shape element without aninstance_key, so ids that start at 0 are compared with row positions and the last shape is dropped. On devel, readingmerfish.zarr.zipfrom the BiocSpatialData OSN bucket leaves 2,388 of 2,389cells, andvisium_associated_xenium_io_aligned.zip4,991 of 4,992 spots.crop()reattaches the tables through the same function: a box with 151 MERFISH cells comes back with 151 observations in the table and no cells.In both stores the ids are in a column named after the table's instance key (
cell_id,spot_id). For an element without aninstance_key, the function now matches on that column when the element has it, as.sync_tables_on_crop()andgetTable()do. If the table already has all ofinstances(y), the element is put back as is, so a whole table numbered by row position keeps all shapes.A subset of such a table is matched on the column, though, and can keep the wrong shapes.
setTable()numbers a table by row position if the shapes have noinstance_keyand no column namedik, also when the table comes with aninstance_keythat names one of their columns, andmask()does ifjhas noinstance_key. I've left both as they are, because they number by the element'sinstance_key, and an element with several tables has only one. That looks like a question for #195.Not changed: an element with an
instance_key, or without such a column, is matched as before, so theblobs_circlesexample in #252, whose parquet file has only a range index, still loses a row. I've left that to #195 as well.query()also still filters the shapes by position before it attaches the table: on MERFISH,query(x, cell_id %% 2 == 0)keeps none of the 1,195 cells.The test in
test-sync.Rfails on devel.devtools::check()on the Bioconductor devel Docker image (R 4.6.1) gives 0 errors, 0 warnings and the same 4 notes as devel, andlintris clean on the changed files.#267 changes the same lines and adds an early exit there, so I'm happy to rebase onto it or fold this into it.