spaCR
Spatial phenotype analysis of CRISPR-Cas9 screens.
The spatial organization of organelles and proteins within cells constitutes a key level of functional regulation. In the context of infectious disease, the spatial relationships between host cell structures and intracellular pathogens are critical to understanding host clearance mechanisms and how pathogens evade them. spaCR is a Python toolkit for generating single-cell image data for deep-learning sub-cellular / cellular phenotypic classification from pooled genetic CRISPR-Cas9 screens. It provides a flexible toolset to extract single-cell images and measurements from high-content cell painting experiments, train deep-learning models to classify cellular phenotypes, simulate CRISPR-Cas9 imaging screens, and analyze pooled-screen data end to end.
📖 Full documentation: https://einarolafsson.github.io/spacr/
Features
Generate Masks — Cellpose masks for cells, nuclei, pathogens and organelles.
Object Measurements — scikit-image regionprops, intensity percentiles, Shannon entropy, Pearson’s and Manders’ correlations, homogeneity, radial distribution. Saved to a SQL database in object-level tables.
Crop Images — Save cropped objects (cells, nuclei, pathogen, cytoplasm) as PNGs alongside their DB rows.
Train CNNs or Transformers — PyTorch training loops for single-object classification.
Manual Annotation — Grid-based single-cell annotation UI that writes labels straight to the measurements DB.
Finetune Cellpose Models — Refine pretrained Cellpose weights against your own hand-drawn masks.
Timelapse Data Support — Track objects across timepoints; every module respects the T filename dimension.
Simulations — Generate synthetic phenotype screens with configurable perturbation effects.
Sequencing — Map FASTQ reads to row / column / gRNA barcodes for pooled-screen genotype-phenotype linking.
Analysis Suite — UMAP, ML/DL classification, regression, recruitment, activation, plaque, Ca²⁺ oscillation.
Overview and data organization of spaCR.
a. Schematic workflow of the spaCR pipeline for pooled image-based CRISPR screens. Microscopy images (TIFF, LIF, CZI, NDI) and sequencing reads (FASTQ) are used as inputs (black). The main modules (teal) are: (1) Mask — generates object masks for cells, nuclei, pathogens, and cytoplasm; (2) Measure — extracts object-level features and crops object images, storing quantitative data in an SQL database; (3) Classify — applies ML (e.g., XGBoost) or DL (e.g., PyTorch) models to classify objects, summarising results as well-level classification scores; (4) Map Barcodes — extracts and maps row, column, and gRNA barcodes from sequencing data to corresponding wells; (5) Regression — estimates gRNA effect sizes and gene scores via multiple linear regression using well-level summary statistics. b. Downstream submodules available for extended analyses at each stage. c. Output folder structure for each module, including locations for raw and processed images, masks, object-level measurements, datasets, and results. d. List of all spaCR package modules.
Quickstart
pip install spacr
spacr # launches the Qt GUI
Installation
Linux is the recommended platform. Windows users are encouraged to switch to Linux — it’s free, open-source, and simply works better with the scientific Python + GPU stack.
macOS prerequisites (before pip install):
brew install libomp hdf5 cmake openssl
Linux prerequisites (only if you also want the classic Tk GUI):
sudo apt-get install python3-tk
Install (PyPI):
pip install spacr
Install (from source, latest development branch):
git clone https://github.com/EinarOlafsson/spacr.git
cd spacr && pip install -e '.[qt]'
Launch:
spacr # Qt GUI (default)
spacr-qt # explicit alias for the Qt GUI
spacr-legacy # classic Tk GUI
Example Notebooks
The following Jupyter notebooks illustrate common workflows:
Generate masks — generate cell, nuclei and pathogen segmentation masks from microscopy images using Cellpose.
Capture single-cell images and measurements — extract object-level measurements and crop single-cell images for downstream analysis.
Machine-learning object classification — train traditional ML models (e.g., XGBoost) to classify cell phenotypes.
Computer-vision object classification — train and evaluate deep-learning models (PyTorch CNNs/Transformers) on cropped object images.
Map sequencing barcodes — map sequencing reads to row, column, and gRNA barcodes for genotype-phenotype mapping.
Finetune Cellpose models — refine Cellpose models with your own annotated training data.
Interactive Tutorial
Click below to explore the step-by-step GUI and Notebook tutorials for spaCR:
Debugging & logs
Every subsystem funnels through the same rotating log at ~/.spacr/logs/spacr.log (5 MB × 3 backups). Crank the level via env var:
SPACR_LOG_LEVEL=DEBUG spacr
Or, interactively:
from spacr.logging_util import setup_logging, enable_debug
setup_logging() # once at program start
enable_debug() # all spacr.* loggers → DEBUG
spaCRPower
Power analysis of pooled-perturbation spaCR screens.
Data Availability
Full microscopy image dataset: EMBL-EBI BioStudies S-BIAD2135
Testing dataset: Hugging Face toxo_mito
Sequencing data: NCBI BioProject PRJNA1261935
License
spaCR is distributed under the terms of the MIT License. See the LICENSE file for details.
How to Cite
If you use spaCR in your research, please cite:
Olafsson EB, et al. A pooled image-based CRISPR screen identifies EAF1 as a T. gondii modulator of ESCRT subversion. Manuscript under consideration.
Papers Using spaCR
Selected publications that have used or cited spaCR:
Olafsson EB, et al. SpaCR: Spatial phenotype analysis of CRISPR-Cas9 screens. Manuscript in preparation.
IRE1α promotes phagosomal calcium flux to enhance macrophage fungicidal activity
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spacr-1.4.9.7.tar.gz.
File metadata
- Download URL: spacr-1.4.9.7.tar.gz
- Upload date:
- Size: 25.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0136459891e386a169fa58b010633024b7032ef01869ae42437ac4145ae0e7b4
|
|
| MD5 |
a926d7908fd6ca7890fc252490c1a910
|
|
| BLAKE2b-256 |
be993b552c6a2f666d43f18cddfe93c42be2c20a2aa69d7ce4d61aef602a7d21
|
File details
Details for the file spacr-1.4.9.7-py3-none-any.whl.
File metadata
- Download URL: spacr-1.4.9.7-py3-none-any.whl
- Upload date:
- Size: 12.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
867aafd7fa5d2c5b757374e68e0be644e75b6244e3c60742db2504314f32bf8b
|
|
| MD5 |
d40f79a5a123c08b127b04dc2eefa486
|
|
| BLAKE2b-256 |
a51a0ef792ccd486cf1b06eb635ac1790c0aacb1161026f0b4d48221f8fa42fa
|