Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join with duplicate obs indices #822

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

melonora
Copy link
Collaborator

@melonora melonora commented Jan 8, 2025

Closes #815

The current way the join works on main does not account for duplicate indices in table.obs.index. This leads to a problem when performing the join as the indices are used to subset the table.

The implemented fix here gets the indices of the masked elements and then does a boolean masking on the obs dataframe with the index reset. This retrieves the integer indices which can then be used for subsetting the table. The behaviour of matching rows stays unchanged with this change.

from pathlib import Path
import spatialdata as sd
import spatialdata_plot

visium_zarr_path = Path("C:/Users/w-mv/PycharmProjects/spatialdata-notebooks/notebooks/examples/visium_brain.zarr")
visium_sdata = sd.read_zarr(visium_zarr_path)
(
    visium_sdata.pl.render_images(elements="ST8059050_hires_image")
    .pl.render_shapes(elements="ST8059050", color="mt-Co3")
    .pl.show()
)

now gives:
image

Copy link

codecov bot commented Jan 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.75%. Comparing base (54e7dd0) to head (64c5ffc).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #822      +/-   ##
==========================================
+ Coverage   91.73%   91.75%   +0.01%     
==========================================
  Files          46       46              
  Lines        7128     7130       +2     
==========================================
+ Hits         6539     6542       +3     
+ Misses        589      588       -1     
Files with missing lines Coverage Δ
src/spatialdata/_core/query/relational_query.py 90.78% <100.00%> (+0.26%) ⬆️

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.

Problem with join
1 participant