SpatialQuery 0.0.3__tar.gz → 0.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. spatialquery-0.0.4/PKG-INFO +92 -0
  2. spatialquery-0.0.4/README.md +55 -0
  3. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/spatial_query.py +36 -33
  4. spatialquery-0.0.4/SpatialQuery.egg-info/PKG-INFO +92 -0
  5. {spatialquery-0.0.3 → spatialquery-0.0.4}/pyproject.toml +2 -1
  6. spatialquery-0.0.3/PKG-INFO +0 -379
  7. spatialquery-0.0.3/README.md +0 -343
  8. spatialquery-0.0.3/SpatialQuery.egg-info/PKG-INFO +0 -379
  9. {spatialquery-0.0.3 → spatialquery-0.0.4}/LICENSE +0 -0
  10. {spatialquery-0.0.3 → spatialquery-0.0.4}/MANIFEST.in +0 -0
  11. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/__init__.py +0 -0
  12. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/plotting.py +0 -0
  13. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/__init__.py +0 -0
  14. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/core_methods.py +0 -0
  15. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/EliasFano.h +0 -0
  16. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/QueryScore.cpp +0 -0
  17. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/QueryScore.h +0 -0
  18. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/Serialization.h +0 -0
  19. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/__init__.py +0 -0
  20. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/const.h +0 -0
  21. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/eliasFano.cpp +0 -0
  22. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/fp_growth.cpp +0 -0
  23. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/fp_growth.h +0 -0
  24. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/serialization.cpp +0 -0
  25. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/typedef.h +0 -0
  26. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/utils.cpp +0 -0
  27. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/scfind4sp/cpp_src/utils.h +0 -0
  28. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/spatial_differential_pattern.py +0 -0
  29. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/spatial_gene_covarying.py +0 -0
  30. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/spatial_query_multiple_fov.py +0 -0
  31. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/spatial_utils.py +0 -0
  32. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery/utils.py +0 -0
  33. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery.egg-info/SOURCES.txt +0 -0
  34. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery.egg-info/dependency_links.txt +0 -0
  35. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery.egg-info/requires.txt +0 -0
  36. {spatialquery-0.0.3 → spatialquery-0.0.4}/SpatialQuery.egg-info/top_level.txt +0 -0
  37. {spatialquery-0.0.3 → spatialquery-0.0.4}/setup.cfg +0 -0
  38. {spatialquery-0.0.3 → spatialquery-0.0.4}/setup.py +0 -0
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.4
2
+ Name: SpatialQuery
3
+ Version: 0.0.4
4
+ Summary: Spatial query tools for analyzing spatial transcriptomics data
5
+ Author-email: Shaokun An <shan12@bwh.harvard.edu>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ShaokunAn/Spatial-Query
8
+ Project-URL: Documentation, https://spatial-query.readthedocs.io
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: numpy>=1.23.0
19
+ Requires-Dist: anndata>=0.8.0
20
+ Requires-Dist: pandas>=2.0.3
21
+ Requires-Dist: scipy>=1.10.0
22
+ Requires-Dist: matplotlib>=3.7.5
23
+ Requires-Dist: scikit-learn>=1.3.2
24
+ Requires-Dist: scanpy>=1.9.5
25
+ Requires-Dist: statsmodels>=0.14.0
26
+ Requires-Dist: seaborn>=0.13.2
27
+ Requires-Dist: mlxtend>=0.23.1
28
+ Requires-Dist: tqdm>=4.60.0
29
+ Requires-Dist: zarr>=2.14.0
30
+ Provides-Extra: docs
31
+ Requires-Dist: sphinx>=5.3; extra == "docs"
32
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
33
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
34
+ Requires-Dist: sphinx-copybutton; extra == "docs"
35
+ Requires-Dist: myst-parser; extra == "docs"
36
+ Dynamic: license-file
37
+
38
+ # SpatialQuery
39
+
40
+ 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).
41
+
42
+ 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.
43
+
44
+ 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.
45
+
46
+ Key capabilities include:
47
+
48
+ - **Spatial motif discovery**: Identify frequent cell type patterns in local neighborhoods
49
+ - **Motif enrichment analysis**: Statistically test whether motifs occur more than expected
50
+ - **Differential motif analysis**: Compare spatial compositions across conditions
51
+ - **Motif-associated differential expression**: Find DE genes linked to specific motifs
52
+ - **Cross-cell gene-gene covariation**: Detect spatially dependent intercellular gene correlations
53
+ - **Multi-FOV support**: Pool and compare results across multiple tissue sections or samples
54
+
55
+ ## Installation
56
+
57
+ ```bash
58
+ pip install SpatialQuery
59
+ ```
60
+
61
+ ## Documentation
62
+
63
+ Full documentation, tutorials, and API reference: **[https://spatialquery.readthedocs.io/en/latest/](https://spatialquery.readthedocs.io/en/latest/)**
64
+
65
+ ## Quick Start
66
+
67
+ ```python
68
+ from SpatialQuery import spatial_query
69
+
70
+ # Single FOV analysis
71
+ sq = spatial_query(adata, spatial_key="X_spatial", label_key="cell_type", feature_name="gene")
72
+ enrich_motif = sq.motif_enrichment_dist(ct="T_cell", max_dist=10, min_support=0.5)
73
+ ```
74
+
75
+ ```python
76
+ from SpatialQuery import spatial_query_multi
77
+
78
+ # Multi-FOV analysis
79
+ spm = spatial_query_multi(adatas=adatas, datasets=datasets,
80
+ spatial_key="X_spatial", label_key="cell_type", feature_name="gene")
81
+ enrich_motif = spm.motif_enrichment_dist(ct="T_cell", dataset="healthy", max_dist=10, min_support=0.5)
82
+ ```
83
+
84
+ ## License
85
+
86
+ MIT
87
+
88
+ ## Contact
89
+
90
+ - **Author**: Shaokun An
91
+ - **Email**: shaokunan1@gmail.com
92
+ - **GitHub**: [ShaokunAn](https://github.com/ShaokunAn)
@@ -0,0 +1,55 @@
1
+ # SpatialQuery
2
+
3
+ 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).
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ Key capabilities include:
10
+
11
+ - **Spatial motif discovery**: Identify frequent cell type patterns in local neighborhoods
12
+ - **Motif enrichment analysis**: Statistically test whether motifs occur more than expected
13
+ - **Differential motif analysis**: Compare spatial compositions across conditions
14
+ - **Motif-associated differential expression**: Find DE genes linked to specific motifs
15
+ - **Cross-cell gene-gene covariation**: Detect spatially dependent intercellular gene correlations
16
+ - **Multi-FOV support**: Pool and compare results across multiple tissue sections or samples
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pip install SpatialQuery
22
+ ```
23
+
24
+ ## Documentation
25
+
26
+ Full documentation, tutorials, and API reference: **[https://spatialquery.readthedocs.io/en/latest/](https://spatialquery.readthedocs.io/en/latest/)**
27
+
28
+ ## Quick Start
29
+
30
+ ```python
31
+ from SpatialQuery import spatial_query
32
+
33
+ # Single FOV analysis
34
+ sq = spatial_query(adata, spatial_key="X_spatial", label_key="cell_type", feature_name="gene")
35
+ enrich_motif = sq.motif_enrichment_dist(ct="T_cell", max_dist=10, min_support=0.5)
36
+ ```
37
+
38
+ ```python
39
+ from SpatialQuery import spatial_query_multi
40
+
41
+ # Multi-FOV analysis
42
+ spm = spatial_query_multi(adatas=adatas, datasets=datasets,
43
+ spatial_key="X_spatial", label_key="cell_type", feature_name="gene")
44
+ enrich_motif = spm.motif_enrichment_dist(ct="T_cell", dataset="healthy", max_dist=10, min_support=0.5)
45
+ ```
46
+
47
+ ## License
48
+
49
+ MIT
50
+
51
+ ## Contact
52
+
53
+ - **Author**: Shaokun An
54
+ - **Email**: shaokunan1@gmail.com
55
+ - **GitHub**: [ShaokunAn](https://github.com/ShaokunAn)
@@ -31,39 +31,6 @@ class spatial_query:
31
31
 
32
32
  A class for performing spatial query analysis on spatial transcriptomics data of a single field of view,
33
33
  including pattern discovery, enrichment analysis, differential analysis, and gene-gene covariation assessment.
34
-
35
- Parameters
36
- ----------
37
- adata : AnnData
38
- Annotated data object containing expression matrix and metadata.
39
- dataset : str, default='ST'
40
- Dataset identifier.
41
- spatial_key : str, default='X_spatial'
42
- Key in adata.obsm containing spatial coordinates (n_obs, 2).
43
- label_key : str, default='cell_type'
44
- Key in adata.obs containing cell type annotations.
45
- leaf_size : int, default=10
46
- Leaf size parameter for KDTree construction. Larger values reduce tree depth
47
- but increase computation per query.
48
- build_gene_index : bool, default=False
49
- If True, constructs SCFind index by compressing original data to binary format to save memory.
50
- If False, uses original expression matrix from adata.X directly.
51
- feature_name : str, default='gene'
52
- Column name in adata.var containing feature identifiers.
53
- if_lognorm : bool, default=True
54
- If True, applies log1p transformation after library size normalization.
55
- Set to False if expression data is already normalized and no more transformation is required.
56
- if_normalize_spatial_coord : bool, default=True
57
- If True, normalizes spatial coordinates so mean nearest neighbor distance equals 1.
58
- This makes max_dist parameter interpretable as "number of cell diameters."
59
- Set to False if original spatial units (e.g., micrometers) are required and
60
- should be preserved for downstream analysis.
61
-
62
- Notes
63
- -----
64
- When if_normalize_spatial_coord=True, the max_dist parameter in query functions
65
- represents relative spatial scale (in units of mean nearest neighbor distance).
66
- When if_normalize_spatial_coord=False, max_dist uses original coordinate units.
67
34
  """
68
35
  def __init__(
69
36
  self,
@@ -77,6 +44,42 @@ class spatial_query:
77
44
  if_lognorm: bool = True,
78
45
  if_normalize_spatial_coord: bool = True
79
46
  ):
47
+ """
48
+ Initialize spatial_query object.
49
+
50
+ Parameters
51
+ ----------
52
+ adata : AnnData
53
+ Annotated data object containing expression matrix and metadata.
54
+ dataset : str, default='ST'
55
+ Dataset identifier.
56
+ spatial_key : str, default='X_spatial'
57
+ Key in adata.obsm containing spatial coordinates (n_obs, 2).
58
+ label_key : str, default='cell_type'
59
+ Key in adata.obs containing cell type annotations.
60
+ leaf_size : int, default=10
61
+ Leaf size parameter for KDTree construction. Larger values reduce tree depth
62
+ but increase computation per query.
63
+ build_gene_index : bool, default=False
64
+ If True, constructs SCFind index by compressing original data to binary format to save memory.
65
+ If False, uses original expression matrix from adata.X directly.
66
+ feature_name : str, default='gene'
67
+ Column name in adata.var containing feature identifiers.
68
+ if_lognorm : bool, default=True
69
+ If True, applies log1p transformation after library size normalization.
70
+ Set to False if expression data is already normalized and no more transformation is required.
71
+ if_normalize_spatial_coord : bool, default=True
72
+ If True, normalizes spatial coordinates so mean nearest neighbor distance equals 1.
73
+ This makes max_dist parameter interpretable as "number of cell diameters."
74
+ Set to False if original spatial units (e.g., micrometers) are required and
75
+ should be preserved for downstream analysis.
76
+
77
+ Notes
78
+ -----
79
+ When if_normalize_spatial_coord=True, the max_dist parameter in query functions
80
+ represents relative spatial scale (in units of mean nearest neighbor distance).
81
+ When if_normalize_spatial_coord=False, max_dist uses original coordinate units.
82
+ """
80
83
  if spatial_key not in adata.obsm.keys() or label_key not in adata.obs.keys():
81
84
  raise ValueError(f"The Anndata object must contain {spatial_key} in obsm and {label_key} in obs.")
82
85
 
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.4
2
+ Name: SpatialQuery
3
+ Version: 0.0.4
4
+ Summary: Spatial query tools for analyzing spatial transcriptomics data
5
+ Author-email: Shaokun An <shan12@bwh.harvard.edu>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ShaokunAn/Spatial-Query
8
+ Project-URL: Documentation, https://spatial-query.readthedocs.io
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: numpy>=1.23.0
19
+ Requires-Dist: anndata>=0.8.0
20
+ Requires-Dist: pandas>=2.0.3
21
+ Requires-Dist: scipy>=1.10.0
22
+ Requires-Dist: matplotlib>=3.7.5
23
+ Requires-Dist: scikit-learn>=1.3.2
24
+ Requires-Dist: scanpy>=1.9.5
25
+ Requires-Dist: statsmodels>=0.14.0
26
+ Requires-Dist: seaborn>=0.13.2
27
+ Requires-Dist: mlxtend>=0.23.1
28
+ Requires-Dist: tqdm>=4.60.0
29
+ Requires-Dist: zarr>=2.14.0
30
+ Provides-Extra: docs
31
+ Requires-Dist: sphinx>=5.3; extra == "docs"
32
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
33
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
34
+ Requires-Dist: sphinx-copybutton; extra == "docs"
35
+ Requires-Dist: myst-parser; extra == "docs"
36
+ Dynamic: license-file
37
+
38
+ # SpatialQuery
39
+
40
+ 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).
41
+
42
+ 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.
43
+
44
+ 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.
45
+
46
+ Key capabilities include:
47
+
48
+ - **Spatial motif discovery**: Identify frequent cell type patterns in local neighborhoods
49
+ - **Motif enrichment analysis**: Statistically test whether motifs occur more than expected
50
+ - **Differential motif analysis**: Compare spatial compositions across conditions
51
+ - **Motif-associated differential expression**: Find DE genes linked to specific motifs
52
+ - **Cross-cell gene-gene covariation**: Detect spatially dependent intercellular gene correlations
53
+ - **Multi-FOV support**: Pool and compare results across multiple tissue sections or samples
54
+
55
+ ## Installation
56
+
57
+ ```bash
58
+ pip install SpatialQuery
59
+ ```
60
+
61
+ ## Documentation
62
+
63
+ Full documentation, tutorials, and API reference: **[https://spatialquery.readthedocs.io/en/latest/](https://spatialquery.readthedocs.io/en/latest/)**
64
+
65
+ ## Quick Start
66
+
67
+ ```python
68
+ from SpatialQuery import spatial_query
69
+
70
+ # Single FOV analysis
71
+ sq = spatial_query(adata, spatial_key="X_spatial", label_key="cell_type", feature_name="gene")
72
+ enrich_motif = sq.motif_enrichment_dist(ct="T_cell", max_dist=10, min_support=0.5)
73
+ ```
74
+
75
+ ```python
76
+ from SpatialQuery import spatial_query_multi
77
+
78
+ # Multi-FOV analysis
79
+ spm = spatial_query_multi(adatas=adatas, datasets=datasets,
80
+ spatial_key="X_spatial", label_key="cell_type", feature_name="gene")
81
+ enrich_motif = spm.motif_enrichment_dist(ct="T_cell", dataset="healthy", max_dist=10, min_support=0.5)
82
+ ```
83
+
84
+ ## License
85
+
86
+ MIT
87
+
88
+ ## Contact
89
+
90
+ - **Author**: Shaokun An
91
+ - **Email**: shaokunan1@gmail.com
92
+ - **GitHub**: [ShaokunAn](https://github.com/ShaokunAn)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "SpatialQuery"
7
- version = "0.0.3"
7
+ version = "0.0.4"
8
8
  description = "Spatial query tools for analyzing spatial transcriptomics data"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -37,6 +37,7 @@ dependencies = [
37
37
 
38
38
  [project.urls]
39
39
  Homepage = "https://github.com/ShaokunAn/Spatial-Query"
40
+ Documentation = "https://spatial-query.readthedocs.io"
40
41
 
41
42
  [project.optional-dependencies]
42
43
  docs = [