Skip to main content

Steamboat

PyPI - Version Documentation Status Unit and integration tests

Steamboat is an interpretable machine learning framework leveraging a self-supervised, multi-head attention model that uniquely decomposes the gene expression of a cell into multiple key factors:

  • intrinsic cell programs,
  • neighboring cell communication, and
  • long-range interactions.

These pieces of information are used to generate cell embedding, cell network, and reconstructed gene expression.

fig1-v3-abstract

System requirements

Hardware

Steamboat can run on a laptop, desktop, or server. The experiments were done on a desktop computer with an RTX 3080 GPU (10GB VRAM). A GPU can significantly reduce the time needed to train the models (more than 5x on the most demanding examples).

Operating system

Steamboat is Python-based and runs on all mainstream operating systems. It has been tested on Windows 10 and Springdale Linux.

Software dependencies

Latest tested working dependency combination
Package Tested in 06/2025 Tested in 12/2025
Python 3.11.5 3.13.9
Torch 2.1.2 (w/ cuda 12.1) 2.9.1 (w/ cuda 13.0)
Scanpy 1.9.6 1.11.5
Squidpy 1.5.0 1.6.6
Scipy 1.11.4 1.16.3
Numpy 1.26.2 2.3.1
Networkx 3.1 3.5
Matplotlib 3.8.0 3.10.6
Seaborn 0.13.2 0.13.2
Scikit-learn 1.2.2 1.7.2

Installation

We recommend using Miniconda to create a virtual environment.

conda create -n steamboat python=3.13
conda activate steamboat
pip install steamboat-bio

Installation usually takes about 2 minutes, but can vary depending on computer and network conditions.

Tips for GPU support

Before running pip install steamboat-bio, follow the official guide to install the appropriate Pytorch version for your system and hardware. The exact commands will depend on your hardware and system. In general, they look like this.

conda create -n steamboat python=3.13
conda activate steamboat
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu130 # DO NOT RUN. ADJUST IT FOR YOUR SYSTEM.
pip install steamboat-bio
Run without installation

If you are interested in modifying the package, or just don't feel like installing it, Steamboat can be imported directly after adding its directory to the path.

git clone https://github.com/ma-compbio-lab/Steamboat
import sys
sys.path.append("/path/of/the/cloned/repository")

You may need to install the dependencies listed in requirements.txt manually.

Basic workflow

import torch
import steamboat as sf # "sf" = "Steamboat Factorization"
import steamboat.tools

Data preparation and training

First, make a list (adatas) of one or more AnnData objects with matching genes in the same order and spatial coordinates in obsm['spatial'], and preprocess them. This example uses all genes and treats each sample as one global region.

adatas = sf.prep_adatas(adatas, norm=True, log1p=True)
for adata in adatas:
    adata.obs['global'] = 0
dataset = sf.make_dataset(adatas, mask_var=False, regional_obs=['global'])
short_features = adatas[0].var_names.tolist()

Create a Steamboat model and fit it to the data. Refer to the tutorial about selecting the optimal n_heads.

model = sf.Steamboat(short_features, n_heads=10, n_scales=3)
device = "cuda" if torch.cuda.is_available() else "cpu"
model = model.to(device)
model.fit(dataset, device=device)

After training, you can check the trained metagenes.

sf.tools.plot_all_transforms(model, top=1)

Tissue architecture definition (clustering and segmentation)

For clustering and segmentation, run the following lines. Change the resolution to your liking.

sf.tools.calc_obs(adatas, dataset, model, device=device)
adata = adatas[0] # Select the sample to analyze.
sf.tools.neighbors(adata)
sf.tools.leiden(adata, resolution=0.1)
sf.tools.segment(adata, resolution=0.5)

Mechanistic discovery (ligand–receptor screening)

lrp_dfs = sf.tools.score_lrs(adata, model, None, gene_names='index')
for i in range(model.spatial_gather.n_heads):
    display(lrp_dfs[i])

For visualization of the results, please refer to the tutorial.

Hypothesis testing (spatial perturbation)

This is a more involved process. Please refer to the relevant demos below.

If you want to try Steamboat with a relatively small dataset, please try human tonsil (Slide-tags).

Demos

A few examples in Jupyter notebook are included in the examples folder:

  1. Illustration (simulated)
  2. Ovarian cancer data (CosMX)
  3. Mouse brain (MERFISH)
  4. Colorectal cancer data (CODEX)
  5. Xenograft melanoma (Perturb-FISH)
  6. Human tonsil (Slide-tags)
  7. Breast cancer (Visium) (Note: Steamboat's attention does not directly reflect cell-cell relationship on spot-level data.)

The simulation demo takes about five minutes to run. The mouse brain data takes one hour to train. Other demos take about ten minutes each.

While the demos only cover selected results that are quick to go through, all results can be generated by code in reproducibility directory.

Data used in these examples are available in Google Drive. Trained models are also uploaded.

Documentation

For the full API and real data examples, please visit our documentation.

Metadata

Release files for steamboat-bio 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for steamboat-bio 0.1.7
File Size Uploaded Provenance Actions
steamboat_bio-0.1.7.tar.gz 27.9 kB With provenance Details for steamboat_bio-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for steamboat-bio 0.1.7
File Interpreter ABI Platform Actions
steamboat_bio-0.1.7-py3-none-any.whl Python 3 none any Details for steamboat_bio-0.1.7-py3-none-any.whl

Total release size: 53.6 kB

Release files / steamboat_bio-0.1.7.tar.gz

Download URL steamboat_bio-0.1.7.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
42d302462487a0a65245f7e839b2c27ffa810341b826049f15b87d21fb7243f2
BLAKE2b-256 checksum
How to use checksums
c6665693e19c512bf839dab620b32de1457a70e8d6301f838162ceb51e0410e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / steamboat_bio-0.1.7-py3-none-any.whl

Download URL steamboat_bio-0.1.7-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f73d55b1693aa70be37a97df181ae1c060281b0de5033343db439c9fd5326db
BLAKE2b-256 checksum
How to use checksums
e94450833af5ae46af37e6beddfc11ec463d41c65030e7eac05e81fdaed2c667
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for steamboat-bio 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for steamboat_bio-0.1.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page