Vitessce integration

For more comprehensive integration tests, see: https://github.com/laminlabs/lamin-spatial

!lamin login testuser1
!lamin init --storage "s3://lamindb-ci/test-vitessce"
✅ logged in with email testuser1@lamin.ai (uid: DzTjkKse)
💡 go to: https://lamin.ai/testuser1/test-vitessce
❗ updating & unlocking cloud SQLite 's3://lamindb-ci/test-vitessce/d8e685232e9c545a89b3f5b869dc5a16.lndb' of instance 'testuser1/test-vitessce'
💡 connected lamindb: testuser1/test-vitessce
❗ locked instance (to unlock and push changes to the cloud SQLite file, call: lamin close)
import lamindb as ln
💡 connected lamindb: testuser1/test-vitessce
pbmc68k = ln.core.datasets.anndata_pbmc68k_reduced()
pbmc68k = pbmc68k[:100, :200].copy()
zarr_filepath = "my_test.zarr"
pbmc68k.write_zarr(zarr_filepath)
zarr_artifact = ln.Artifact(zarr_filepath, description="Test dataset")
zarr_artifact.save()
❗ no run & transform get linked, consider calling ln.track()
Artifact(uid='2PJXQBOox34O5C3AimAe', description='Test dataset', suffix='.zarr', accessor='AnnData', size=185899, hash='LjIw9T99EBlrxvFNjwyauQ', hash_type='md5-d', n_objects=128, visibility=1, key_is_virtual=True, created_by_id=1, storage_id=1, updated_at='2024-05-25 15:35:36 UTC')
from vitessce import (
    VitessceConfig,
    Component as cm,
    AnnDataWrapper,
)
vc = VitessceConfig(
    schema_version="1.0.15",
    name="Test dataset",
    description="Test description",
)
dataset = vc.add_dataset(name="test1").add_object(
    AnnDataWrapper(adata_url=zarr_artifact.path.to_url()),
)
obs_sets = vc.add_view(cm.OBS_SETS, dataset=dataset)
obs_sets_sizes = vc.add_view(cm.OBS_SET_SIZES, dataset=dataset)
scatterplot = vc.add_view(cm.SCATTERPLOT, dataset=dataset, mapping="UMAP")
heatmap = vc.add_view(cm.HEATMAP, dataset=dataset)
genes = vc.add_view(cm.FEATURE_LIST, dataset=dataset)
vc.layout(((scatterplot | obs_sets) / heatmap) | (obs_sets_sizes / genes))

# inspect the config
vc.to_dict()
/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/vitessce/__init__.py:42: UserWarning: Extra installs are necessary to use widgets: No module named 'anywidget'
  warn(f'Extra installs are necessary to use widgets: {e}')
/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/vitessce/__init__.py:66: UserWarning: Extra installs are necessary to use exports: No module named 'starlette'
  warn(f'Extra installs are necessary to use exports: {e}')
{'version': '1.0.15',
 'name': 'Test dataset',
 'description': 'Test description',
 'datasets': [{'uid': 'A', 'name': 'test1', 'files': []}],
 'coordinationSpace': {'dataset': {'A': 'A'}, 'embeddingType': {'A': 'UMAP'}},
 'layout': [{'component': 'obsSets',
   'coordinationScopes': {'dataset': 'A'},
   'x': 3.0,
   'y': 0.0,
   'w': 3.0,
   'h': 6.0},
  {'component': 'obsSetSizes',
   'coordinationScopes': {'dataset': 'A'},
   'x': 6.0,
   'y': 0.0,
   'w': 6.0,
   'h': 6.0},
  {'component': 'scatterplot',
   'coordinationScopes': {'dataset': 'A', 'embeddingType': 'A'},
   'x': 0.0,
   'y': 0.0,
   'w': 3.0,
   'h': 6.0},
  {'component': 'heatmap',
   'coordinationScopes': {'dataset': 'A'},
   'x': 0.0,
   'y': 6.0,
   'w': 6.0,
   'h': 6.0},
  {'component': 'featureList',
   'coordinationScopes': {'dataset': 'A'},
   'x': 6.0,
   'y': 6.0,
   'w': 6.0,
   'h': 6.0}],
 'initStrategy': 'auto'}
from lamindb.integrations import save_vitessce_config
vc_artifact = save_vitessce_config(vc, description="View Habib17 in Vitessce")
💡 go to: https://lamin.ai/testuser1/test-vitessce/artifact/5n8OOKK1a3CLyCxuyzf0
zarr_artifact.delete(permanent=True)
vc_artifact.delete(permanent=True)
ln.setup.delete("test-vitessce", force=True)
💡 deleted storage record on hub 62c8d91900dd5de9a05da1141a7659a8
💡 deleted instance record on hub d8e685232e9c545a89b3f5b869dc5a16