Skip to content

Commit cff2168

Browse files
committed
Initialization
0 parents  commit cff2168

File tree

16 files changed

+2189
-0
lines changed

16 files changed

+2189
-0
lines changed

.github/workflows/docs-check.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Docs Check
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-docs:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.10"
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
python -m pip install -e .[docs]
25+
26+
- name: Build Sphinx docs
27+
run: sphinx-build -b html docs docs/_build/html

.github/workflows/pypi-publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-publish:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.10"
20+
21+
- name: Install build backend
22+
run: python -m pip install --upgrade pip build
23+
24+
- name: Build distributions
25+
run: python -m build
26+
27+
- name: Publish to PyPI
28+
uses: pypa/gh-action-pypi-publish@release/v1
29+
with:
30+
user: __token__
31+
password: ${{ secrets.PYPI_API_TOKEN }}
32+
packages_dir: dist

.github/workflows/readthedocs.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Read the Docs Trigger
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
tags:
7+
- "v*"
8+
workflow_dispatch:
9+
10+
jobs:
11+
trigger:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Trigger Read the Docs build
18+
uses: readthedocs/actions@v1
19+
with:
20+
token: ${{ secrets.READTHEDOCS_TOKEN }}
21+
project: cellucid

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Bytecode / cache
2+
__pycache__/
3+
*.py[cod]
4+
*.pyo
5+
.pytest_cache/
6+
7+
# Virtual envs
8+
.env
9+
.venv
10+
env/
11+
venv/
12+
13+
# Editors / OS
14+
.DS_Store
15+
.idea/
16+
.vscode/
17+
18+
# Build / dist
19+
build/
20+
dist/
21+
*.egg-info/
22+
htmlcov/
23+
.coverage
24+
coverage.xml
25+
26+
# Logs / dumps
27+
*.log
28+
*.tmp
29+
*.swp
30+
31+
# Local data artifacts
32+
data/**
33+
!data/.gitkeep
34+
!data/raw/.gitkeep
35+
!data/experiments/.gitkeep
36+
exports/**
37+
project_context.txt

.readthedocs.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: 2
2+
3+
sphinx:
4+
configuration: docs/conf.py
5+
6+
build:
7+
os: ubuntu-22.04
8+
tools:
9+
python: "3.10"
10+
11+
python:
12+
install:
13+
- method: pip
14+
path: .
15+
extra_requirements:
16+
- docs
17+
- analysis

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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.

cellucid-logo.svg

Lines changed: 114 additions & 0 deletions
Loading

data/.gitkeep

Whitespace-only changes.

docs/conf.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Sphinx configuration for the cellucid Python package."""
2+
3+
from __future__ import annotations
4+
5+
import sys
6+
from pathlib import Path
7+
8+
PROJECT_ROOT = Path(__file__).resolve().parents[1]
9+
SRC_DIR = PROJECT_ROOT / "src"
10+
sys.path.insert(0, str(SRC_DIR))
11+
12+
project = "cellucid"
13+
author = "cellucid contributors"
14+
15+
extensions = [
16+
"sphinx.ext.autodoc",
17+
"sphinx.ext.napoleon",
18+
"sphinx.ext.autosummary",
19+
"myst_parser",
20+
]
21+
22+
autosummary_generate = True
23+
templates_path = ["_templates"]
24+
exclude_patterns: list[str] = ["_build"]
25+
26+
html_theme = "sphinx_rtd_theme"
27+
28+
try:
29+
from cellucid import __version__
30+
except Exception: # pragma: no cover - import may fail during initial setup
31+
release = version = "0.0.0"
32+
else:
33+
release = version = __version__

docs/index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# cellucid
2+
3+
Utilities to export AnnData/numpy payloads for the 3D UMAP WebGL viewer.
4+
5+
## Quickstart
6+
- Install: `pip install -e python[docs,analysis]`
7+
- Export data: `from cellucid.prepare_data import export_data_for_web`
8+
- Default outputs land in `exports/` under your working directory; copy them into the viewer’s `assets/exports/` folder when hosting the site, or override `out_dir` to point there directly.
9+
10+
Companion viewer: static site in `theislab/cellucid` expects the exported `assets/exports/` folder.
11+
12+
## API
13+
```{autofunction} cellucid.prepare_data.export_data_for_web
14+
```
15+
```{automodule} cellucid.anndata_variations
16+
:members:
17+
:undoc-members:
18+
:show-inheritance:
19+
```
20+
21+
## Local docs build
22+
```bash
23+
cd python
24+
pip install -e .[docs]
25+
sphinx-build -b html docs docs/_build/html
26+
```

0 commit comments

Comments
 (0)