|
| 1 | +<p align="center"> |
| 2 | + <img src="cellucid-logo.svg" alt="Cellucid logo" width="180"> |
| 3 | +</p> |
| 4 | + |
| 5 | +# cellucid (Python) |
| 6 | + |
| 7 | +Python utilities for exporting AnnData/numpy payloads into the manifest + binary format consumed by the Cellucid WebGL viewer. Everything here is independent of the website; generate data wherever you like, then copy the resulting files into the viewer’s `assets/exports/` directory when you host the site. |
| 8 | + |
| 9 | +## Layout (repo: theislab/cellucid-data) |
| 10 | +- `src/cellucid/prepare_data.py`: `export_data_for_web` writes points/obs/var/connectivity binaries into an `exports/` directory (configurable). |
| 11 | +- `src/cellucid/anndata_variations.py`: UMAP sweep helper for experimentation (uses Scanpy). |
| 12 | +- `src/cellucid/repo_to_text.py`: utility to dump repository contents to a single text file. |
| 13 | +- `notebooks/`: exploratory notebook that demonstrates exporting viewer assets. |
| 14 | +- `data/`: example/raw inputs (h5ad, pickles) and experiment outputs live here; this folder stays untracked by default. |
| 15 | + |
| 16 | +## Installation |
| 17 | +Requires Python 3.10+. |
| 18 | + |
| 19 | +From the repo root: |
| 20 | + |
| 21 | +```bash |
| 22 | +pip install -e python |
| 23 | +# or with optional extras |
| 24 | +pip install -e python[analysis,docs] |
| 25 | +``` |
| 26 | + |
| 27 | +The package name is `cellucid` and imports under `cellucid`. |
| 28 | + |
| 29 | +## Usage |
| 30 | +```python |
| 31 | +import scanpy as sc |
| 32 | +from cellucid.prepare_data import export_data_for_web |
| 33 | + |
| 34 | +adata = sc.read_h5ad("path/to/adata.h5ad") |
| 35 | +export_data_for_web( |
| 36 | + X_umap=adata.obsm["X_umap"], |
| 37 | + latent_space=adata.X, |
| 38 | + obs=adata.obs, |
| 39 | + var=adata.var, |
| 40 | + gene_expression=adata.X, |
| 41 | + connectivities=adata.obsp.get("connectivities"), |
| 42 | + out_dir="exports", # default; change as needed |
| 43 | + var_quantization=8, |
| 44 | + obs_continuous_quantization=8, |
| 45 | + compression=6, |
| 46 | +) |
| 47 | +``` |
| 48 | + |
| 49 | +The exporter defaults to `exports/` under your current working directory. After generation, copy or sync that folder into the website’s `assets/exports/` directory so the viewer can load the files. |
| 50 | + |
| 51 | +To run the UMAP sweep helper: |
| 52 | + |
| 53 | +```bash |
| 54 | +python -m cellucid.anndata_variations |
| 55 | +``` |
| 56 | + |
| 57 | +Ensure `python/data/raw` contains the expected h5ad/pickle files or override the module constants before calling. Paths in the notebook and sweep helper assume the `data/` directory inside this `python/` project; point them to your own locations as needed. |
| 58 | + |
| 59 | +## Companion web viewer (theislab/cellucid) |
| 60 | +The static viewer lives in a separate repository (`theislab/cellucid`). After running `export_data_for_web`, copy or sync the resulting `exports/` directory into that repo’s `assets/exports/` folder before hosting. The manifest/binary schema is shared; no build step is required on the web side. |
| 61 | + |
| 62 | +## Documentation |
| 63 | +- Build locally: `pip install -e python[docs] && sphinx-build -b html docs docs/_build/html` |
| 64 | +- Read the Docs: `python/.readthedocs.yaml` targets `docs/conf.py` with the `docs` extra. |
| 65 | + |
| 66 | +## Publishing |
| 67 | +Install packaging tools if needed: `pip install build twine` |
| 68 | + |
| 69 | +1. From `python/`, bump the version in `pyproject.toml`. |
| 70 | +2. Build: `python -m build` |
| 71 | +3. Upload to PyPI (or TestPyPI) with `twine upload dist/*`. |
| 72 | + |
| 73 | +Update the `license`, `authors`, and `Repository` URL in `pyproject.toml` before publishing if needed. |
0 commit comments