spaCR
Spatial phenotype analysis of CRISPR–Cas9 screens (spaCR).
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-based software package for generating single-cell image data for deep-learning sub-cellular/cellular phenotypic classification from pooled genetic CRISPR-Cas9 screens. SpaCr provides a flexible toolset to extract single-cell images and measurements from high-content cell painting experiments, train deep-learning models to classify cellular/subcellular phenotypes, simulate, and analyze pooled CRISPR-Cas9 imaging screens.
- Generate Masks: Generate Cellpose masks of cell, nuclei, and pathogen objects.
- Object Measurements: Measurements for each object including scikit-image regionprops, intensity percentiles, shannon-entropy, Pearson’s and Manders’ correlations, homogeneity, and radial distribution. Measurements are saved to a SQL database in object-level tables.
- Crop Images: Save objects (cells, nuclei, pathogen, cytoplasm) as images. Object image paths are saved in a SQL database.
- Train CNNs or Transformers: Train PyTorch models to classify single object images.
- Manual Annotation (nightly): Supports manual annotation of single-cell images and segmentation to refine training datasets for training CNNs/Transformers or cellpose, respectively.
- Finetune Cellpose Models (nightly): Adjust pre-existing Cellpose models to your specific dataset for improved performance.
- Timelapse Data Support (nightly): Track objects in timelapse image data.
- Simulations: Simulate spatial phenotype screens with spaCRPower.
- Sequencing: Map FASTQ reads to barcode and gRNA barcode metadata.
- Misc (nightly): Analyze Ca oscillation, recruitment, infection rate, plaque size/count.
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 machine learning (ML, e.g., XGBoost) or deep learning (DL, e.g., PyTorch) models to classify objects, summarizing 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. Output folder structure for each module, including locations for raw and processed images, masks, object-level measurements, datasets, and results. c. List of all spaCR package modules.
Linux recommended.
macOS prerequisites (before install):
brew install libomp hdf5 cmake openssl
Linux GUI requirement: spaCR GUI requires Tkinter.
sudo apt install python3-tk
Install stable version (main):
pip install spacr
Install nightly version:
pip install spacr-nightly
Launch GUI (stable):
spacr
Launch GUI (nightly):
spacrn
The following example Jupyter notebooks illustrate common workflows using spaCR.
- 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 based object classification Train traditional machine learning models (e.g., XGBoost) to classify cell phenotypes based on extracted features.
- Computer vision based 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 CRISPR screen genotype-phenotype mapping.
- Finetune cellpose models Finetune Cellpose models using your own annotated training data for improved segmentation accuracy.
Graphical abstract | Workflow for pooled CRISPR–Cas9 spatial phenotype screening
A pooled population of cells with perturbations (G1…i) is distributed into wells (W1…j) and expanded. Cells from each well (Wj) are transferred for genotyping by PCR with barcoded primers, followed by next-generation sequencing (NGS) to determine gRNA abundances (Rij). In parallel, cells are phenotyped by MaxViT-based image classification, generating an average well classification score (Cj). Multiple linear regression (MLR) uses Cj as the response variable and Rij as the predictor to estimate the effect size (βi) of each gRNA.
Click below to explore the step-by-step GUI and Notebook tutorials for spaCR:
Power analysis of pooled perturbation spaCR screens.
- Full microscopy image dataset: EMBL-EBI BioStudies S-BIAD2135
- Testing dataset: Hugging Face toxo_mito
- Sequencing data: NCBI BioProject PRJNA1261935
spaCR is distributed under the terms of the MIT License. See the LICENSE file for details.
If you use spaCR in your research, please cite: spaCR: Spatial phenotype analysis of CRISPR-Cas9 screens.
Below are selected publications that have used or cited spaCR: