SpatialQuery 0.0.2__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 (46) hide show
  1. spatialquery-0.0.4/MANIFEST.in +6 -0
  2. spatialquery-0.0.4/PKG-INFO +92 -0
  3. spatialquery-0.0.4/README.md +55 -0
  4. spatialquery-0.0.4/SpatialQuery/__init__.py +26 -0
  5. spatialquery-0.0.4/SpatialQuery/plotting.py +1267 -0
  6. spatialquery-0.0.4/SpatialQuery/scfind4sp/__init__.py +3 -0
  7. spatialquery-0.0.4/SpatialQuery/scfind4sp/core_methods.py +1307 -0
  8. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/EliasFano.h +180 -0
  9. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/QueryScore.cpp +179 -0
  10. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/QueryScore.h +32 -0
  11. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/Serialization.h +72 -0
  12. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/__init__.py +1 -0
  13. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/const.h +7 -0
  14. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/eliasFano.cpp +1657 -0
  15. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/fp_growth.cpp +245 -0
  16. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/fp_growth.h +41 -0
  17. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/serialization.cpp +381 -0
  18. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/typedef.h +418 -0
  19. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/utils.cpp +354 -0
  20. spatialquery-0.0.4/SpatialQuery/scfind4sp/cpp_src/utils.h +72 -0
  21. spatialquery-0.0.4/SpatialQuery/spatial_differential_pattern.py +550 -0
  22. spatialquery-0.0.4/SpatialQuery/spatial_gene_covarying.py +4941 -0
  23. spatialquery-0.0.4/SpatialQuery/spatial_query.py +1694 -0
  24. spatialquery-0.0.4/SpatialQuery/spatial_query_multiple_fov.py +1826 -0
  25. spatialquery-0.0.4/SpatialQuery/spatial_utils.py +858 -0
  26. {spatialquery-0.0.2 → spatialquery-0.0.4}/SpatialQuery/utils.py +29 -24
  27. spatialquery-0.0.4/SpatialQuery.egg-info/PKG-INFO +92 -0
  28. spatialquery-0.0.4/SpatialQuery.egg-info/SOURCES.txt +33 -0
  29. spatialquery-0.0.4/SpatialQuery.egg-info/requires.txt +19 -0
  30. spatialquery-0.0.4/SpatialQuery.egg-info/top_level.txt +2 -0
  31. spatialquery-0.0.4/pyproject.toml +53 -0
  32. spatialquery-0.0.4/setup.py +28 -0
  33. spatialquery-0.0.2/MANIFEST.in +0 -3
  34. spatialquery-0.0.2/PKG-INFO +0 -58
  35. spatialquery-0.0.2/README.md +0 -24
  36. spatialquery-0.0.2/SpatialQuery/__init__.py +0 -3
  37. spatialquery-0.0.2/SpatialQuery/spatial_query.py +0 -1339
  38. spatialquery-0.0.2/SpatialQuery/spatial_query_multiple_fov.py +0 -1116
  39. spatialquery-0.0.2/SpatialQuery.egg-info/PKG-INFO +0 -58
  40. spatialquery-0.0.2/SpatialQuery.egg-info/SOURCES.txt +0 -13
  41. spatialquery-0.0.2/SpatialQuery.egg-info/requires.txt +0 -10
  42. spatialquery-0.0.2/SpatialQuery.egg-info/top_level.txt +0 -1
  43. spatialquery-0.0.2/setup.py +0 -33
  44. {spatialquery-0.0.2 → spatialquery-0.0.4}/LICENSE +0 -0
  45. {spatialquery-0.0.2 → spatialquery-0.0.4}/SpatialQuery.egg-info/dependency_links.txt +0 -0
  46. {spatialquery-0.0.2 → spatialquery-0.0.4}/setup.cfg +0 -0
@@ -0,0 +1,6 @@
1
+ include README.md
2
+ include LICENSE
3
+ include setup.py
4
+ include pyproject.toml
5
+
6
+ recursive-include SpatialQuery/scfind4sp/cpp_src *.cpp *.h
@@ -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)
@@ -0,0 +1,26 @@
1
+ from .spatial_query import spatial_query, interactive_motif
2
+ from .spatial_query_multiple_fov import spatial_query_multi
3
+ from .utils import maximal_patterns, retrieve_niche_pattern_freq, plot_niche_pattern_freq
4
+ from .scfind4sp import SCFind
5
+ from .plotting import (
6
+ plot_fov,
7
+ plot_motif_grid,
8
+ plot_motif_rand,
9
+ plot_motif_celltype,
10
+ plot_all_center_motif
11
+ )
12
+
13
+ __all__ = [
14
+ 'spatial_query',
15
+ 'spatial_query_multi',
16
+ 'maximal_patterns',
17
+ 'retrieve_niche_pattern_freq',
18
+ 'plot_niche_pattern_freq',
19
+ 'SCFind',
20
+ 'plot_fov',
21
+ 'plot_motif_grid',
22
+ 'plot_motif_rand',
23
+ 'plot_motif_celltype',
24
+ 'plot_all_center_motif',
25
+ 'interactive_motif'
26
+ ]