Spatial query tools for analyzing spatial transcriptomics data
Project description
SpatialQuery
SpatialQuery is a Python package for systematic spatial analysis of single-cell resolution spatial omics data. It provides a unified framework to discover, quantify, and compare recurring spatial cell type patterns — termed motifs — across single or multiple fields of view (FOVs).
Starting from annotated spatial omics datasets (spatial transcriptomics and spatial proteomics data), SpatialQuery constructs cell neighborhoods using KNN or distance-based approaches and mines frequent cell type co-occurrence patterns via the FP-Growth algorithm. It then tests whether these motifs are statistically enriched beyond what is expected by chance, and supports comparison of motif compositions across biological conditions (e.g., healthy vs. disease) through differential motif analysis.
Beyond spatial structure, SpatialQuery links motifs to molecular phenotypes. For cells participating in a given motif, it performs motif-associated differential expression analysis to identify genes whose expression differs between motif-positive and motif-negative cells or across conditions. It further detects cross-cell gene-gene covariation — spatially dependent correlations between gene expression in anchor cells and their neighbors — to reveal intercellular signaling relationships that are specific to particular spatial contexts.
Key capabilities include:
- Spatial motif discovery: Identify frequent cell type patterns in local neighborhoods
- Motif enrichment analysis: Statistically test whether motifs occur more than expected
- Differential motif analysis: Compare spatial compositions across conditions
- Motif-associated differential expression: Find DE genes linked to specific motifs
- Cross-cell gene-gene covariation: Detect spatially dependent intercellular gene correlations
- Multi-FOV support: Pool and compare results across multiple tissue sections or samples
Installation
pip install SpatialQuery
Documentation
Full documentation, tutorials, and API reference: https://spatialquery.readthedocs.io/en/latest/
Reproducibility
The following tutorials reproduce the main analyses presented in our manuscript:
- Mouse organogenesis — single-FOV analysis (seqFISH)
- Kidney disease atlas — multi-condition analysis (MERFISH)
- Colorectal cancer microenvironment — spatial proteomics (CODEX)
- Whole-brain atlas — large-scale analysis (MERFISH)
Quick Start
from SpatialQuery import spatial_query
# Single FOV analysis
sq = spatial_query(adata, spatial_key="X_spatial", label_key="cell_type", feature_name="gene")
enrich_motif = sq.motif_enrichment_dist(ct="T_cell", max_dist=10, min_support=0.5)
from SpatialQuery import spatial_query_multi
# Multi-FOV analysis
spm = spatial_query_multi(adatas=adatas, datasets=datasets,
spatial_key="X_spatial", label_key="cell_type", feature_name="gene")
enrich_motif = spm.motif_enrichment_dist(ct="T_cell", dataset="healthy", max_dist=10, min_support=0.5)
License
MIT
Contact
- Author: Shaokun An
- Email: shaokunan1@gmail.com
- GitHub: ShaokunAn
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
Built Distributions
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 spatialquery-0.0.5.tar.gz.
File metadata
- Download URL: spatialquery-0.0.5.tar.gz
- Upload date:
- Size: 117.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92aa1af0c5e3ea9b420ec1fc6cb07b7bbe27cd99b4cc32f5ed249b369c5b8d8d
|
|
| MD5 |
b1cbfb0585befe6ee2ee3d48aeba8462
|
|
| BLAKE2b-256 |
2b0721a61d92bac3a5f2c8f92744ae26c22b9e8d177d50777a4d3e3b85d76465
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5.tar.gz:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5.tar.gz -
Subject digest:
92aa1af0c5e3ea9b420ec1fc6cb07b7bbe27cd99b4cc32f5ed249b369c5b8d8d - Sigstore transparency entry: 1331812329
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spatialquery-0.0.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: spatialquery-0.0.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 6.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f777f952ec549ab3f02e7e464797cf7f80d91ad7dcb8f17dd400255a302bdc3b
|
|
| MD5 |
f8a54d3b14cbc559e819886e3e5a40cb
|
|
| BLAKE2b-256 |
42f8951302f46ac53a85a7427e25c5e1b3d11950698e488ca844e81d81c042d4
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
f777f952ec549ab3f02e7e464797cf7f80d91ad7dcb8f17dd400255a302bdc3b - Sigstore transparency entry: 1331812612
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spatialquery-0.0.5-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: spatialquery-0.0.5-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 376.1 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91b9ac3ee3869232b0bd98147204de2899a2a61fa937cd56e5012bf43409e197
|
|
| MD5 |
3972939384dab358451b22a0a16d580e
|
|
| BLAKE2b-256 |
3daea8afdb84f239dafb2332bbea62460621d9d99340801a78e4277bfcfe8878
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
91b9ac3ee3869232b0bd98147204de2899a2a61fa937cd56e5012bf43409e197 - Sigstore transparency entry: 1331812977
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spatialquery-0.0.5-cp312-cp312-macosx_10_13_x86_64.whl.
File metadata
- Download URL: spatialquery-0.0.5-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 399.4 kB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0ffa3a733669ab89c45370b60bf8fac101d8a4fb1a3ed1a3a111a8feeb2a7d4
|
|
| MD5 |
fce4997418afdd951308594f619bea55
|
|
| BLAKE2b-256 |
8a0b9437e1086fe90d03c4ed0101b7a22ef0710c32fa085f30c4f8702ead57a9
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5-cp312-cp312-macosx_10_13_x86_64.whl:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5-cp312-cp312-macosx_10_13_x86_64.whl -
Subject digest:
b0ffa3a733669ab89c45370b60bf8fac101d8a4fb1a3ed1a3a111a8feeb2a7d4 - Sigstore transparency entry: 1331812787
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spatialquery-0.0.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: spatialquery-0.0.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e6e651e7837dfc64d017b6f8b2520211d03a0b137343daace84a74d951b53bf
|
|
| MD5 |
239508518a807106d74d76dd27010c62
|
|
| BLAKE2b-256 |
936b9375f174d8cefebd4d1ddaff1b3eef34f79f4f80003325f0f6cffc623426
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
6e6e651e7837dfc64d017b6f8b2520211d03a0b137343daace84a74d951b53bf - Sigstore transparency entry: 1331812883
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spatialquery-0.0.5-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: spatialquery-0.0.5-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 374.7 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea4e542c610727b99ea988555199f1623e7a9239367fdaf09596755510dfc045
|
|
| MD5 |
4a68e912bf9009114b5f8b364c61269b
|
|
| BLAKE2b-256 |
86c5d8de3a8f28beb10faa2a96d9b354eedd28d7a8ebdf7b695ae9a6f48b4dd4
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
ea4e542c610727b99ea988555199f1623e7a9239367fdaf09596755510dfc045 - Sigstore transparency entry: 1331813165
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spatialquery-0.0.5-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: spatialquery-0.0.5-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 394.5 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e62acd68f3c0c98b50d0f43e724d3e7d01365daed89f177404556bf73b071d3
|
|
| MD5 |
96c0404de2c65ac11450ddb66faf8616
|
|
| BLAKE2b-256 |
cacfa0d3b5d71fdd36831d0ba6437bde9b6113d8edb082c9aff968990c451590
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5-cp311-cp311-macosx_10_9_x86_64.whl:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5-cp311-cp311-macosx_10_9_x86_64.whl -
Subject digest:
2e62acd68f3c0c98b50d0f43e724d3e7d01365daed89f177404556bf73b071d3 - Sigstore transparency entry: 1331812698
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spatialquery-0.0.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: spatialquery-0.0.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9ffb370c647c67594111ab424429893779818e32312df9c84a3246ad6109d48
|
|
| MD5 |
f0ee07b86a66efa387931f6c77e86145
|
|
| BLAKE2b-256 |
4eec0da7c5e97a636f4f7e06b5865bb573cba35111a3f4ebd4a499dfba235d74
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
a9ffb370c647c67594111ab424429893779818e32312df9c84a3246ad6109d48 - Sigstore transparency entry: 1331812434
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spatialquery-0.0.5-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: spatialquery-0.0.5-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 373.7 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a5dd66856d0723e2bc14a794f3661ae00d0c1433c6cf00d7f29c731c561bcb0
|
|
| MD5 |
8382e426ab9060b1623efd430a271250
|
|
| BLAKE2b-256 |
05d0d444e41eda1079b409c434cf6e820438fca15f578e6c1abe40b8b11a7dbc
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5-cp310-cp310-macosx_11_0_arm64.whl:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5-cp310-cp310-macosx_11_0_arm64.whl -
Subject digest:
2a5dd66856d0723e2bc14a794f3661ae00d0c1433c6cf00d7f29c731c561bcb0 - Sigstore transparency entry: 1331812524
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spatialquery-0.0.5-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: spatialquery-0.0.5-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 393.6 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bbbc2c5731be7799d736afb186ec187adcce6cfb18f47df0f4d205466c21cfe
|
|
| MD5 |
caedf2eb34d3bc8aded428ac3f4ff936
|
|
| BLAKE2b-256 |
8fba8729b239555305b7f366add91fa8e1809e787f6a14e1e87a01fcf506478b
|
Provenance
The following attestation bundles were made for spatialquery-0.0.5-cp310-cp310-macosx_10_9_x86_64.whl:
Publisher:
build_wheels.yml on ShaokunAn/Spatial-Query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spatialquery-0.0.5-cp310-cp310-macosx_10_9_x86_64.whl -
Subject digest:
8bbbc2c5731be7799d736afb186ec187adcce6cfb18f47df0f4d205466c21cfe - Sigstore transparency entry: 1331813078
- Sigstore integration time:
-
Permalink:
ShaokunAn/Spatial-Query@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ShaokunAn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@457b856e3aefbc7f13a79120315c38ba942be7b9 -
Trigger Event:
release
-
Statement type: