Skip to main content

GESSO: Spatial Gene Set Activity Analysis

GESSO (Gene sEt activity Score analysis with Spatial lOcation) is a computational method for estimating spatially coherent gene set activity from spatial transcriptomics data.

This repository is the official Python implementation of GESSO. Please visit the GESSO documentation for tutorials and API details.

GESSO workflow showing spatial gene set activity estimation, local activity enrichment testing, and downstream biological analyses.

Figure 1. Overview of the GESSO workflow and applications. From the GESSO paper in Nature Communications.

Installation

The PyPI distribution name is gesso-py; the Python import remains from gesso import GESSO.

We recommend installing GESSO in a new Python environment. You can create a new Python environment through conda:

conda create -n gesso python=3.12 -y
conda activate gesso

GESSO supports Python 3.12, 3.13, and 3.14. The example above uses 3.12; you can substitute either of the other supported versions. Install GESSO from PyPI:

pip install gesso-py

Quick start

For Scanpy/Squidpy workflows, install optional AnnData support with pip install 'gesso-py[anndata]', or install the plotting tutorial dependencies with pip install 'gesso-py[tutorial]'. GESSO itself requires neither Scanpy nor Squidpy. Use GESSO.from_anndata(adata, layer="counts") to preserve sparse expression and report.write_to_anndata(adata) to attach pathway scores. See the AnnData tutorial for normalization choices and plotting examples.

GESSO processes spatial transcriptomics data along with a user-defined gene set/pathway and outputs a gene set activity score (GAS) for each spatial location.

Let's say your spatial transcriptomics dataset contains counts for $G$ genes across $N$ spots. You'll need to prepare an $N \times G$ expression pd.DataFrame as well as an $N \times 2$ locations pd.DataFrame. The indices of the two DataFrames must match. The locations DataFrame must contain two columns named x and y.

import pandas as pd
from gesso import GESSO

# load data
expression_df: pd.DataFrame = ...
locations_df: pd.DataFrame = ...

# initialize a GESSO model
model = GESSO(
    expression_df=expression_df,
    locations_df=locations_df,
    k=20,
    normalize_counts_method="normalize-log1p"   # optional, use for raw data
)

# compute gene set activity scores
gas_report = model.compute_gas(
    genesets_dict={
        "example_geneset_1": ["gene1", "gene2", "gene3"],
        "example_geneset_2": ["gene4", "gene5", "gene6"],
    },
    n_jobs=2        # number of parallel jobs
)
gas_df = gas_report.gas_df()    # returns N by n_genesets df
gas_df.to_csv("gas_output.csv")

# test whether each spot exhibits significantly elevated gene set activity
htest_report = model.htest_elevated_gas(
    geneset="example_geneset_1",
    genes_in_geneset=["gene1", "gene2", "gene3"],
    n_permutations=500,     # number of random gene sets to sample
    n_jobs=8
)
htest_df = htest_report.htest_df()  # returns N by 4 df w/ columns 'x', 'y', 'gas', 'p'
htest_df.to_csv("htest_output.csv")

Tutorials

The documentation includes a runnable tutorial using the small dataset bundled in demo_data, as well as demonstrations for several spatial transcriptomics platforms. The platform-scale demonstrations require the corresponding public datasets described in each notebook.

Download or clone the repository for the notebooks and bundled demo data; these are not included in the installed package.

AI-assisted analysis

The gesso_vibe folder includes an analysis skill for AI agents, with guidance on spatial data input, pathway scoring, and exporting results through the GESSO Python API.

Citation

If you use GESSO, please cite the following article and the specific GESSO software release used in your analysis:

Yang, A. J., Tan, C. & Ma, Y. Interpretable and scalable spatial gene set activity analysis with GESSO uncovers functional tissue architecture. Nature Communications (2026). https://doi.org/10.1038/s41467-026-78316-z

Machine-readable citation metadata are provided in CITATION.cff.

License

GESSO is released under the MIT License.

Metadata

Release files for gesso-py 0.2.0

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

Source distribution (sdist)

Source distribution for gesso-py 0.2.0
File Size Uploaded Provenance Actions
gesso_py-0.2.0.tar.gz 14.0 MB With provenance Details for gesso_py-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gesso-py 0.2.0
File Interpreter ABI Platform Actions
gesso_py-0.2.0-py3-none-any.whl Python 3 none any Details for gesso_py-0.2.0-py3-none-any.whl

Total release size: 14.1 MB

Release files / gesso_py-0.2.0.tar.gz

Download URL gesso_py-0.2.0.tar.gz
Size 14.0 MB
Tags Source
SHA-256 checksum
How to use checksums
4e11cd7006a630042ba2213a4eae3a5c0a1a1f99990808f3ec8fd0467d6a77d8
BLAKE2b-256 checksum
How to use checksums
5749c7216192c9e56ecc7c503ef9849434f52bf52e929b871ad764cc209a1fbc
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 3, 2026.

Transparency log

Release files / gesso_py-0.2.0-py3-none-any.whl

Download URL gesso_py-0.2.0-py3-none-any.whl
Size 30.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b67c597216777392b6f41d8b0d58a796801df5b0e3306b483d92d9bf355473bf
BLAKE2b-256 checksum
How to use checksums
4471f0c2431020a580199ac7f691b2c5e5f1ecf348f9837c7ace05352b1a8d82
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 3, 2026.

Transparency log

Security for gesso-py 0.2.0

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gesso_py-0.2.0.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 3, 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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