vitessce-python
vitessce-python copied to clipboard
vitessce spatialdata
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
If I select 'channel_0_sum', I would expect this would color the blobs given the "expression" found.