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:
- Load a spatial
AnnDataobject. - Filter the ligand-receptor database to pairs supported by the dataset.
- Run
spaflow. - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42bc58114f07f4b131e939d4dfe640f2c4063fb7490b5dc932a217eb17380e77
|
|
| MD5 |
124bd33bde7672cda607b992d03c64dc
|
|
| BLAKE2b-256 |
39eb5d8802931cca3b0dbe757d73aa283da2a034d6b9609b14bd8fc5cf3b0f15
|
Provenance
The following attestation bundles were made for spaflow-0.1.0.tar.gz:
Publisher:
publish.yml on Tigerrr07/SpaFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spaflow-0.1.0.tar.gz -
Subject digest:
42bc58114f07f4b131e939d4dfe640f2c4063fb7490b5dc932a217eb17380e77 - Sigstore transparency entry: 1247804558
- Sigstore integration time:
-
Permalink:
Tigerrr07/SpaFlow@7ce80bfdb573991487284112f4212600067375a5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Tigerrr07
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7ce80bfdb573991487284112f4212600067375a5 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
969a6f0d0ba9f354e56685bc5188cc6af2c11fecad186fcd9cc7d39fe040a998
|
|
| MD5 |
8849b45025448fc3931aed421e71a6f8
|
|
| BLAKE2b-256 |
02cc4a07788f453028e9095ef21b3e533da7636bf606928428d5f41dda834997
|
Provenance
The following attestation bundles were made for spaflow-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Tigerrr07/SpaFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spaflow-0.1.0-py3-none-any.whl -
Subject digest:
969a6f0d0ba9f354e56685bc5188cc6af2c11fecad186fcd9cc7d39fe040a998 - Sigstore transparency entry: 1247804562
- Sigstore integration time:
-
Permalink:
Tigerrr07/SpaFlow@7ce80bfdb573991487284112f4212600067375a5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Tigerrr07
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7ce80bfdb573991487284112f4212600067375a5 -
Trigger Event:
push
-
Statement type: