Metadata-Version: 2.5
Name: segger
Version: 1.0.0rc1
Summary: Segmentation of spatial transcriptomics data
Project-URL: Homepage, https://github.com/dpeerlab/segger
Project-URL: Documentation, https://segger-segmentation.readthedocs.io/en/latest/
Project-URL: Repository, https://github.com/dpeerlab/segger
Project-URL: Changelog, https://github.com/dpeerlab/segger/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/dpeerlab/segger/issues
Author-email: Elyas Heidari <elyas.heidari@dkfz-heidelberg.de>, Andrew Moorman <moormana@mskcc.org>
License-Expression: MIT
Keywords: image-analysis,segmentation,spatial-transcriptomics
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: <3.14,>=3.13
Requires-Dist: anndata
Requires-Dist: cudf-cu13>=26
Requires-Dist: cugraph-cu13>=26
Requires-Dist: cuml-cu13>=26
Requires-Dist: cupy-cuda13x
Requires-Dist: cuspa-cu13
Requires-Dist: cyclopts
Requires-Dist: fastquadtree
Requires-Dist: geopandas
Requires-Dist: imagecodecs
Requires-Dist: lightning
Requires-Dist: numba
Requires-Dist: numpy
Requires-Dist: opencv-python
Requires-Dist: pandas
Requires-Dist: polars
Requires-Dist: pyarrow
Requires-Dist: rmm-cu13>=26
Requires-Dist: scanpy>=1.13
Requires-Dist: scikit-image
Requires-Dist: scikit-learn
Requires-Dist: scipy
Requires-Dist: shapely
Requires-Dist: tifffile
Requires-Dist: torch-geometric
Requires-Dist: torch==2.14.*
Requires-Dist: torchvision
Requires-Dist: tqdm
Provides-Extra: spatialdata
Requires-Dist: spatialdata; extra == 'spatialdata'
Description-Content-Type: text/markdown

# segger

GNN-based cell segmentation of spatial transcriptomics data.

![segger overview](https://raw.githubusercontent.com/dpeerlab/segger/main/segger_overview.png)

> Segger is a graph neural network (GNN)-based method that formulates cell segmentation in imaging-based spatial transcriptomics (iST) as a problem of transcript–cell assignment. Rather than relying solely on geometric proximity, Segger assumes that a transcript belongs to a cell if it is consistent both with its local spatial context and with the gene expression programs that define cell identity, as captured in a shared latent representation.
>
> — [Heidari, Moorman, et al., segger methods description](segger_methods.pdf)

> [!IMPORTANT]
> **Latest cuspa-accelerated segger:** the version used for the manuscript, which scales to billion-transcript
> whole-transcriptome datasets (e.g. Atera) using NVIDIA `cuspa`, is available as
> [release **v0.4.0-manuscript**](https://github.com/dpeerlab/segger/releases/tag/v0.4.0-manuscript).
> It requires CUDA 13 and Python 3.13 and is **not yet stable**. To install it:
>
> ```bash
> git clone --branch v0.4.0-manuscript https://github.com/dpeerlab/segger.git && cd segger
> pixi install   # or: conda env create -n segger -f environment.yml
> ```
>
> The instructions below install the stable release on `main`.

Full documentation - installation, quickstart, outputs, API reference, etc.:
[segger-segmentation.readthedocs.io](https://segger-segmentation.readthedocs.io/en/latest/)

## Installation

**segger** requires CUDA 13 and Python 3.13.

Clone the repo, then use `conda` or `pixi`:

```bash
git clone https://github.com/dpeerlab/segger.git && cd segger
```

```bash
# conda
conda env create -n segger -f environment.yml
conda activate segger

# pixi
pixi install
pixi shell
```

Alternatively, install directly from GitHub without cloning:

```bash
pip install --extra-index-url https://pypi.nvidia.com --extra-index-url https://download.pytorch.org/whl/cu130 git+https://github.com/dpeerlab/segger.git
```

## Usage

```bash
segger segment \
  -i /path/to/your/ist/data/ \
  -o /path/to/save/outputs/

# export different data formats (e.g. boundaries, spatialdata, anndata, xeniumranger, ...)
segger export boundaries \
  -s /path/to/save/outputs/segger_segmentation.parquet \
  -o /path/to/export/

# export spatialdata. transcripts are added to the existing sdata
segger export spatialdata \
  -s /path/to/save/outputs/segger_segmentation.parquet \
  --sdata /path/to/sdata.zarr

# for Xenium data to visualise in xenium explorer
segger export xeniumranger \
  -s /path/to/save/outputs/segger_segmentation.parquet \
  -i /path/to/your/ist/data/ \
  -o /path/to/export/
```

See [notebooks/quickstart.ipynb](notebooks/quickstart.ipynb) for an end-to-end walkthrough.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).

## Methods description

[Heidari, E., Moorman, A., et al. Segger: Fast and accurate cell segmentation of imaging-based spatial transcriptomics data. Methods description (2026).](segger_methods.pdf)

## Citation

If you use segger in your research, please cite:

```bibtex
@misc{heidari2026segger,
  title={Segger: Fast and accurate cell segmentation of imaging-based spatial transcriptomics data},
  author={Heidari, Elyas and Moorman, Andrew and others},
  note={Methods description},
  year={2026},
  howpublished={\url{https://github.com/dpeerlab/segger/blob/main/segger_methods.pdf}}
}
```
