Skip to main content

Spatial-omics pipeline and analysis

Project description

sopa_logo

Spatial omics pipeline and analysis

PyPI Downloads Docs Build License uv Ruff

Built on top of SpatialData, Sopa enables processing and analyses of spatial omics data with single-cell resolution (spatial transcriptomics or multiplex imaging data) using a standard data structure and output. We currently support the following technologies: Xenium, Visium HD, MERSCOPE, CosMx, PhenoCycler, MACSima, Molecular Cartography, and others. Sopa was designed for generability and low memory consumption on large images (scales to 1TB+ images).

[!NOTE] You may also be interested in Novae, developed by the same authors, now published in Nature Methods 🎉

Documentation

Check Sopa's documentation to get started. It contains installation explanations, CLI/API details, and tutorials.

Overview

The following illustration describes the main steps of sopa:

sopa_overview

Installation

Sopa can be installed from PyPI on all OS, for any Python version >=3.11. On a new environment, run the following command:

pip install sopa

[!NOTE] See this installation section for more details about extras and other installations modes.

Features

Sopa comes in four different flavours, each corresponding to a different use case:

  • API: use directly sopa as a Python package for complete flexibility and customization.
  • Snakemake pipeline: choose a config, and run our pipeline on your spatial data in a couple of minutes.
  • nf-core/sopa: run Sopa with Nextflow (see this repo and the corresponding usage guide). Great for Docker users.
  • CLI: use our command-line-interface for prototyping quickly your own pipeline (advanced users).

API

Below is a minimal example of API usage. For a complete API description, please refer to the documentation.

import sopa

sdata = sopa.io.xenium("path/to/data") # reading Xenium data

sopa.make_image_patches(sdata) # creating overlapping patches
sopa.segmentation.cellpose(sdata, "DAPI", diameter=30) # running cellpose segmentation
sopa.aggregate(sdata) # counting the transcripts inside the cells

Snakemake pipeline

Clone our repository, choose a config here (or create your own), and execute our pipeline locally or on a high-performance cluster:

git clone https://github.com/gustaveroussy/sopa.git
cd sopa/workflow
snakemake --configfile=/path/to/yaml_config --config data_path=/path/to/data_directory --cores 1 --use-conda

For more details on snakemake configuration and how to properly setup your environments, please refer to the documentation.

CLI

Below are examples of commands that can be run with the sopa CLI. For a complete description of the CLI, please refer to the documentation.

> sopa --help # show command names and arguments
> sopa convert merscope_directory --technology merscope # read some data
> sopa patchify image merscope_directory.zarr # make patches for low-memory segmentation
> sopa segmentation cellpose merscope_directory.zarr --diameter 60 --channels DAPI # segmentation
> sopa resolve cellpose merscope_directory.zarr # resolve segmentation conflicts at boundaries
> sopa aggregate merscope_directory.zarr --average-intensities # transcripts/channels aggregation
> sopa explorer write merscope_directory.zarr # convert for interactive vizualisation

Cite us

Our article is published in Nature Communications. You can cite Sopa as below:

Blampey, Q., Mulder, K., Gardet, M. et al. Sopa: a technology-invariant pipeline for analyses of image-based spatial omics.
Nat Commun 15, 4981 (2024). https://doi.org/10.1038/s41467-024-48981-z

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

sopa-2.2.3.tar.gz (138.4 kB view details)

Uploaded Source

Built Distribution

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

sopa-2.2.3-py3-none-any.whl (182.6 kB view details)

Uploaded Python 3

File details

Details for the file sopa-2.2.3.tar.gz.

File metadata

  • Download URL: sopa-2.2.3.tar.gz
  • Upload date:
  • Size: 138.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.20

File hashes

Hashes for sopa-2.2.3.tar.gz
Algorithm Hash digest
SHA256 72b8a2ee2e9e49a651935c80b9903ece8917fedbddd627539c52a2ea60673e01
MD5 95f9a2e01e6d9e48b70ceebf5d2e8d63
BLAKE2b-256 2b9b92f0a10d8910e5156c4db95ad1e018158c33b1bb5efba9c1a80546de5144

See more details on using hashes here.

File details

Details for the file sopa-2.2.3-py3-none-any.whl.

File metadata

  • Download URL: sopa-2.2.3-py3-none-any.whl
  • Upload date:
  • Size: 182.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.20

File hashes

Hashes for sopa-2.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5b5879ce5f5bafbaf8a953771d19e05beb6c7a37984fe147fadd4a11482f4f47
MD5 dd299ae930f6704a04ea4e4f67eca637
BLAKE2b-256 6ff41b4d5e703569f29b585f4256cb0e36f291771e6147c740b0f0236643c841

See more details on using hashes here.

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