Skip to content

pysceptre

Standalone Python port of the statistical engine behind sceptre's discovery analysis for single-cell CRISPR screens.

from pysceptre import run_discovery_analysis

Three sceptre analyses -- discovery analysis, the calibration check and the power check -- for high- and low-MOI screens: the complement and NT-cells control groups, with CRT or permutation resampling, each validated against the R package rather than against itself.

Alongside them, compute_power estimates in closed form what a screen could have detected, per pair and without simulation. It answers a different question, it is a port of PerturbPlan rather than of sceptre, and it is validated against that package instead.

run_specificity_check asks how many of the links a screen discovered are more than background, measured on tests between elements and genes on other chromosomes. It is not sceptre's either, and nothing external validates it: its reference is the analysis it was ported from.

assign_grnas assigns gRNAs to cells from raw counts, like sceptre's function of the same name: with sceptre's mixture, thresholding or maximum method, each validated against sceptre, or with fishash, which is not sceptre's and is validated against fishash's R.

What is deliberately not implemented, and which paths are exercised rather than validated, is in Scope and limitations; read it before assuming a path works.

sceptre's own discovery-analysis implementation is correct but processes one (gene, gRNA-target) pair, and one resampling draw, largely with R and per-cell C++ loops. At real dataset scale (hundreds of thousands of cells, thousands of gRNA targets, tens of thousands of pairs) that adds up. Every GLM fit in this pipeline shares one design matrix across many response columns (all genes share the covariate matrix; all gRNA targets share it too), which is exactly the shape numpy's batched matrix operations are built for -- so the rewrite fits one batched IRLS call per resampling stage instead of one per gene or target.

Where to go next

Installation uv and pip, the fast and io extras, tested Python versions
User guide a run end to end, and how to read the result frame
Tutorials a worked example end to end, then per-gRNA tests, interaction designs, power beside a result, and a low-MOI screen
API reference generated from the source
Scope and limitations the paths that are not implemented
Design decisions why the port differs from R where it does