Landscape from a Local Server¶
Celldega's widgets run in the browser and load DegaFiles (the output of
dega.pre.main) over HTTP. To view DegaFiles stored on your own machine, start
a local file server with dega.viz.get_local_server() and point the Landscape's
base_url at it.
import celldega as dega
Serve local DegaFiles¶
get_local_server() starts a background HTTP server (with CORS enabled) rooted
at the notebook's working directory and returns its port. Build base_url from
that port plus the path to your DegaFiles folder, relative to the working
directory:
from pathlib import Path
path_dega_files = Path("data/Xenium_V1_human_Pancreas_FFPE_outs")
port = dega.viz.get_local_server()
base_url = f"http://localhost:{port}/{path_dega_files.as_posix()}"
landscape = dega.viz.Landscape(
technology="Xenium",
base_url=base_url,
height=500,
)
landscape
The server runs for the lifetime of the kernel. Run this in a live Jupyter
session: the static documentation page cannot reach your localhost.
The same view from GitHub¶
Any static host that serves the DegaFiles folder works the same way. Below, the
same Landscape is created from DegaFiles pushed to a GitHub repository, so it
also renders on this page. Only base_url changes.
base_url = (
"https://raw.githubusercontent.com/broadinstitute/"
"celldega_Xenium_human_Pancreas_FFPE/main/"
"Landscape_Xenium_V1_human_Pancreas_FFPE_outs_webp"
)
landscape = dega.viz.Landscape(
technology="Xenium",
base_url=base_url,
height=500,
)
landscape