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

vitessce spatialdata #397

Open
ArneDefauw opened this issue Jan 9, 2025 · 0 comments
Open

vitessce spatialdata #397

ArneDefauw opened this issue Jan 9, 2025 · 0 comments

Comments

@ArneDefauw
Copy link

ArneDefauw commented Jan 9, 2025

Thanks for the great package!

I want to visualize a spatialdata object using vitessce using the widget. I used the code from https://github.com/vitessce/vitessce-python/blob/main/docs/notebooks/spatial_data_blobs.ipynb. This notebook works, but now I also want to visualize the 'gene expression' spatially, similar as in https://github.com/vitessce/vitessce-python/blob/main/docs/notebooks/spatial_data.ipynb, but this does not seem to work.

This is my code:

import spatialdata

import os

from vitessce import CoordinationLevel as CL
from vitessce import CoordinationType as ct
from vitessce import (
    SpatialDataWrapper,
    VitessceConfig,
    get_initial_coordination_scope_prefix,
)
from vitessce import ViewType as vt

sdata = spatialdata.datasets.blobs()

spatialdata_filepath = os.path.join("data", "blobs.spatialdata.zarr")

sdata.write(spatialdata_filepath)

sdata.table.uns

vc = VitessceConfig(
    schema_version="1.0.16",
    name='Visium SpatialData Demo',
)
# Add data to the configuration:
wrapper = SpatialDataWrapper(
    sdata_path=spatialdata_filepath,
    # The following paths are relative to the root of the SpatialData zarr store on-disk.
    image_path="images/blobs_image",
    table_path="tables/table_transcriptomics",
    obs_feature_matrix_path="tables/table/X",
    labels_path="labels/blobs_labels",
    region="blobs_labels",
    coordinate_system="global",
    coordination_values={
        # The following tells Vitessce to consider each observation as a "blobs"
        "obsType": "blobs",
    }
)
dataset = vc.add_dataset(name='blobs').add_object(wrapper)

# Add views (visualizations) to the configuration:
spatial = vc.add_view("spatialBeta", dataset=dataset)
feature_list = vc.add_view(vt.FEATURE_LIST, dataset=dataset)
layer_controller = vc.add_view("layerControllerBeta", dataset=dataset)

obs_sets = vc.add_view(vt.OBS_SETS, dataset=dataset)
vc.link_views([spatial, layer_controller, feature_list, obs_sets], ['obsType'], [wrapper.obs_type_label])

# Layout the views
vc.layout(spatial | (feature_list / layer_controller ));

vw = vc.widget()
vw

This gives me

Screenshot 2025-01-09 at 08 51 47

If I select 'channel_0_sum', I would expect this would color the blobs given the "expression" found.

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

No branches or pull requests

1 participant