Skip to main content

SIGMA · Spatial interface metabolic programmes

PyPI

SIGMA identifies metabolic programmes around tissue interfaces. It combines spatial mass spectra, tissue coordinates and pathological or weak anchors to describe where signals change, how far they extend and how they vary along an interface. Matched spatial RNA can provide an auxiliary representation and cellular context.

Installation

Use Python 3.10 or later in a separate environment. Python 3.11 is recommended for this release. The distribution is sigma-omics; the import name is sigma_spatial.

python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install --prefer-binary "sigma-omics==0.3.2"
python -c "import sigma_spatial; print(sigma_spatial.__version__)"

On Windows, activate with .venv\Scripts\activate. To update an existing installation:

python -m pip install --upgrade --prefer-binary "sigma-omics==0.3.2"
python -m pip check

Restart the Python or notebook session after upgrading. PyTorch and PyTorch Geometric are installed as dependencies; CPU execution is sufficient. For CUDA, install the PyTorch build appropriate for your system before installing SIGMA.

What changed in 0.3.2

  • Continuous distance to an interpolated interface is available through distance_mode="continuous".
  • Zero-distance positions retain their explicitly recorded tissue side.
  • Upgrading a saved coordinate also updates existing d_signed and d_abs aliases while preserving the old columns.
  • Tied near/far thresholds no longer test overlapping groups. Unavailable programme comparisons return NaN and record n_overlap.

The original SIGMA model is unchanged. distance_mode="legacy" remains the default for historical reproducibility. Select continuous distance explicitly for new analyses.

Quick start

Prepare an AnnData object with MSI intensities in X, spatial coordinates in obsm["spatial"], and anchors in obs["sigma_anchor"] (1: inside/tumour, 0: outside/non-tumour, NaN: unknown). The paired workflow also requires an aligned RNA representation in obsm["X_harmony"], in the same spot order.

import scanpy as sc
from sigma_spatial import run_sigma

adata = sc.read_h5ad("sample.h5ad")
result = run_sigma(
    adata,
    anchor_key="sigma_anchor",
    representation_key="X_harmony",
    distance_mode="continuous",
    random_state=0,
)
result.write_h5ad("sample_sigma.h5ad")

For explicitly anchored MSI-only data, use run_sigma_weak_anchor, which omits the RNA loss. It accepts the same distance_mode option. Continuous distance requires the unmodified probability-threshold mask (boundary_mode="legacy"); it is not compatible with morphological mask cleanup.

Upgrade an existing coordinate

An existing fitted probability field can be re-expressed without retraining:

from sigma_spatial import update_interface_coordinate

updated = update_interface_coordinate(result, copy=True)
updated.write_h5ad("sample_sigma_continuous.h5ad")

This uses obs["sigma_region_probability"] and preserves previous coordinate columns under the _before_continuous suffix. It does not recalculate existing ion rankings or programme memberships. Recompute downstream analyses before interpreting results under the new coordinate.

Side-specific near/far comparisons

from sigma_spatial import side_near_far_statistics

# program_scores maps programme names to arrays in the same spot order as updated.
statistics = side_near_far_statistics(
    program_scores,
    updated.obs["sigma_d_signed"].to_numpy(),
    inside_mask=updated.obs["sigma_inside"].to_numpy(),
    side_names={"negative": "Tumour", "positive": "Stroma"},
)

Negative distance denotes the inside, positive distance the outside. An exact zero is a location, not a side label. If inside_mask is omitted, zero-distance positions are excluded with a warning. Distances use the units of the supplied coordinates; they are not automatically micrometres or spot spacings.

Outputs and interpretation

SIGMA stores the fitted tissue field, interface coordinate, ranked ions and programme summaries in AnnData and downstream tables. The continuous contour is stored in uns["sigma_coordinate"]["segments"]; sigma_boundary remains the neighbour-based display mask. Raw data and manuscript fitting caches are not bundled.

Use independent measurements or specimens to validate biological interpretations. RNA used in fitting provides context rather than independent validation of the same model. A static signal's spatial extent is not a physical diffusion length or an invasion distance.

Documentation and source

The source distribution includes docs/installation.md, docs/continuous_distance.md, docs/output_schema.md, examples, regression tests and CHANGELOG.md for this release.

Metadata

Release files for sigma-omics 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sigma-omics 0.3.2
File Size Uploaded Provenance Actions
sigma_omics-0.3.2.tar.gz 84.8 kB Without provenance Details for sigma_omics-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sigma-omics 0.3.2
File Interpreter ABI Platform Actions
sigma_omics-0.3.2-py3-none-any.whl Python 3 none any Details for sigma_omics-0.3.2-py3-none-any.whl

Total release size: 159.9 kB

Release files / sigma_omics-0.3.2.tar.gz

Download URL sigma_omics-0.3.2.tar.gz
Size 84.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9665475825d63c64fcc10971056dba8eb417d27c4e19c8102ceedc7fe8d1c534
BLAKE2b-256 checksum
How to use checksums
ec440675bdae0ac6ecea3167a19aac9ad73b7536107bf0c453b5a9547c1dd5d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.13

Release files / sigma_omics-0.3.2-py3-none-any.whl

Download URL sigma_omics-0.3.2-py3-none-any.whl
Size 75.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b3bba3e725c3f4ed4f73963d0f60d84b5255062371183d7a9493496a7fb6717
BLAKE2b-256 checksum
How to use checksums
7420d0c6228762701a36f4de457b16509ca68243e25a763a1f27979775f991dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.13

Security for sigma-omics 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page