pertpy: Perturbation Analysis in the scverse ecosystem

repository·main·Indexed 43 days ago

https://github.com/scverse/pertpy

An end-to-end framework for analyzing large-scale single-cell perturbation experiments, such as genetic knockouts and drug screens. pertpy enables dataset harmonization, metadata annotation via databases like PubChem and ChEMBL, perturbation space analysis, and cellular response calculations. It supports AnnData and MuData formats and leverages JAX, Numba, and NumPyro for GPU acceleration and high-performance computing.

Tokens
26.8K
Snippets
95
Records
118
Agent score
55%

What's inside pertpy

  1. Overview of pertpy for perturbation analysis

    main

    pertpy is a framework within the scverse ecosystem designed for analyzing large-scale single-cell perturbation experiments. It provides tools for:

    • Harmonizing perturbation datasets.
    • Automating metadata annotation.
    • Calculating perturbation distances.
    • Analyzing cellular responses to stimuli such as genetic modifications, drug treatments, and environmental changes.
  2. Explore Perturbation Analysis tools in pertpy

    main

    pertpy provides a suite of tools for analyzing single-cell perturbation data, categorized by analytical task. You can find specialized tutorials and implementations for:

    • Differential gene expression: Identifying gene changes following perturbation.
    • Pooled CRISPR screens: Analyzing perturbation efficacy in pooled screens.
    • Compositional analysis: Using methods like sccoda, sccoda_extended, tasccoda, and milo to study changes in cell type proportions.
    • Multicellular and gene programs: Tools for dialogue and enrichment analysis.
    • Distances and permutation tests: Measuring distances between states and performing statistical tests.
    • Response prediction: Predicting cellular responses using augur, cinemaot, or scgen_perturbation_prediction.
    • Perturbation space: Analyzing the landscape of perturbations.
  3. Overview of the Pertpy workflow

    main

    Pertpy is an end-to-end framework for analyzing large-scale single-cell perturbation experiments (e.g., genetic knockouts, drug screens, disease states). A typical workflow in Pertpy follows these modular steps:

    1. Data transformation: Initial processing, such as guide RNA assignment for CRISPR screens.
    2. Quality control: Addressing confounding factors and technical variation.
    3. Metadata annotation: Annotating against ontologies and enriching from databases.
    4. Perturbation space analysis: Learning biologically interpretable embeddings.
    5. Downstream analysis: Performing differential expression, compositional analysis, and distance calculations.

    These steps are designed to be composable, allowing you to chain individual modules into custom analysis pipelines.

  4. Supported data formats and inputs for Pertpy

    main

    Pertpy is designed to work with unimodal scRNA-seq or multimodal perturbation readouts. The primary input formats are:

    • AnnData objects
    • MuData objects

    The framework can handle various assay types, data sizes (from thousands to millions of cells), and perturbation settings including genetic modifications, drug treatments, pathogen exposure, and environmental conditions or disease states.

  5. Scalability and acceleration in Pertpy

    main

    Pertpy uses sparse and memory-efficient implementations to handle large datasets. It leverages several libraries for parallelization and GPU acceleration to improve performance over original implementations:

    • JAX: Used for GPU acceleration and high-performance computing.
    • Numba: Used for speeding up Python code.
    • PyNNDescent: Used in the Mixscape implementation for optimized nearest neighbor search during perturbation signature calculation.
    • NumPyro: Used to accelerate scCODA and tascCODA by replacing TensorFlow's Hamiltonian Monte Carlo with the no-U-turn sampler.
    • ott-jax: Used to optimize CINEMA-OT, making it portable across hardware and enabling GPU acceleration.
  6. Annotate perturbations using the Metadata module

    main
    The pertpy.metadata module provides tools to annotate perturbations by querying external databases. This metadata can be used to develop biologically informed models or perform enrichment tests. The module is organized into specialized classes for different types of metadata: CellLine, Compound, Moa (Mechanism of Action), and Drug.
  7. Documentation standards and tools used in pertpy

    main

    Pertpy uses the following tools and standards for its documentation:

    • Sphinx: The core documentation engine.
    • MyST: Allows writing documentation in Markdown or Markedly Structured Text.
    • Numpy-style docstrings: Handled via the napoleon extension.
    • myst-nb: Renders Jupyter notebooks as tutorials.
    • sphinx-autodoc-typehints: Automatically references annotated input and output types.
    • sphinxcontrib-bibtex: Used for including citations (e.g., {cite:p}Virshup_2023`).
  8. Cite pertpy in research

    main

    If you use pertpy in your research, please cite the following BibTeX entry. Additionally, if you use specific tools integrated within pertpy, you should also cite their original publications. A list of tool-specific references is available in the references documentation.

    @article {Heumos2024.08.04.606516,
        author = {Heumos, Lukas and Ji, Yuge and May, Lilly and Green, Tessa and Zhang, Xinyue and Wu, Xichen and Ostner, Johannes and Peidli, Stefan and Schumacher, Antonia and Hrovatin, Karin and Müller, Michaela and Chong, Faye and Sturm, Gregor and Tejada, Alejandro and Dann, Emma and Dong, Mingze and Bahrami, Mojtaba and Gold, Ilan and Rybakov, Sergei and Namsaraeva, Altana and Moinfar, Amir and Zheng, Zihe and Roellin, Eljas and Mekki, Isra and Sander, Chris and Lotfollahi, Mohammad and Schiller, Herbert B. and Theis, Fabian J.},
        title = {Pertpy: an end-to-end framework for perturbation analysis},
        elocation-id = {2024.08.04.606516},
        year = {2024},
        doi = {10.1101/2024.08.04.606516},
        publisher = {Cold Spring Harbor Laboratory},
        URL = {https://www.biorxiv.org/content/early/2024/08/07/2024.08.04.606516},
        eprint = {https://www.biorxiv.org/content/early/2024/08/07/2024.08.04.606516.full.pdf},
        journal = {bioRxiv}
    }
  9. Configure pre-commit for code-style enforcement

    main

    The project uses pre-commit to enforce code styles and run type-checks (via mypy) on every commit.

    To install and enable pre-commit locally, run:

    pre-commit install

    If you are working on a branch where pre-commit.ci has automatically committed fixes, integrate them using:

    git pull --rebase

    Type Checking: mypy is used for type checking. To silence a specific line in your code, use the comment # type: ignore[<error-code>].