Skip to content

Commit 6ace98a

Browse files
committed
Update notebook
1 parent f88d7ad commit 6ace98a

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

docs/notebooks/spatial_data_kpmp_vis.ipynb

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,18 @@
318318
"spatial = vc.add_view(\"spatialBeta\", dataset=dataset)\n",
319319
"layer_controller = vc.add_view(\"layerControllerBeta\", dataset=dataset)\n",
320320
"# Tubules\n",
321-
"tubules_feature_list = vc.add_view(\"featureList\", dataset=dataset)\n",
321+
"tubules_feature_list = vc.add_view(\"featureList\", dataset=dataset).set_props(title=\"Tubules\")\n",
322322
"tubules_histogram = vc.add_view(\"featureValueHistogram\", dataset=dataset)\n",
323323
"# Peritubular capillaries\n",
324-
"pt_feature_list = vc.add_view(\"featureList\", dataset=dataset)\n",
324+
"pt_feature_list = vc.add_view(\"featureList\", dataset=dataset).set_props(title=\"Peritubular Capillaries\")\n",
325325
"pt_histogram = vc.add_view(\"featureValueHistogram\", dataset=dataset)\n",
326+
"# GSG\n",
327+
"gsg_feature_list = vc.add_view(\"featureList\", dataset=dataset).set_props(title=\"Globally Sclerotic Glomeruli\")\n",
328+
"gsg_histogram = vc.add_view(\"featureValueHistogram\", dataset=dataset)\n",
329+
"\n",
330+
"# NGSG\n",
331+
"ngsg_feature_list = vc.add_view(\"featureList\", dataset=dataset).set_props(title=\"Non-Globally Sclerotic Glomeruli\")\n",
332+
"ngsg_histogram = vc.add_view(\"featureValueHistogram\", dataset=dataset)\n",
326333
"\n",
327334
"\n",
328335
"#obs_sets = vc.add_view(\"obsSets\", dataset=dataset)\n",
@@ -341,6 +348,17 @@
341348
"pt_oce_scope.set_value(\"spatialChannelColor\")\n",
342349
"\n",
343350
"\n",
351+
"[gsg_ot_scope, gsg_fs_scope, gsg_oce_scope, gsg_fvcr_scope] = vc.add_coordination(\"obsType\", \"featureSelection\", \"obsColorEncoding\", \"featureValueColormapRange\")\n",
352+
"gsg_ot_scope.set_value(\"Globally Sclerotic Glomerulus\")\n",
353+
"gsg_oce_scope.set_value(\"spatialChannelColor\")\n",
354+
"gsg_fvcr_scope.set_value([(3077 - 2333) / (29911 - 2333), 1.0])\n",
355+
"\n",
356+
"[ngsg_ot_scope, ngsg_fs_scope, ngsg_oce_scope, ngsg_fvcr_scope] = vc.add_coordination(\"obsType\", \"featureSelection\", \"obsColorEncoding\", \"featureValueColormapRange\")\n",
357+
"ngsg_ot_scope.set_value(\"Non-Globally Sclerotic Glomerulus\")\n",
358+
"ngsg_oce_scope.set_value(\"spatialChannelColor\")\n",
359+
"ngsg_fvcr_scope.set_value([0.0, 1 - (59451 - 29911) / (59451 - 3077)])\n",
360+
"\n",
361+
"\n",
344362
"vc.link_views_by_dict([spatial, layer_controller], {\n",
345363
" \"imageLayer\": CL([{\n",
346364
" \"photometricInterpretation\": \"RGB\",\n",
@@ -402,14 +420,15 @@
402420
" \"fileUid\": \"labels_globally_sclerotic_glomeruli\",\n",
403421
" \"segmentationChannel\": CL([{\n",
404422
" \"spatialTargetC\": 0,\n",
405-
" \"obsType\": \"Globally Sclerotic Glomerulus\",\n",
423+
" \"obsType\": gsg_ot_scope,\n",
406424
" \"featureType\": ft_scope,\n",
407425
" \"featureValueType\": fvt_scope,\n",
426+
" \"featureSelection\": gsg_fs_scope,\n",
408427
" \"spatialChannelVisible\": False,\n",
409428
" \"spatialChannelColor\": [255, 255, 255],\n",
410429
" \"spatialChannelOpacity\": 0.5,\n",
411-
" \"obsColorEncoding\": \"spatialChannelColor\",\n",
412-
" \"featureValueColormapRange\": [0, 1],\n",
430+
" \"obsColorEncoding\": gsg_oce_scope,\n",
431+
" \"featureValueColormapRange\": gsg_fvcr_scope,\n",
413432
" \"featureAggregationStrategy\": \"first\",\n",
414433
" \"obsHighlight\": None,\n",
415434
" }]),\n",
@@ -418,14 +437,15 @@
418437
" \"fileUid\": \"labels_non_globally_sclerotic_glomeruli\",\n",
419438
" \"segmentationChannel\": CL([{\n",
420439
" \"spatialTargetC\": 0,\n",
421-
" \"obsType\": \"Non-Globally Sclerotic Glomerulus\",\n",
440+
" \"obsType\": ngsg_ot_scope,\n",
422441
" \"featureType\": ft_scope,\n",
423442
" \"featureValueType\": fvt_scope,\n",
443+
" \"featureSelection\": ngsg_fs_scope,\n",
424444
" \"spatialChannelVisible\": False,\n",
425445
" \"spatialChannelColor\": [255, 255, 255],\n",
426446
" \"spatialChannelOpacity\": 0.5,\n",
427-
" \"obsColorEncoding\": \"spatialChannelColor\",\n",
428-
" \"featureValueColormapRange\": [0, 1],\n",
447+
" \"obsColorEncoding\": ngsg_oce_scope,\n",
448+
" \"featureValueColormapRange\": ngsg_fvcr_scope,\n",
429449
" \"featureAggregationStrategy\": \"first\",\n",
430450
" \"obsHighlight\": None,\n",
431451
" }]),\n",
@@ -473,9 +493,20 @@
473493
"pt_feature_list.use_coordination(pt_ot_scope, ft_scope, fvt_scope, pt_fs_scope, pt_oce_scope)\n",
474494
"pt_histogram.use_coordination(pt_ot_scope, ft_scope, fvt_scope, pt_fs_scope, pt_oce_scope)\n",
475495
"\n",
496+
"gsg_feature_list.use_coordination(gsg_ot_scope, ft_scope, fvt_scope, gsg_fs_scope, gsg_oce_scope, gsg_fvcr_scope)\n",
497+
"gsg_histogram.use_coordination(gsg_ot_scope, ft_scope, fvt_scope, gsg_fs_scope, gsg_oce_scope, gsg_fvcr_scope)\n",
498+
"\n",
499+
"ngsg_feature_list.use_coordination(ngsg_ot_scope, ft_scope, fvt_scope, ngsg_fs_scope, ngsg_oce_scope, ngsg_fvcr_scope)\n",
500+
"ngsg_histogram.use_coordination(ngsg_ot_scope, ft_scope, fvt_scope, ngsg_fs_scope, ngsg_oce_scope, ngsg_fvcr_scope)\n",
501+
"\n",
476502
"\n",
477503
"# Layout the views in a grid arrangement.\n",
478-
"vc.layout(vconcat(hconcat(spatial, layer_controller, split=[3, 1]), hconcat((tubules_feature_list / tubules_histogram), (pt_feature_list / pt_histogram))));"
504+
"vc.layout(vconcat(hconcat(spatial, layer_controller, split=[3, 1]), hconcat(\n",
505+
" (tubules_feature_list / tubules_histogram),\n",
506+
" (pt_feature_list / pt_histogram),\n",
507+
" (gsg_feature_list / gsg_histogram),\n",
508+
" (ngsg_feature_list / ngsg_histogram)\n",
509+
")));"
479510
]
480511
},
481512
{
@@ -496,7 +527,7 @@
496527
},
497528
"outputs": [],
498529
"source": [
499-
"vw = vc.widget()\n",
530+
"vw = vc.widget(js_package_version=\"3.6.3\")\n",
500531
"vw"
501532
]
502533
},
@@ -505,9 +536,7 @@
505536
"execution_count": null,
506537
"metadata": {},
507538
"outputs": [],
508-
"source": [
509-
"vw.port"
510-
]
539+
"source": []
511540
},
512541
{
513542
"cell_type": "code",

src/vitessce/wrappers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ def auto_view_config(self, vc):
13971397

13981398
class SpatialDataWrapper(AnnDataWrapper):
13991399

1400-
def __init__(self, sdata_path: Optional[str] = None, sdata_url: Optional[str] = None, sdata_store: Optional[Union[str, zarr.storage.StoreLike]] = None, sdata_artifact: Optional[ln.Artifact] = None, image_path: Optional[str] = None, region: Optional[str] = None, coordinate_system: Optional[str] = None, affine_transformation: Optional[np.ndarray] = None, obs_spots_path: Optional[str] = None, labels_path: Optional[str] = None, table_path: str = "tables/table", **kwargs):
1400+
def __init__(self, sdata_path: Optional[str] = None, sdata_url: Optional[str] = None, sdata_store: Optional[Union[str, zarr.storage.StoreLike]] = None, sdata_artifact: Optional[ln.Artifact] = None, image_path: Optional[str] = None, region: Optional[str] = None, coordinate_system: Optional[str] = None, affine_transformation: Optional[np.ndarray] = None, obs_spots_path: Optional[str] = None, labels_path: Optional[str] = None, table_path: str = "tables/table", coordination_values=None, **kwargs):
14011401
"""
14021402
Wrap a SpatialData object.
14031403
@@ -1444,6 +1444,7 @@ def __init__(self, sdata_path: Optional[str] = None, sdata_url: Optional[str] =
14441444
if self._adata_path is not None:
14451445
self.zarr_folder = 'spatialdata.zarr'
14461446
self.obs_type_label = None
1447+
self._coordination_values = coordination_values
14471448
if self._coordination_values is not None and "obsType" in self._coordination_values:
14481449
self.obs_type_label = self._coordination_values["obsType"]
14491450
self._table_path = table_path

0 commit comments

Comments
 (0)