|
| 1 | +import marimo |
| 2 | + |
| 3 | +__generated_with = "0.13.15" |
| 4 | +app = marimo.App() |
| 5 | + |
| 6 | + |
| 7 | +@app.cell |
| 8 | +def _(): |
| 9 | + import marimo as mo |
| 10 | + return (mo,) |
| 11 | + |
| 12 | + |
| 13 | +@app.cell |
| 14 | +def _(): |
| 15 | + import anywidget |
| 16 | + from vitessce import ( |
| 17 | + VitessceConfig, |
| 18 | + ViewType as vt, |
| 19 | + CoordinationType as ct, |
| 20 | + ImageOmeTiffWrapper, |
| 21 | + ImageOmeZarrWrapper, |
| 22 | + AnnDataWrapper, |
| 23 | + SpatialDataWrapper, |
| 24 | + CoordinationLevel as CL, |
| 25 | + get_initial_coordination_scope_prefix, |
| 26 | + hconcat, |
| 27 | + vconcat, |
| 28 | + ) |
| 29 | + return VitessceConfig, ImageOmeTiffWrapper, get_initial_coordination_scope_prefix |
| 30 | + |
| 31 | + |
| 32 | +@app.cell |
| 33 | +def _(VitessceConfig, ImageOmeTiffWrapper, get_initial_coordination_scope_prefix): |
| 34 | + vc = VitessceConfig( |
| 35 | + schema_version="1.0.17", |
| 36 | + name='My configuration', |
| 37 | + description='Data from https://portal.hubmapconsortium.org/browse/collection/6a6efd0c1a2681dc7d2faab8e4ab0bca' |
| 38 | + ) |
| 39 | + dataset = vc.add_dataset(name='My dataset').add_object( |
| 40 | + ImageOmeTiffWrapper( |
| 41 | + img_url="https://assets.hubmapconsortium.org/f4188a148e4c759092d19369d310883b/ometiff-pyramids/processedMicroscopy/VAN0006-LK-2-85-PAS_images/VAN0006-LK-2-85-PAS_registered.ome.tif" |
| 42 | + ) |
| 43 | + ) |
| 44 | + |
| 45 | + spatial = vc.add_view("spatialBeta", dataset=dataset) |
| 46 | + lc = vc.add_view("layerControllerBeta", dataset=dataset) |
| 47 | + |
| 48 | + vc.link_views_by_dict([spatial, lc], { |
| 49 | + "photometricInterpretation": "RGB" |
| 50 | + }, meta=True, scope_prefix=get_initial_coordination_scope_prefix("A", "image")) |
| 51 | + |
| 52 | + vc.layout(spatial | lc); |
| 53 | + return (vc,) |
| 54 | + |
| 55 | + |
| 56 | +@app.cell |
| 57 | +def _(mo, vc): |
| 58 | + vw = mo.ui.anywidget(vc.widget()) |
| 59 | + vw |
| 60 | + return (vw,) |
| 61 | + |
| 62 | + |
| 63 | +@app.cell(hide_code=True) |
| 64 | +def _(mo): |
| 65 | + mo.md(r"""As you interact with the widget above, watch as the Vitessce configuration below dynamically updates. For instance, as you zoom in the spatial view, check the value of `coordinationSpace.spatialZoom`""") |
| 66 | + return |
| 67 | + |
| 68 | + |
| 69 | +@app.cell |
| 70 | +def _(vw): |
| 71 | + vw.config |
| 72 | + return |
| 73 | + |
| 74 | + |
| 75 | +@app.cell |
| 76 | +def _(vw): |
| 77 | + vw.config["coordinationSpace"]["spatialZoom"] |
| 78 | + return |
| 79 | + |
| 80 | +@app.cell |
| 81 | +def _(vc): |
| 82 | + import json |
| 83 | + print(json.dumps(vc.to_dict(), indent=2)) |
| 84 | + return |
| 85 | + |
| 86 | +@app.cell |
| 87 | +def _(): |
| 88 | + return |
| 89 | + |
| 90 | + |
| 91 | +if __name__ == "__main__": |
| 92 | + app.run() |
0 commit comments