Skip to main content

Accurate and efficient spot detection for microscopy data

Project description

License: BSD-3 PyPI Python Version tests PyPI - Downloads

Logo

Spotiflow - accurate and efficient spot detection with stereographic flow

Spotiflow is a deep learning-based, threshold-agnostic, and subpixel-accurate spot detection method for fluorescence microscopy. It is primarily developed for spatial transcriptomics workflows that require transcript detection in large, multiplexed FISH-images, although it can also be used to detect spot-like structures in general fluorescence microscopy images. A more detailed description of the method can be found in our paper.

Overview

The documentation of the software can be found here.

Installation

Create and activate a fresh conda environment (we currently support Python 3.9 to 3.11):

conda create -n spotiflow python=3.9
conda activate spotiflow

For Linux/Windows with a CUDA device, install PyTorch using conda/mamba (one might need to change the cuda version accordingly):

conda install pytorch torchvision pytorch-cuda=11.8 -c pytorch -c nvidia # Might need to change the cuda version accordingly

Note (for MacOS users): if using MacOS, there is a known bug causing the installation of PyTorch with conda to sometimes break OpenMP. You can avoid installing PyTorch and let spotiflow install it automatically via pip.

Note (for Windows users): if using Windows, please install the latest Build Tools for Visual Studio (make sure to select the C++ build tools during installation) before proceeding to install Spotiflow.

Finally, install spotiflow:

pip install spotiflow

Usage

Training

See the example training script or the example notebook for an example of training. For finetuning an already pretrained model, please refer to the finetuning example notebook.

Inference (CLI)

You can use the CLI to run inference on an image or folder containing several images. To do that, you can use the following command:

spotiflow-predict PATH

where PATH can be either an image or a folder. By default, the command will use the general pretrained model. You can specify a different model by using the --pretrained-model flag. Moreover, spots are saved to a subfolder spotiflow_results created inside the input folder (this can be changed with the --out-dir flag). For more information, please refer to the help message of the CLI ($ spotiflow-predict -h).

Inference (API)

The API allows detecting spots in a new image in a few lines of code! Please check the corresponding example notebook and the documentation for a more in-depth explanation.

from spotiflow.model import Spotiflow
from spotiflow.sample_data import test_image_hybiss_2d

# Load sample image
img = test_image_hybiss_2d()
# Or any other image
# img = tifffile.imread("myimage.tif")

# Load a pretrained model
model = Spotiflow.from_pretrained("general")
# Or load your own trained model from folder
# model = Spotiflow.from_folder("./mymodel")

# Predict
points, details = model.predict(img) # points contains the coordinates of the detected spots, the attributes 'heatmap' and 'flow' of `details` contains the predicted full resolution heatmap and the prediction of the stereographic flow respectively (access them by `details.heatmap` or `details.flow`).

Napari plugin

Our napari plugin allows detecting spots directly with an easy-to-use UI. See napari-spotiflow for more information.

For developers

We are open to contributions, and we indeed very much encourage them! Make sure that existing tests pass before submitting a PR, as well as adding new tests/updating the documentation accordingly for new features.

Testing

First, clone the repository:

git clone git@github.com:weigertlab/spotiflow.git

Then install the testing extras:

cd spotiflow
pip install -e ".[testing]"

then run the tests:

pytest -v --color=yes --cov=spotiflow

Docs

Install the docs extras:

pip install -e ".[docs]"

and then cd into the docs folder of the cloned repository and build them:

cd spotiflow/docs
sphinx-build -M html source build

How to cite

If you use this code in your research, please cite the Spotiflow paper (currently preprint):

@article {dominguezmantes24,
	author = {Albert Dominguez Mantes and Antonio Herrera and Irina Khven and Anjalie Schlaeppi and Eftychia Kyriacou and Georgios Tsissios and Can Aztekin and Joachim Ligner and Gioele La Manno and Martin Weigert},
	title = {Spotiflow: accurate and efficient spot detection for imaging-based spatial transcriptomics with stereographic flow regression},
	elocation-id = {2024.02.01.578426},
	year = {2024},
	doi = {10.1101/2024.02.01.578426},
	publisher = {Cold Spring Harbor Laboratory},
 URL = {https://www.biorxiv.org/content/early/2024/02/05/2024.02.01.578426},
	eprint = {https://www.biorxiv.org/content/early/2024/02/05/2024.02.01.578426.full.pdf},
	journal = {bioRxiv}
}

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

spotiflow-0.2.0.tar.gz (10.4 MB view details)

Uploaded Source

Built Distributions

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

spotiflow-0.2.0-cp311-cp311-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11Windows x86-64

spotiflow-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

spotiflow-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

spotiflow-0.2.0-cp310-cp310-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.10Windows x86-64

spotiflow-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

spotiflow-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

spotiflow-0.2.0-cp39-cp39-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9Windows x86-64

spotiflow-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

spotiflow-0.2.0-cp39-cp39-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file spotiflow-0.2.0.tar.gz.

File metadata

  • Download URL: spotiflow-0.2.0.tar.gz
  • Upload date:
  • Size: 10.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for spotiflow-0.2.0.tar.gz
Algorithm Hash digest
SHA256 adc779b1d52adc5b6137de2a825231a162899b4cc9c1bb9f5df1f4dcef52347e
MD5 ec02f2f40096210567b98cc498243edc
BLAKE2b-256 14de8fa27700208891410820e31609fa41817a3f6ac445024403088330e42156

See more details on using hashes here.

File details

Details for the file spotiflow-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: spotiflow-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for spotiflow-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 182d2eeaa9cffe5f5f2efba3d7148c3de7ec8894383d7d3f8e6cda6cc6469d71
MD5 23fb39cac73d3bcb6bd5b01b2cc35f83
BLAKE2b-256 92516d9a40e4bf7654cfaa103f9baa7e64b618820769d400d4d1c8fca371121b

See more details on using hashes here.

File details

Details for the file spotiflow-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for spotiflow-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 73fe8d1a2ab78d952543f582002ab99c66a334b487929a6fc78009eef7475d0e
MD5 6ff708f4d35a433b65e11ff0bfd511bc
BLAKE2b-256 39751c3621b4a0aeeb33e3fecd2c8ac6c92f76dc7e4c6837b1ec50c9136afb99

See more details on using hashes here.

File details

Details for the file spotiflow-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spotiflow-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92c63c7cd2f77044b102585fc4ab93926cd05302ff57bb35d1e2c1cce1486be4
MD5 b93d956a735e83f2486bfa4b075d5bd6
BLAKE2b-256 21d5d919d35e885f51eb244e20bee70760b061f853a5ccfcab347a7bd6d50083

See more details on using hashes here.

File details

Details for the file spotiflow-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: spotiflow-0.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for spotiflow-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7b7758d257ac18f7c34c07b69118ccc4fc064bd8a01e492809f2960790e17a8c
MD5 b620ecc20285d578d9898c76ec305618
BLAKE2b-256 3a4d1d7130b3f6b5e13d77d6c4d15c294ac41697756f872b8c6390fecdb823f5

See more details on using hashes here.

File details

Details for the file spotiflow-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for spotiflow-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 191fb33b6fd6ffec6e7bc061e629c3c20b85df503e29d1ecdcc75a7a62e85d7d
MD5 650f2a59e7aad6af364ad193f8f6ceb5
BLAKE2b-256 5ff86058f73aa0dd371e322a9c8563b94bd6542ec1fc0aa5dcb8ae86aa22379f

See more details on using hashes here.

File details

Details for the file spotiflow-0.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spotiflow-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25c301e4ce14c6fb4eb5a833bafd76a89c81ee04f880e6d3768d10e8801b5c7d
MD5 a1d5445a9107c4074790a3e5ec556522
BLAKE2b-256 a408898d9bf3dbb777841dc676f56feafa959d5fe0402b6baca330161affec93

See more details on using hashes here.

File details

Details for the file spotiflow-0.2.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: spotiflow-0.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for spotiflow-0.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 244a033a0defa03e9600162e576d6c2103c845452105fd9f72d4f542d8e0ae16
MD5 259f9b2080c27917dd9867fea3ef7894
BLAKE2b-256 d4172452039d79105ea4d08edd723da2ff4898455de5cda6f70b2c81dbd661dc

See more details on using hashes here.

File details

Details for the file spotiflow-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for spotiflow-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 24af709af410108c82c0142cc5375a5ddff1b2613fa0cffac169da42bc179730
MD5 7a7251eb8bc8b6b7bde31f46573b54b9
BLAKE2b-256 22c85f63e5e6c78a703fb0c26ef78bb834b727974f43ee620cabd6ba731e722e

See more details on using hashes here.

File details

Details for the file spotiflow-0.2.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spotiflow-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6bb65f60aa8db7e2572f4bde8ca2ebbc729c6be247933eed834af216a0b89b1d
MD5 5403964050627462c0b8457730398f35
BLAKE2b-256 eca7812808010b0a92016d1ae6947a6fb8d71e71350e9a1fe4d8024838f20414

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