Skip to content

Commit 171d736

Browse files
authored
Upgrade JS package version. Update SpatialDataWrapper class (#460)
* Update SpatialDataWrapper. Bump js version * Update spatialdata notebooks * Lint * Bump js version
1 parent 037a60f commit 171d736

11 files changed

+66
-72
lines changed

docs/notebooks/spatial_data.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"outputs": [],
8787
"source": [
8888
"vc = VitessceConfig(\n",
89-
" schema_version=\"1.0.16\",\n",
89+
" schema_version=\"1.0.18\",\n",
9090
" name='Visium SpatialData Demo (visium_associated_xenium_io)',\n",
9191
")\n",
9292
"# Add data to the configuration:\n",

docs/notebooks/spatial_data_blobs.ipynb

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"metadata": {},
3030
"outputs": [],
3131
"source": [
32-
"import spatialdata"
32+
"import spatialdata\n",
33+
"from os.path import join"
3334
]
3435
},
3536
{
@@ -41,15 +42,6 @@
4142
"sdata = spatialdata.datasets.blobs()"
4243
]
4344
},
44-
{
45-
"cell_type": "code",
46-
"execution_count": null,
47-
"metadata": {},
48-
"outputs": [],
49-
"source": [
50-
"from os.path import join"
51-
]
52-
},
5345
{
5446
"cell_type": "code",
5547
"execution_count": null,
@@ -65,16 +57,7 @@
6557
"metadata": {},
6658
"outputs": [],
6759
"source": [
68-
"sdata.write(spatialdata_filepath)"
69-
]
70-
},
71-
{
72-
"cell_type": "code",
73-
"execution_count": null,
74-
"metadata": {},
75-
"outputs": [],
76-
"source": [
77-
"sdata.table.uns"
60+
"sdata.write(spatialdata_filepath, overwrite=True)"
7861
]
7962
},
8063
{
@@ -109,15 +92,15 @@
10992
"outputs": [],
11093
"source": [
11194
"vc = VitessceConfig(\n",
112-
" schema_version=\"1.0.17\",\n",
95+
" schema_version=\"1.0.18\",\n",
11396
" name='Visium SpatialData Demo (blobs)',\n",
11497
")\n",
11598
"# Add data to the configuration:\n",
11699
"wrapper = SpatialDataWrapper(\n",
117100
" sdata_store=spatialdata_filepath,\n",
118101
" # The following paths are relative to the root of the SpatialData zarr store on-disk.\n",
119102
" image_path=\"images/blobs_image\",\n",
120-
" labels_path=\"labels/blobs_labels\",\n",
103+
" obs_segmentations_path=\"labels/blobs_labels\",\n",
121104
" coordinate_system=\"global\",\n",
122105
" coordination_values={\n",
123106
" \"obsType\": \"blob\",\n",
@@ -185,6 +168,13 @@
185168
"vw = vc.widget()\n",
186169
"vw"
187170
]
171+
},
172+
{
173+
"cell_type": "code",
174+
"execution_count": null,
175+
"metadata": {},
176+
"outputs": [],
177+
"source": []
188178
}
189179
],
190180
"metadata": {

docs/notebooks/spatial_data_kpmp_vis.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"outputs": [],
7272
"source": [
7373
"# Create a VitessceConfig instance.\n",
74-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"SpatialData\")\n",
74+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"SpatialData\")\n",
7575
"\n",
7676
"t_obstype = \"Tubule\"\n",
7777
"a_obstype = \"Artery\"\n",
@@ -93,7 +93,7 @@
9393
" SpatialDataWrapper(\n",
9494
" sdata_url=sdata_url,\n",
9595
" table_path=\"tables/table_tubules\",\n",
96-
" labels_path=\"labels/labels_tubules\",\n",
96+
" obs_segmentations_path=\"labels/labels_tubules\",\n",
9797
" obs_feature_matrix_path=\"tables/table_tubules/X\",\n",
9898
" coordinate_system=\"global\",\n",
9999
" coordination_values={\n",
@@ -106,7 +106,7 @@
106106
").add_object(\n",
107107
" SpatialDataWrapper(\n",
108108
" sdata_url=sdata_url,\n",
109-
" labels_path=\"labels/labels_arteries_arterioles\",\n",
109+
" obs_segmentations_path=\"labels/labels_arteries_arterioles\",\n",
110110
" coordinate_system=\"global\",\n",
111111
" coordination_values={\n",
112112
" \"fileUid\": \"labels_arteries_arterioles\",\n",
@@ -119,7 +119,7 @@
119119
" SpatialDataWrapper(\n",
120120
" sdata_url=sdata_url,\n",
121121
" table_path=\"tables/table_cortical_interstitia\",\n",
122-
" labels_path=\"labels/labels_cortical_interstitia\",\n",
122+
" obs_segmentations_path=\"labels/labels_cortical_interstitia\",\n",
123123
" obs_feature_matrix_path=\"tables/table_cortical_interstitia/X\",\n",
124124
" coordinate_system=\"global\",\n",
125125
" coordination_values={\n",
@@ -133,7 +133,7 @@
133133
" SpatialDataWrapper(\n",
134134
" sdata_url=sdata_url,\n",
135135
" table_path=\"tables/table_globally_sclerotic_glomeruli\",\n",
136-
" labels_path=\"labels/labels_globally_sclerotic_glomeruli\",\n",
136+
" obs_segmentations_path=\"labels/labels_globally_sclerotic_glomeruli\",\n",
137137
" obs_feature_matrix_path=\"tables/table_globally_sclerotic_glomeruli/X\",\n",
138138
" coordinate_system=\"global\",\n",
139139
" coordination_values={\n",
@@ -147,7 +147,7 @@
147147
" SpatialDataWrapper(\n",
148148
" sdata_url=sdata_url,\n",
149149
" table_path=\"tables/table_non_globally_sclerotic_glomeruli\",\n",
150-
" labels_path=\"labels/labels_non_globally_sclerotic_glomeruli\",\n",
150+
" obs_segmentations_path=\"labels/labels_non_globally_sclerotic_glomeruli\",\n",
151151
" obs_feature_matrix_path=\"tables/table_non_globally_sclerotic_glomeruli/X\",\n",
152152
" coordinate_system=\"global\",\n",
153153
" coordination_values={\n",
@@ -161,7 +161,7 @@
161161
" SpatialDataWrapper(\n",
162162
" sdata_url=sdata_url,\n",
163163
" table_path=\"tables/table_interstitialfibrosis_and_tubular_atrophy\",\n",
164-
" labels_path=\"labels/labels_interstitialfibrosis_and_tubular_atrophy\",\n",
164+
" obs_segmentations_path=\"labels/labels_interstitialfibrosis_and_tubular_atrophy\",\n",
165165
" coordinate_system=\"global\",\n",
166166
" coordination_values={\n",
167167
" \"fileUid\": \"labels_interstitialfibrosis_and_tubular_atrophy\",\n",
@@ -174,7 +174,7 @@
174174
" SpatialDataWrapper(\n",
175175
" sdata_url=sdata_url,\n",
176176
" table_path=\"tables/table_peritubular_capillaries\",\n",
177-
" labels_path=\"labels/labels_peritubular_capillaries\",\n",
177+
" obs_segmentations_path=\"labels/labels_peritubular_capillaries\",\n",
178178
" obs_feature_matrix_path=\"tables/table_peritubular_capillaries/X\",\n",
179179
" obs_set_paths=[\n",
180180
" \"tables/table_peritubular_capillaries/obs/cortex_ifta_set\",\n",

docs/notebooks/spatial_data_merfish.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"outputs": [],
6565
"source": [
6666
"vc = VitessceConfig(\n",
67-
" schema_version=\"1.0.17\",\n",
67+
" schema_version=\"1.0.18\",\n",
6868
" name='SpatialData with MERFISH data',\n",
6969
")\n",
7070
"# Add data to the configuration:\n",
@@ -80,7 +80,7 @@
8080
")).add_object(SpatialDataWrapper(\n",
8181
" sdata_url=sdata_url,\n",
8282
" # The following paths are relative to the root of the SpatialData zarr store on-disk.\n",
83-
" labels_path=\"labels/dapi_labels\",\n",
83+
" obs_segmentations_path=\"labels/dapi_labels\",\n",
8484
" coordinate_system=\"global\",\n",
8585
" coordination_values={\n",
8686
" \"obsType\": \"nucleus\",\n",
@@ -89,7 +89,7 @@
8989
")).add_object(SpatialDataWrapper(\n",
9090
" sdata_url=sdata_url,\n",
9191
" # The following paths are relative to the root of the SpatialData zarr store on-disk.\n",
92-
" labels_path=\"labels/membrane_labels\",\n",
92+
" obs_segmentations_path=\"labels/membrane_labels\",\n",
9393
" coordinate_system=\"global\",\n",
9494
" coordination_values={\n",
9595
" \"obsType\": \"cell\",\n",

docs/notebooks/spatial_data_merfish_2.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"outputs": [],
8787
"source": [
8888
"vc = VitessceConfig(\n",
89-
" schema_version=\"1.0.17\",\n",
89+
" schema_version=\"1.0.18\",\n",
9090
" name='MERFISH SpatialData Demo',\n",
9191
")\n",
9292
"# Add data to the configuration:\n",

docs/notebooks/spatial_data_mouseliver.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,15 @@
248248
"outputs": [],
249249
"source": [
250250
"# Create a VitessceConfig instance.\n",
251-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"SpatialData Demo\")\n",
251+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"SpatialData Demo\")\n",
252252
"\n",
253253
"# Instantiate the wrapper class, specifying data fields of interest.\n",
254254
"wrapper = SpatialDataWrapper(\n",
255255
" sdata_path=spatialdata_filepath,\n",
256256
" # The following paths are relative to the root of the SpatialData Zarr store on-disk.\n",
257257
" table_path=\"tables/table\",\n",
258258
" image_path=\"images/raw_image\",\n",
259-
" labels_path=\"labels/segmentation_mask\",\n",
259+
" obs_segmentations_path=\"labels/segmentation_mask\",\n",
260260
" obs_feature_matrix_path=\"tables/table/X\",\n",
261261
" obs_set_paths=[\"tables/table/obs/annotation\"],\n",
262262
" obs_set_names=[\"Annotation\"],\n",
@@ -434,7 +434,7 @@
434434
"metadata": {},
435435
"outputs": [],
436436
"source": [
437-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"AnnData (zarr)\")\n",
437+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"AnnData (zarr)\")\n",
438438
"# Add data.\n",
439439
"wrapper = AnnDataWrapper(\n",
440440
" adata_path=adata_zarr_filepath,\n",
@@ -481,7 +481,7 @@
481481
"metadata": {},
482482
"outputs": [],
483483
"source": [
484-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"AnnData (h5ad)\")\n",
484+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"AnnData (h5ad)\")\n",
485485
"# Add data.\n",
486486
"wrapper = AnnDataWrapper(\n",
487487
" adata_path=adata_h5ad_filepath,\n",
@@ -613,7 +613,7 @@
613613
"metadata": {},
614614
"outputs": [],
615615
"source": [
616-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"Image (ome-zarr)\")\n",
616+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"Image (ome-zarr)\")\n",
617617
"\n",
618618
"# Add data.\n",
619619
"img_wrapper = ImageOmeZarrWrapper(\n",
@@ -696,7 +696,7 @@
696696
"metadata": {},
697697
"outputs": [],
698698
"source": [
699-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"Image and segmentations (ome-tiff)\")\n",
699+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"Image and segmentations (ome-tiff)\")\n",
700700
"# Add data.\n",
701701
"wrapper = ImageOmeTiffWrapper(\n",
702702
" img_path=ome_tiff_filepath,\n",

docs/notebooks/spatial_data_mouseliver_remote.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,15 @@
212212
"outputs": [],
213213
"source": [
214214
"# Create a VitessceConfig instance.\n",
215-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"SpatialData Demo\")\n",
215+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"SpatialData Demo\")\n",
216216
"\n",
217217
"# Instantiate the wrapper class, specifying data fields of interest.\n",
218218
"wrapper = SpatialDataWrapper(\n",
219219
" sdata_url=spatialdata_filepath,\n",
220220
" # The following paths are relative to the root of the SpatialData Zarr store on-disk.\n",
221221
" table_path=\"tables/table\",\n",
222222
" image_path=\"images/raw_image\",\n",
223-
" labels_path=\"labels/segmentation_mask\",\n",
223+
" obs_segmentations_path=\"labels/segmentation_mask\",\n",
224224
" obs_feature_matrix_path=\"tables/table/X\",\n",
225225
" obs_set_paths=[\"tables/table/obs/annotation\"],\n",
226226
" obs_set_names=[\"Annotation\"],\n",
@@ -349,7 +349,7 @@
349349
"metadata": {},
350350
"outputs": [],
351351
"source": [
352-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"AnnData (zarr)\")\n",
352+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"AnnData (zarr)\")\n",
353353
"# Add data.\n",
354354
"wrapper = AnnDataWrapper(\n",
355355
" adata_url=adata_zarr_filepath,\n",
@@ -396,7 +396,7 @@
396396
"metadata": {},
397397
"outputs": [],
398398
"source": [
399-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"AnnData (h5ad)\")\n",
399+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"AnnData (h5ad)\")\n",
400400
"# Add data.\n",
401401
"wrapper = AnnDataWrapper(\n",
402402
" adata_url=adata_h5ad_filepath,\n",
@@ -451,7 +451,7 @@
451451
"metadata": {},
452452
"outputs": [],
453453
"source": [
454-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"Image (ome-zarr)\")\n",
454+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"Image (ome-zarr)\")\n",
455455
"\n",
456456
"# Add data.\n",
457457
"img_wrapper = ImageOmeZarrWrapper(\n",
@@ -534,7 +534,7 @@
534534
"metadata": {},
535535
"outputs": [],
536536
"source": [
537-
"vc = VitessceConfig(schema_version=\"1.0.17\", name=\"Image and segmentations (ome-tiff)\")\n",
537+
"vc = VitessceConfig(schema_version=\"1.0.18\", name=\"Image and segmentations (ome-tiff)\")\n",
538538
"# Add data.\n",
539539
"wrapper = ImageOmeTiffWrapper(\n",
540540
" img_url=ome_tiff_filepath,\n",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "vitessce"
7-
version = "3.6.6"
7+
version = "3.6.7"
88
authors = [
99
{ name="Mark Keller", email="[email protected]" },
1010
]

src/vitessce/file_def_utils.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from functools import partial
44
from typing import Optional
55

6-
import numpy as np
7-
86

97
def gen_obs_embedding_schema(options: dict, paths: Optional[list[str]] = None, names: Optional[list[str]] = None, dims: Optional[list[list[int]]] = None):
108
if paths is not None:
@@ -127,29 +125,25 @@ def gen_path_schema(key: str, path: Optional[str], options: dict):
127125
gen_feature_labels_schema = partial(gen_path_schema, "featureLabels")
128126

129127

130-
def gen_sdata_image_schema(options, path: str, coordinate_system: Optional[str] = None, affine_transformation: Optional[np.ndarray] = None) -> dict:
128+
def gen_sdata_image_schema(options, path: str, coordinate_system: Optional[str] = None) -> dict:
131129
if path is not None:
132130
options["image"] = {
133131
"path": path
134132
}
135-
if affine_transformation is not None:
136-
options["image"]['coordinateTransformations'] = affine_transformation
137133
if coordinate_system is not None:
138134
options["image"]['coordinateSystem'] = coordinate_system
139135
return options
140136

141137

142-
def gen_sdata_labels_schema(options, path: str, table_path: str = "tables/table", coordinate_system: Optional[str] = None, affine_transformation: Optional[np.ndarray] = None) -> dict:
138+
def gen_sdata_obs_segmentations_schema(options, path: str, table_path: str = "tables/table", coordinate_system: Optional[str] = None) -> dict:
143139
if path is not None:
144-
options["labels"] = {
140+
options["obsSegmentations"] = {
145141
"path": path
146142
}
147143
if table_path is not None:
148-
options["labels"]['tablePath'] = table_path
149-
if affine_transformation is not None:
150-
options["labels"]['coordinateTransformations'] = affine_transformation
144+
options["obsSegmentations"]['tablePath'] = table_path
151145
if coordinate_system is not None:
152-
options["labels"]['coordinateSystem'] = coordinate_system
146+
options["obsSegmentations"]['coordinateSystem'] = coordinate_system
153147
return options
154148

155149

src/vitessce/widget.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ def launch_vitessce_io(config, theme='light', port=None, base_url=None, host_nam
131131
port, DEFAULT_PORT, proxy=proxy, base_url=base_url, host_name=host_name)
132132
config_dict = config.to_dict(base_url=base_url)
133133
routes = config.get_routes()
134+
135+
stores = config.get_stores(base_url=base_url)
136+
if len(stores) > 0:
137+
raise ValueError('One or more files in this configuration have been provided via Zarr store, which can only be loaded via the widget. Either use VitessceConfig.widget or VitessceConfig.display (instead of .web_app), or provide the files via _path or _url (rather than _store) parameters.')
138+
134139
serve_routes(config, routes, use_port)
135140
vitessce_url = f"http://vitessce.io/#?theme={theme}&url=data:," + quote_plus(
136141
json.dumps(config_dict))
@@ -626,7 +631,7 @@ class VitessceWidget(anywidget.AnyWidget):
626631

627632
next_port = DEFAULT_PORT
628633

629-
js_package_version = Unicode('3.6.7').tag(sync=True)
634+
js_package_version = Unicode('3.6.9').tag(sync=True)
630635
js_dev_mode = Bool(False).tag(sync=True)
631636
custom_js_url = Unicode('').tag(sync=True)
632637
plugin_esm = List(trait=Unicode(''), default_value=[]).tag(sync=True)
@@ -639,7 +644,7 @@ class VitessceWidget(anywidget.AnyWidget):
639644

640645
store_urls = List(trait=Unicode(''), default_value=[]).tag(sync=True)
641646

642-
def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.6.7', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, prefer_local=True, invoke_timeout=300000, invoke_batched=True, page_mode=False, page_esm=None, prevent_scroll=True):
647+
def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.6.9', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, prefer_local=True, invoke_timeout=300000, invoke_batched=True, page_mode=False, page_esm=None, prevent_scroll=True):
643648
"""
644649
Construct a new Vitessce widget.
645650
@@ -775,7 +780,7 @@ def _plugin_command(self, params, buffers):
775780
# Launch Vitessce using plain HTML representation (no ipywidgets)
776781

777782

778-
def ipython_display(config, height=600, theme='auto', base_url=None, host_name=None, uid=None, port=None, proxy=False, js_package_version='3.6.7', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, page_mode=False, page_esm=None):
783+
def ipython_display(config, height=600, theme='auto', base_url=None, host_name=None, uid=None, port=None, proxy=False, js_package_version='3.6.9', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, page_mode=False, page_esm=None):
779784
from IPython.display import display, HTML
780785
uid_str = "vitessce" + get_uid_str(uid)
781786

0 commit comments

Comments
 (0)