Skip to content

Commit dad3dea

Browse files
committed
Merge
2 parents 85d634f + b84155a commit dad3dea

File tree

8 files changed

+86
-19
lines changed

8 files changed

+86
-19
lines changed

docs/notebooks/widget_neuroglancer.ipynb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,6 @@
176176
"vc.layout(hconcat(neuroglancerView, spatialThreeView, vconcat(lcView, obsSets, scatterView)));"
177177
]
178178
},
179-
{
180-
"cell_type": "code",
181-
"execution_count": null,
182-
"metadata": {},
183-
"outputs": [],
184-
"source": [
185-
"vc.to_dict()"
186-
]
187-
},
188179
{
189180
"cell_type": "markdown",
190181
"metadata": {},
@@ -198,7 +189,7 @@
198189
"metadata": {},
199190
"outputs": [],
200191
"source": [
201-
"vw = vc.widget(js_dev_mode=True)\n",
192+
"vw = vc.widget(custom_js_url=\"http://localhost:3003/packages/main/prod/dist/index.min.js\")\n",
202193
"vw"
203194
]
204195
},
@@ -209,6 +200,13 @@
209200
"outputs": [],
210201
"source": []
211202
},
203+
{
204+
"cell_type": "code",
205+
"execution_count": null,
206+
"metadata": {},
207+
"outputs": [],
208+
"source": []
209+
},
212210
{
213211
"cell_type": "code",
214212
"execution_count": null,

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.5.11"
7+
version = "3.6.1"
88
authors = [
99
{ name="Mark Keller", email="[email protected]" },
1010
]

src/vitessce/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ class FileType(DocEnum):
164164
ANNDATA_ZARR = "anndata.zarr", "Joint file type for AnnData objects"
165165
SPATIALDATA_ZARR = "spatialdata.zarr", "Joint file type for SpatialData objects"
166166
ANNDATA_H5AD = "anndata.h5ad", "Joint file type for AnnData objects"
167+
ANNDATA_ZARR_ZIP = "anndata.zarr.zip", "Joint file type for AnnData object in a Zarr directory store that has been zipped"
167168
OBS_EMBEDDING_CSV = 'obsEmbedding.csv', "File type for obsEmbedding values stored in a CSV file"
168169
OBS_LOCATIONS_CSV = 'obsLocations.csv', "File type for obsLocations values stored in a CSV file"
169170
OBS_LABELS_CSV = 'obsLabels.csv', "File type for obsLabels values stored in a CSV file"

src/vitessce/widget.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ class VitessceWidget(anywidget.AnyWidget):
602602

603603
next_port = DEFAULT_PORT
604604

605-
js_package_version = Unicode('3.6.1').tag(sync=True)
605+
js_package_version = Unicode('3.6.2').tag(sync=True)
606606
js_dev_mode = Bool(False).tag(sync=True)
607607
custom_js_url = Unicode('').tag(sync=True)
608608
plugin_esm = List(trait=Unicode(''), default_value=[]).tag(sync=True)
@@ -614,7 +614,7 @@ class VitessceWidget(anywidget.AnyWidget):
614614

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

617-
def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.6.1', 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):
617+
def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.6.2', 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):
618618
"""
619619
Construct a new Vitessce widget.
620620
@@ -749,7 +749,7 @@ def _plugin_command(self, params, buffers):
749749
# Launch Vitessce using plain HTML representation (no ipywidgets)
750750

751751

752-
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.1', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, page_mode=False, page_esm=None):
752+
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.2', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, page_mode=False, page_esm=None):
753753
from IPython.display import display, HTML
754754
uid_str = "vitessce" + get_uid_str(uid)
755755

src/vitessce/wrappers.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ def raise_error_if_more_than_one(inputs):
11921192

11931193

11941194
class AnnDataWrapper(AbstractWrapper):
1195-
def __init__(self, adata_path=None, adata_url=None, adata_store=None, adata_artifact=None, ref_path=None, ref_url=None, ref_artifact=None, obs_feature_matrix_path=None, feature_filter_path=None, initial_feature_filter_path=None, obs_set_paths=None, obs_set_names=None, obs_locations_path=None, obs_segmentations_path=None, obs_embedding_paths=None, obs_embedding_names=None, obs_embedding_dims=None, obs_spots_path=None, obs_points_path=None, feature_labels_path=None, obs_labels_path=None, convert_to_dense=True, coordination_values=None, obs_labels_paths=None, obs_labels_names=None, **kwargs):
1195+
def __init__(self, adata_path=None, adata_url=None, adata_store=None, adata_artifact=None, ref_path=None, ref_url=None, ref_artifact=None, obs_feature_matrix_path=None, feature_filter_path=None, initial_feature_filter_path=None, obs_set_paths=None, obs_set_names=None, obs_locations_path=None, obs_segmentations_path=None, obs_embedding_paths=None, obs_embedding_names=None, obs_embedding_dims=None, obs_spots_path=None, obs_points_path=None, feature_labels_path=None, obs_labels_path=None, convert_to_dense=True, coordination_values=None, obs_labels_paths=None, obs_labels_names=None, is_zip=None, **kwargs):
11961196
"""
11971197
Wrap an AnnData object by creating an instance of the ``AnnDataWrapper`` class.
11981198
@@ -1220,6 +1220,7 @@ def __init__(self, adata_path=None, adata_url=None, adata_store=None, adata_arti
12201220
:param list[str] obs_labels_names: The optional display names of columns containing observation labels (e.g., alternate cell IDs), instead of the default index in `obs` of the AnnData store.
12211221
:param bool convert_to_dense: Whether or not to convert `X` to dense the zarr store (dense is faster but takes more disk space).
12221222
:param coordination_values: Coordination values for the file definition.
1223+
:param is_zip: Boolean indicating whether the Zarr store is in a zipped format.
12231224
:type coordination_values: dict or None
12241225
:param \\*\\*kwargs: Keyword arguments inherited from :class:`~vitessce.wrappers.AbstractWrapper`
12251226
"""
@@ -1229,6 +1230,7 @@ def __init__(self, adata_path=None, adata_url=None, adata_store=None, adata_arti
12291230
self._adata_url = adata_url
12301231
self._adata_store = adata_store
12311232
self._adata_artifact = adata_artifact
1233+
self.is_zip = is_zip
12321234

12331235
# For reference spec JSON with .h5ad files
12341236
self._ref_path = ref_path
@@ -1250,11 +1252,14 @@ def __init__(self, adata_path=None, adata_url=None, adata_store=None, adata_arti
12501252
self.is_remote = False
12511253
self.is_store = False
12521254
self.zarr_folder = 'anndata.zarr'
1255+
if is_zip is None and '.zip' in str(adata_path):
1256+
self.is_zip = True
12531257
elif adata_url is not None or adata_artifact is not None:
12541258
self.is_remote = True
12551259
self.is_store = False
12561260
self.zarr_folder = None
1257-
1261+
if is_zip is None and '.zip' in str(adata_url):
1262+
self.is_zip = True
12581263
# Store artifacts on AbstractWrapper.artifacts for downstream access,
12591264
# e.g. in lamindb.save_vitessce_config
12601265
if adata_artifact is not None:
@@ -1356,9 +1361,8 @@ def get_anndata_zarr(base_url):
13561361
if len(options.keys()) > 0:
13571362
if self.is_h5ad:
13581363
options["refSpecUrl"] = self.get_ref_url(base_url, dataset_uid, obj_i)
1359-
13601364
obj_file_def = {
1361-
"fileType": ft.ANNDATA_ZARR.value if not self.is_h5ad else ft.ANNDATA_H5AD.value,
1365+
"fileType": ft.ANNDATA_ZARR_ZIP.value if self.is_zip else ft.ANNDATA_H5AD.value if self.is_h5ad else ft.ANNDATA_ZARR.value,
13621366
"url": self.get_zarr_url(base_url, dataset_uid, obj_i) if not self.is_h5ad else self.get_h5ad_url(base_url, dataset_uid, obj_i),
13631367
"options": options
13641368
}

tests/test_config.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,52 @@ def test_config_add_dataset():
7676
}
7777

7878

79+
def test_config_add_anndata_zip_url():
80+
vc = VitessceConfig(schema_version="1.0.15")
81+
vc.add_dataset(name='My Dataset').add_object(
82+
AnnDataWrapper(
83+
adata_url="http://example.com/adata.zarr.zip",
84+
obs_set_paths=["obs/louvain"],
85+
is_zip=True
86+
)
87+
)
88+
89+
vc_dict = vc.to_dict()
90+
91+
assert vc_dict == {
92+
"version": "1.0.15",
93+
"name": "",
94+
"description": "",
95+
"datasets": [
96+
{
97+
'uid': 'A',
98+
'name': 'My Dataset',
99+
'files': [
100+
{
101+
"fileType": "anndata.zarr.zip",
102+
"url": "http://example.com/adata.zarr.zip",
103+
"options": {
104+
"obsSets": [
105+
{
106+
"name": "louvain",
107+
"path": "obs/louvain",
108+
}
109+
]
110+
}
111+
}
112+
]
113+
}
114+
],
115+
'coordinationSpace': {
116+
'dataset': {
117+
'A': 'A'
118+
},
119+
},
120+
"layout": [],
121+
"initStrategy": "auto"
122+
}
123+
124+
79125
def test_config_add_anndata_url():
80126
vc = VitessceConfig(schema_version="1.0.15")
81127
vc.add_dataset(name='My Dataset').add_object(

tests/test_wrappers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,24 @@ def test_obs_segmentations_ome_zarr(self):
208208
'url': 'http://localhost:8000/A/0/test.ome.zarr'
209209
})
210210

211+
def test_anndata_with_zip(self):
212+
adata_path = data_path / 'test.zarr.zip'
213+
w = AnnDataWrapper(adata_path,
214+
is_zip=True,
215+
obs_set_paths=['obs/CellType'], obs_set_names=['Cell Type'],
216+
obs_labels_names=['Cell Label'], obs_labels_paths=['obs/CellLabel'],
217+
obs_embedding_paths=['obsm/X_umap'], obs_embedding_names=['UMAP'])
218+
w.local_dir_uid = 'anndata.zarr.zip'
219+
220+
file_def_creator = w.make_file_def_creator('A', 0)
221+
file_def = file_def_creator('http://localhost:8000')
222+
self.assertEqual(file_def, {'fileType': 'anndata.zarr.zip', 'url': 'http://localhost:8000/A/0/anndata.zarr.zip',
223+
'options': {
224+
'obsEmbedding': [{'path': 'obsm/X_umap', 'embeddingType': 'UMAP', 'dims': [0, 1]}],
225+
'obsSets': [{'path': 'obs/CellType', 'name': 'Cell Type'}],
226+
'obsLabels': [{'path': 'obs/CellLabel', 'obsLabelsType': 'Cell Label'}]
227+
}})
228+
211229
def test_anndata(self):
212230
adata_path = data_path / 'test.h5ad.zarr'
213231
w = AnnDataWrapper(adata_path,

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)