Skip to content
naulon

No retraction, correction or concern found when last checked on Oct 15, 2026.

SCANPY: large-scale single-cell gene expression data analysis

F. Alexander Wolf, Philipp Angerer, Fabian J. Theis

Genome Biology · 2018

doi:10.1186/s13059-017-1382-0

Abstract

SCANPY is a scalable toolkit for analyzing single-cell gene expression data. It includes methods for preprocessing, visualization, clustering, pseudotime and trajectory inference, differential expression testing, and simulation of gene regulatory networks. Its Python-based implementation efficiently deals with data sets of more than one million cells ( https://github.com/theislab/Scanpy ). Along with SCANPY, we present ANNDATA, a generic class for handling annotated data matrices ( https://github.com/theislab/anndata ).

Full text

From PubMed Central, U.S. National Library of Medicine, as current on Oct 15, 2026. Paragraph numbers are ours, so an answer can point at one.

Background

Simple integrated analysis work flows for single-cell transcriptomic data have been enabled by frameworks such as SEURAT, MONOCLE, SCDE/PAGODA, MAST, CELL RANGER, SCATER, and SCRAN. However, these frameworks do not scale to the increasingly available large data sets with up to and more than one million cells. Here, we present a framework that overcomes this limitation and provides similar analysis possibilities. Moreover, in contrast to the existing R-based frameworks, SCANPY’s Python-based implementation is easy to interface with advanced machine-learning packages, such as TENSORFLOW.

SCANPY integrates canonical analysis methods in a scalable way

SCANPY integrates the analysis possibilities of established R-based frameworks and provides them in a scalable and modular form. Specifically, SCANPY provides preprocessing comparable to SEURAT and CELL RANGER, visualization through TSNE, graph-drawing and diffusion maps, clustering similar to PHENOGRAPH, identification of marker genes for clusters via differential expression tests and pseudotemporal ordering via diffusion pseudotime, which compares favorably with MONOCLE 2, and WISHBONE (Fig. 1a).

SCANPY is benchmarked in comparisons with established packages

In a detailed clustering tutorial of 2700 peripheral blood mononuclear cells (PBMCs), adapted from one of SEURAT’s tutorials (http://satijalab.org/seurat/pbmc3k_tutorial.html), all steps starting from raw count data to the identification of cell types are carried out, providing speedups between 5 and 90 times in each step (https://github.com/theislab/scanpy_usage/tree/master/170505_seurat). Benchmarking against the more run-time optimized CELL RANGER R kit, we demonstrate a speedup of 5 to 16 times for a data set of 68,579 PBMCs (Fig. 1a,b, https://github.com/theislab/scanpy_usage/tree/master/170503_zheng17). Moreover, we demonstrate the feasibility of analyzing 1.3 million cells without subsampling in a few hours of computing time on eight cores of a small computing server (Fig. 1c, https://github.com/theislab/scanpy_usage/tree/master/170522_visualizing_one_million_cells). Thus, SCANPY provides tools with speedups that enable an analysis of data sets with more than one million cells and an interactive analysis with run times of the order of seconds for about 100,000 cells.

In addition to the mentioned standard clustering-based analyses approaches, we demonstrate the reconstruction of branching developmental processes via diffusion pseudotime as in the original paper (https://github.com/theislab/scanpy_usage/tree/master/170502_haghverdi16), the simulation of single cells using literature-curated gene regulatory networks based on the ideas of (https://github.com/theislab/scanpy_usage/tree/master/170430_krumsiek11), and the analysis of deep-learning results for single-cell imaging data (https://github.com/theislab/scanpy_usage/tree/master/170529_images).

SCANPY introduces efficient modular implementation choices

With SCANPY, we introduce the class ANNDATA—with a corresponding package ANNDATA—which stores a data matrix with the most general annotations possible: annotations of observations (samples, cells) and variables (features, genes), and unstructured annotations. As SCANPY is built around that class, it is easy to add new functionality to the toolkit. All statistics and machine-learning tools extract information from a data matrix, which can be added to an ANNDATA object while leaving the structure of ANNDATA unaffected. ANNDATA is similar to R’s EXPRESSIONSET, but supports sparse data and allows HDF5-based backing of ANNDATA objects on disk, a format independent of platform, framework, and language. This allows operating on an ANNDATA object without fully loading it into memory—the functionality is offered via ANNDATA’s backed mode as opposed to its memory mode. To simplify memory-efficient pipelines, SCANPY’s functions operate in-place by default but allow the optional non-destructive transformation of objects. Pipelines written this way can then also be run in backed mode to exploit online-learning formulations of algorithms. Almost all of SCANPY’s tools are parallelized.

SCANPY introduces a class for representing a graph of neighborhood relations among data points. The computation of neighborhood relations is much faster than in the popular reference package. This is achieved by aggregating rows (observations) in a data matrix to submatrices and computing distances for each submatrix using fast parallelized matrix multiplication. Moreover, the class provides several functions to compute random-walk-based metrics that are not available in other graph software. Typically, SCANPY’s tools reuse a once-computed, single graph representation of data and hence, avoid the use of different, potentially inconsistent, and computationally expensive representations of data.

Conclusions

SCANPY’s scalability directly addresses the strongly increasing need for aggregating larger and larger data sets across different experimental setups, for example within challenges such as the Human Cell Atlas. Moreover, being implemented in a highly modular fashion, SCANPY can be easily developed further and maintained by a community. The transfer of the results obtained with different tools used within the community is simple, as SCANPY’s data storage formats and objects are language independent and cross-platform. SCANPY integrates well into the existing Python ecosystem, in which no comparable toolkit yet exists.

During the revision of this article, the loom file format (https://github.com/linnarsson-lab/loompy) was proposed for HDF5-based storage of annotated data. Within a joint effort of facilitating data exchange across different labs, ANNDATA now supports importing and exporting to loom (https://github.com/linnarsson-lab/loompy). In this context, we acknowledge the discussions with S. Linnarson, which motivated us to extend ANNDATA’s previously static to a dynamic HDF5 backing. Just before submission of this manuscript, a C++ library that provides simple interfacing of HDF5-backed matrices in R was made available as a preprint.

SCANPY’s technological foundations

SCANPY’s core relies on NUMPY, SCIPY, MATPLOTLIB, PANDAS, and H5PY. Parts of the toolkit rely on SCIKIT-LEARN, STATSMODELS, SEABORN, NETWORKX, IGRAPH, the TSNE package of, and the Louvain clustering package of. The ANNDATA class—available within the package ANNDATA—relies only on NUMPY, SCIPY, PANDAS, and H5PY.

SCANPY’s Python-based implementation allows easy interfacing to advanced machine-learning packages such as TENSORFLOW for deep learning, LIMIX for linear mixed models, and GPY/GPFLOW for Gaussian processes. However, we note that the Python ecosystem comes with less possibilities for classical statistical analyses compared to R.

Comparison with existing Python packages for single-cell analysis

Aside from the highly popular SCLVM (https://github.com/PMBio/scLVM), which uses Gaussian process latent variable models for inferring hidden sources of variation, there are, among others, the visualization frameworks FASTPROJECT (https://github.com/YosefLab/FastProject), ACCENSE (http://www.cellaccense.com/), and SPRING (https://github.com/AllonKleinLab/SPRING)—the latter uses the JavaScript package (http://d3js.org D3.js for the actual visualization and Python only for preprocessing—the trajectory inference tool SCIMITAR (https://github.com/dimenwarper/scimitar), the clustering tool PHENOGRAPH (https://github.com/jacoblevine/PhenoGraph), the single-cell experiment design tool MIMOSCA (https://github.com/asncd/MIMOSCA), UMIS (https://github.com/vals/umis) for handling raw read data, the tree-inference tool ECLAIR (https://github.com/GGiecold/ECLAIR), and the framework FLOTILLA (https://github.com/yeolab/flotilla), which comes with modules for simple visualization, simple clustering, and differential expression testing. Hence, only the latter provides a data analysis framework that solves more than one specific task. In contrast to SCANPY, however, FLOTILLA is neither targeted at single-cell nor at large-scale data and does not provide any graph-based methods, which are the core of SCANPY. Also, FLOTILLA is built around a complicated class STUDY, which contains data, tools, and plotting functions. SCANPY, by contrast, is built around a simple HDF5-backed class ANNDATA, which makes SCANPY both scalable and extendable (law of Demeter).

Availability and requirements

SCANPY’s and ANNDATA’s open-source code are maintained on GITHUB (https://github.com/theislab/scanpy, https://github.com/theislab/anndata) and published under the BSD3 license.

SCANPY and ANNDATA are released via the Python packaging index: https://pypi.python.org/pypi/scanpy and https://pypi.python.org/pypi/anndata.

Demonstrations and benchmarks discussed in the main text are all stored at https://github.com/theislab/scanpy_usageand summarized here: Analyzing 68,579 PBMCs (Fig. 1) in a comparison with the Cell Ranger R kit: https://github.com/theislab/scanpy_usage/tree/master/170503_zheng17.Clustering and identifying cell types, adapted from and benchmarked with http://satijalab.org/seurat/pbmc3k_tutorial.htmland one of Seurat’s tutorials: https://github.com/theislab/scanpy_usage/tree/master/170505_seurat.Visualizing and clustering 1.3 million cells (Fig. 1c): https://github.com/theislab/scanpy_usage/tree/master/170522_visualizing_one_million_cells.Reconstructing branching processes via diffusion pseudotime: https://github.com/theislab/scanpy_usage/tree/master/170502_haghverdi16.Simulating single cells using gene regulatory networks: https://github.com/theislab/scanpy_usage/tree/master/170430_krumsiek11.Analyzing deep-learning results for single-cell images: https://github.com/theislab/scanpy_usage/tree/master/170529_images.

Analyzing 68,579 PBMCs (Fig. 1) in a comparison with the Cell Ranger R kit: https://github.com/theislab/scanpy_usage/tree/master/170503_zheng17.

Clustering and identifying cell types, adapted from and benchmarked with http://satijalab.org/seurat/pbmc3k_tutorial.htmland one of Seurat’s tutorials: https://github.com/theislab/scanpy_usage/tree/master/170505_seurat.

Visualizing and clustering 1.3 million cells (Fig. 1c): https://github.com/theislab/scanpy_usage/tree/master/170522_visualizing_one_million_cells.

Reconstructing branching processes via diffusion pseudotime: https://github.com/theislab/scanpy_usage/tree/master/170502_haghverdi16.

Simulating single cells using gene regulatory networks: https://github.com/theislab/scanpy_usage/tree/master/170430_krumsiek11.

Analyzing deep-learning results for single-cell images: https://github.com/theislab/scanpy_usage/tree/master/170529_images.

The data sets used in demonstrations and benchmarks are three data sets from 10x Genomics.

Programming language: Python

Operating system: Linux, Mac OS and Windows

References 52

  1. 1.

    Wagner A, Regev A, Yosef N. Revealing the vectors of cellular identity with single-cell genomics. Nat Biotechnol. 2016;34:1145-60.

    Not in our library10.1038/nbt.3711

  2. 2.

    Satija R, Farrell JA, Gennert D, Schier AF, Regev A. Spatial reconstruction of single-cell gene expression data. Nat Biotechnol. 2015;33:495-502.

    Not in our library10.1038/nbt.3192

  3. 3.

    Trapnell C, et al. The dynamics and regulators of cell fate decisions are revealed by pseudotemporal ordering of single cells. Nat Biotechnol. 2014;32:381-6.

    Not in our library10.1038/nbt.2859

  4. 4.

    Kharchenko PV, Silberstein L, Scadden DT, Bayesian approach to single-cell differential expression analysis. Nat Methods. 2014;11:740-2.

    Not in our library10.1038/nmeth.2967

  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.

    Abadi M, et al.TensorFlow: large-scale machine learning on heterogeneous systems. 2015. https://www.tensorflow.org/about/bib.

    Not in our library

  10. 10.

    Macosko EZ, et al. Highly parallel genome-wide expression profiling of individual cells using nanoliter droplets. Cell. 2015;161:1202-14.

    Not in our library10.1016/j.cell.2015.05.002

  11. 11.

    Coifman RR, et al. Geometric diffusions as a tool for harmonic analysis and structure definition of data: diffusion maps. Proc Natl Acad Sci. 2005;102:7426-31.

    Not in our library10.1073/pnas.0500334102

  12. 12.

    Amir EAD, Davis KL, Tadmor MD, Simonds EF, Levine JH, Bendall SC, et al. viSNE enables visualization of high dimensional single-cell data and reveals phenotypic heterogeneity of leukemia. Nat Biotechnol. 2013;31:545-52.

    Not in our library10.1038/nbt.2594

  13. 13.

    Reingold EM. Graph drawing by force-directed placement. Softw Pract Exp. 1991;21:1129-64.

    Not in our library10.1002/spe.4380211102

  14. 14.

    Csardi G, Nepusz T. The igraph software package for complex network research. InterJournal Compl Syst. 2006;2006:1695.

    Not in our library

  15. 15.

    Weinreb C, Wolock S, Klein A. Spring: a kinetic interface for visualizing high dimensional single-cell expression data. bioRxiv. 2017. 10.1093/bioinformatics/btx792.

    Not in our library10.1093/bioinformatics/btx792

  16. 16.

    Buettner F, Theis FJ. Diffusion maps for high-dimensional single-cell analysis of differentiation data. Bioinformatics. 2015;31:2989-98.

    Not in our library10.1093/bioinformatics/btv325

  17. 17.

    Angerer P, et al. destiny: diffusion maps for large-scale single-cell data in R. Bioinformatics. 2015;32:1241.

    Not in our library10.1093/bioinformatics/btv715

  18. 18.

    Blondel VD, Guillaume J-L, Lambiotte R, Lefebvre E. Fast unfolding of communities in large networks. J Stat Mech. 2008;2008:P10008.

    Not in our library10.1088/1742-5468/2008/10/p10008

  19. 19.

    Levine JH, et al. Data-driven phenotypic dissection of AML reveals progenitor-like cells that correlate with prognosis. Cell. 2015;162:184-97.

    Not in our library10.1016/j.cell.2015.05.047

  20. 20.

    Xu C, Su Z. Identification of cell types from single-cell transcriptomes using a novel clustering method. Bioinformatics. 2015;31:1974-80.

    Not in our library10.1093/bioinformatics/btv088

  21. 21.

    Haghverdi L, Buttner, M̈, Wolf FA, Buettner F, Theis FJ. Diffusion pseudotime robustly reconstructs branching cellular lineages. Nat Methods. 2016;13:845-8.

    Not in our library10.1038/nmeth.3971

  22. 22.

    Qiu X, et al. Reversed graph embedding resolves complex single-cell trajectories. Nat Methods. 2017;14:979-82.

    Not in our library10.1038/nmeth.4402

  23. 23.

    Setty, M, et al. Wishbone identifies bifurcating developmental trajectories from single-cell data. Nat Biotechnol. 2016;34:637-45.

    Not in our library10.1038/nbt.3569

  24. 24.
  25. 25.
  26. 26.

    Huber, W, et al. Orchestrating high-throughput genomic analysis with Bioconductor. Nat Methods. 2015;12:115-21.

    Not in our library10.1038/nmeth.3252

  27. 27.

    Pedregosa F, et al. Scikit-learn: machine learning in Python. J Mach Learn Res. 2011;12:2825-30.

    Not in our library

  28. 28.

    Hagberg AA, Schult DA, Swart PJ. Exploring network structure, dynamics, and function using networkx. In: Proceedings of the 7th Python in Science Conference (SciPy2008). Pasadena: 2008. p. 11–15.

    Not in our library

  29. 29.

    Bastian M, Heymann S, Jacomy M. Gephi: an open source software for exploring and manipulating networks. International AAAI Conference on Weblogs and Social Media. 2009.

    Not in our library

  30. 30.

    Angerer, P, et al. Single cells make big data: new challenges and opportunities in transcriptomics. Curr Opin Syst Biol. 2017;4:85-91.

    Not in our library10.1016/j.coisb.2017.07.004

  31. 31.
    The Human Cell Atlas · 2017
    No notice
  32. 32.

    Lun ATL, Pages̀ H, Smith ML. beachmat: a Bioconductor C++ API for accessing single-cell genomics data from a variety of R matrix types. bioRxiv. 2017. 10.1101/167445.

    Not in our library

  33. 33.

    van der Walt S, Colbert SC, Varoquaux G. The NumPy array: a structure for efficient numerical computation. Comput Sci Eng. 2011;13:22-30.

    Not in our library10.1109/mcse.2011.37

  34. 34.

    Jones E, Oliphant T, Peterson P, et al.SciPy: open source scientific tools for Python. 2001. https://www.scipy.org/citing.html.

    Not in our library

  35. 35.

    Hunter JD. Matplotlib: a 2D graphics environment. Comput Sci Eng. 2007;9:90-5.

    Not in our library10.1109/mcse.2007.55

  36. 36.

    McKinney W. Data structures for statistical computing in Python In: van der Walt S, Millman J, editors. Proceedings of the 9th Python in Science Conference: 2010. p. 51–6.

    Not in our library

  37. 37.

    Collette A. Python and HDF5. 2013.

    Not in our library

  38. 38.

    Seabold S, Perktold J. Statsmodels: econometric and statistical modeling with Python. 9th Python in Science Conference. 2010.

    Not in our library

  39. 39.

    Waskom, M, et al. In: Varoquaux G, Vaught T, Millman J, (eds).Seaborn; 2016. http://doi.org/10.5281/zenodo.12710, https://networkx.github.io/documentation/networkx-1.10/reference/citing.html.

    Not in our library

  40. 40.

    Ulyanov D. Multicore-tsne. 2016. https://github.com/DmitryUlyanov/Multicore-TSNE.

    Not in our library

All 52 references

Cited by papers we hold 240

and 220 more

Reads

Read by people on this page

None yet.

Checked or read by AI through naulon

None yet.

A person counts once a day per paper. We keep no cookie and no address: a reader is a hash that changes every day. Any month under five reads shows no number.

Are you an author?

Is this your paper?

Claim it to add your note and be paid when agents cite it. Free.