Skip to content

dpeerlab/segger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

We recommend CUDA 12.1 with cu* packages version ≥24.2 and <26.0. Ensure your CUDA driver version matches or exceeds your toolkit version (≥12.1 for CUDA 12.1). Adjust package versions in the environment files below if your system requires a different package versions.

Clone the repository

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

Using conda

conda env create -n segger -f environment_cuda121.yml

Adjust environment_cuda121.yml for other CUDA versions (e.g., environment_cuda118.yml for CUDA 11.8).

Using pixi

pixi install -e cuda121

Adjust the environment name in pixi.toml as needed for other CUDA versions.

pip

Install GPU-accelerated PyTorch and RAPIDS compatible with your CUDA version before installing segger. All CUDA-enabled packages must be compiled for the same CUDA version.

For example, on Linux with CUDA 12.1 and PyTorch 2.5.0:

# Install PyTorch and torchvision for CUDA 12.1
pip install torch==2.5.0 torchvision==0.20.0 --index-url https://download.pytorch.org/whl/cu121

# Install torch_scatter for CUDA 12.1
pip install torch_scatter -f https://data.pyg.org/whl/torch-2.5.0+cu121.html

# Install RAPIDS packages for CUDA 12.x
pip install --extra-index-url=https://pypi.nvidia.com cuspatial-cu12 cudf-cu12 cuml-cu12 cugraph-cu12

# Install CuPy for CUDA 12.x
pip install cupy-cuda12x

December 2025: To stay up-to-date with new developments, we recommend installing the latest version directly from GitHub:

# Clone segger repo and install locally
pip install -e .

Usage

You can run segger from the command line with:

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

To see all available parameter options:

segger segment --help

Exporting segmentation outputs for interoperability

segger export writes a segger segmentation to plain files from which a SpatialData object can be assembled. Name which elements to write: anndata (cell by gene table), transcripts (the assigned transcripts), or boundaries (one polygon per cell). With no element named it writes anndata and boundaries; add transcripts for the per-transcript assignment.

segger export                     -s outputs/segger_segmentation.parquet -i /path/to/ist/data/ -o export/   # anndata.h5ad + cell_boundaries.parquet
segger export anndata transcripts -s outputs/segger_segmentation.parquet -i /path/to/ist/data/ -o export/   # select which elements to write

Boundaries are traced with --method: delaunay (the default) prunes a Delaunay triangulation into a concave outline, while convex_hull takes the convex hull; neither is smoothed by default, but --chaikin-iterations rounds them with that many rounds of Chaikin corner-cutting. The exported transcripts are controlled by --include-all-transcripts, --min-similarity, and --min-transcripts (see segger export --help).

The column names follow SOPA's SpatialData conventions. anndata.h5ad and cell_boundaries.parquet share cell_id, the instance key SOPA uses to join a table to its shapes. transcripts.parquet keeps the segger assignment as segger_cell_id (plus row_index), a sibling column in the spirit of SOPA's sopa_prior, so it merges onto an existing transcripts dataframe by row_index without overwriting the vendor cell_id; its values match the cell_id in the other two files.

About

GNN-based cell segmentation of spatial transcriptomics data

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages