Skip to main content

A spatial CCC tool to infer ligand-receptor interaction

Project description

spaflow

spaflow is a spatial cell-cell communication tool for ligand-receptor interaction analysis in spatial transcriptomics data.

It is designed to answer a practical question:

"Where are ligand-receptor signals active in tissue, and which locations show stronger-than-expected spatial communication?"

The package is built around Scanpy and Squidpy and uses spatial permutation testing to identify ligand-receptor hotspots.

Installation

Create the envionment and install from PyPI:

conda create -n spaflow python=3.10 -y
pip install spaflow

If you are working from the repository:

uv sync

Tutorial

The main tutorial lives in tutorial.ipynb. The workflow is:

  1. Load a spatial AnnData object.
  2. Filter the ligand-receptor database to pairs supported by the dataset.
  3. Run spaflow.
  4. Visualize ligand-receptor activity and hotspot calls.

1. Load data

import warnings

warnings.filterwarnings("ignore")

import scanpy as sc
from spaflow import filter_lr_database, run_spaflow

adata = sc.read("your_data.h5ad")

2. Filter the ligand-receptor database

df_ligrec = filter_lr_database(adata)
df_ligrec.head()

By default, this keeps supported ligand-receptor pairs for secreted signaling.

3. Run SpaFlow

spaflow_adata = run_spaflow(adata, df_ligrec)

4. Visualize results

The tutorial notebook shows a spatial plot for TNFSF14-LTBR:

lr = "TNFSF14-LTBR"

spaflow_adata.uns[f"{lr}_sig_colors"] = ["#DDDDDD", "#EE6677"]

sc.pl.spatial(
    spaflow_adata,
    color=[lr, f"{lr}_sig", "Classes"],
    img_key=None,
    size=1.5,
    frameon=False,
    cmap="Spectral_r",
)

In this example, "Classes" is an annotation column already present in the tutorial dataset. Replace it with a column from your own adata.obs if needed.

Output

run_spaflow returns a copy of the input AnnData with additional columns in adata.obs.

For each ligand-receptor complex, the output typically includes:

  • <complex>: ligand-receptor interaction activity
  • <complex>_sig: ligand-receptor interaction hotspots

These outputs can be used directly in scanpy.pl.spatial or downstream statistical summaries.

Notes

  • The notebooks under figures/ are manuscript-oriented analysis notebooks rather than package onboarding material.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spaflow-0.1.0.tar.gz (79.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spaflow-0.1.0-py3-none-any.whl (82.1 kB view details)

Uploaded Python 3

File details

Details for the file spaflow-0.1.0.tar.gz.

File metadata

  • Download URL: spaflow-0.1.0.tar.gz
  • Upload date:
  • Size: 79.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spaflow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 42bc58114f07f4b131e939d4dfe640f2c4063fb7490b5dc932a217eb17380e77
MD5 124bd33bde7672cda607b992d03c64dc
BLAKE2b-256 39eb5d8802931cca3b0dbe757d73aa283da2a034d6b9609b14bd8fc5cf3b0f15

See more details on using hashes here.

Provenance

The following attestation bundles were made for spaflow-0.1.0.tar.gz:

Publisher: publish.yml on Tigerrr07/SpaFlow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spaflow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: spaflow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spaflow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 969a6f0d0ba9f354e56685bc5188cc6af2c11fecad186fcd9cc7d39fe040a998
MD5 8849b45025448fc3931aed421e71a6f8
BLAKE2b-256 02cc4a07788f453028e9095ef21b3e533da7636bf606928428d5f41dda834997

See more details on using hashes here.

Provenance

The following attestation bundles were made for spaflow-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Tigerrr07/SpaFlow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page