Skip to main content

Standardized spatial statistics tools for computational biology

Project description

SpatialCore

Standardized spatial statistics for computational biology.

License Python PyPI Code Style


🎯 The Mission

The Problem

Tools for spatial biology analysis are fragmented. Implementations packages and complex functions often differ between languages (R vs Python) and even between packages, making reproducibility difficult and benchmarking impossible. We believe simple statistical tools solve many of the core problems of spatial biology, and we have desinged them to be intuative, easy to use, and scaleable for millions of cells.

The Solution

SpatialCore serves as a package for computational biologists, by computational biologists. It provides robust, standardized implementations of core spatial statistics that ensure identical results across platforms, wrapping high-performance libraries where available.

The Goal

To make spatial analysis engineering boring, so you can focus on the exciting biology. Standardized. Scalable. Reproducible.


📦 Installation

Recommended: Conda/Mamba Environment

For the best experience, we recommend using a conda or mamba environment:

# Create environment with Python 3.11
mamba create -n spatialcore python=3.11
mamba activate spatialcore

# Install SpatialCore
pip install spatialcore

This installs all core Python dependencies including CellTypist for custom model training for cell type annotation.

Run upgrade to get the latest modules, features, and fixes

# Activate environment
mamba activate spatialcore

# Upgrade
pip install --upgrade spatialcore

R Requirements

SpatialCore uses R for certain operations that are statistically optimized or perform better in R. The r_bridge module handles R integration via subprocess (no rpy2 required).

Install R packages in your environment:

# If using conda/mamba (recommended)
mamba install -c conda-forge r-base r-sf r-concaveman r-dplyr r-purrr r-jsonlite

# If using system R (Linux/macOS)
sudo apt-get install r-base  # Ubuntu/Debian
R -e "install.packages(c('sf', 'concaveman', 'dplyr', 'purrr', 'jsonlite'), repos='https://cloud.r-project.org/')"

Verify R is configured correctly:

from spatialcore.r_bridge import check_r_available, get_r_version
print(check_r_available())  # True
print(get_r_version())      # R version 4.x.x

How r_bridge Works

The r_bridge automatically detects your environment:

Environment R Execution Method
Conda/Mamba mamba run -n env_name Rscript ...
System R Rscript directly

No manual configuration needed - it just works.


🚀 Quick Start

import spatialcore

# Check what's available in your installation
spatialcore.print_info()
# SpatialCore v0.1.3
# Available modules: core, annotation

📖 See the full documentation: for modules, examples, and benchmarks mcap91.github.io/SpatialCore


🧩 Modules & Features

Module Status Features
spatialcore.core ✅ Available Logging, metadata tracking, caching utilities
spatialcore.annotation ✅ Available CellTypist wrappers, custom model training, benchmarking
spatialcore.spatial 🔜 Coming soon Moran's I, Lee's L, neighborhoods, niches, domains
spatialcore.nmf 🔜 Coming soon Spatial non-negative matrix factorization
spatialcore.diffusion 🔜 Coming soon Diffusion maps, pseudotime analysis

📚 Terminology

We strictly define our spatial units to ensure clarity:

Term Definition
Neighborhood The immediate spatial vicinity of a cell (e.g., k-Nearest Neighbors or fixed radius).
Niche A functional microenvironment defined by a specific composition of cell types (e.g., "Tumor-immune border").
Domain A macroscopic, continuous tissue region with shared structural characteristics (e.g., "Cortex", "Medulla").

🤝 Ecosystem Integration

SpatialCore is designed to play nice with others. It fits seamlessly into the existing Python spatial biology stack:

  • Scanpy: The backbone for single-cell analysis.
  • Squidpy: Advanced spatial omics analysis.
  • Seurat: Direct R interoperability for teams working across languages.

⚖️ Philosophy

This package is for computational biologists, by computational biologists.

  • Reproducibility: Same inputs = Same outputs. Period.
  • Scalability: Built for the era of millions of cells (Xenium/CosMx).
  • Transparency: Thin wrappers, not black boxes. We verify, we don't obfuscate.
  • Documentation: Clear docstrings with academic references.

What we are NOT:

  • Inventing new, unproven math.
  • Replacing Scanpy, Seurat, or other methods.

📝 Citation

If SpatialCore aids your research, please cite:

@software{spatialcore,
  title = {SpatialCore: Standardized spatial statistics for computational biology},
  url = {https://github.com/mcap91/SpatialCore},
  license = {Apache-2.0}
}

License

Apache License 2.0

The SpatialCore name and trademarks are reserved to ensure the community can rely on the "Standardized" quality of the core library. You are free to use, modify, and distribute the code, including for commercial use.

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

spatialcore-0.2.3.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

spatialcore-0.2.3-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file spatialcore-0.2.3.tar.gz.

File metadata

  • Download URL: spatialcore-0.2.3.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spatialcore-0.2.3.tar.gz
Algorithm Hash digest
SHA256 2ac42523563fc79a942157e4eb84026eca4e959c235a1b9e19f6344626d7e9c9
MD5 1776ac610e6697dd1816b586e0926ce7
BLAKE2b-256 887c0cbc2bb138d841dcc2ee0203e98fa316875ae1e33fd3a08b9e849d52a5c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for spatialcore-0.2.3.tar.gz:

Publisher: publish-pypi.yml on mcap91/SpatialCore

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

File details

Details for the file spatialcore-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: spatialcore-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spatialcore-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b42339d5301c7a28c8f82288d91461641297bf6fcab3f1289de45b5774660b0
MD5 df6008a022daa5cd1db8c54fec4cba88
BLAKE2b-256 8ecc01aa97411d4c0f86a6b14087608a3398a9b885924370ff9b3bf6644e262a

See more details on using hashes here.

Provenance

The following attestation bundles were made for spatialcore-0.2.3-py3-none-any.whl:

Publisher: publish-pypi.yml on mcap91/SpatialCore

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