Metadata-Version: 2.4
Name: cascade-reg
Version: 0.5.1
Summary: Causal discovery of gene regulatory programs from single-cell genomics
Keywords: bioinformatics,causal-discovery,causal-inference,deep-learning,gene-regulatory-network,single-cell
Author-email: Zhi-Jie Cao <caozj@mail.cbi.pku.edu.cn>
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
License-File: LICENSE
Requires-Dist: anndata
Requires-Dist: adjustText
Requires-Dist: kneed
Requires-Dist: loguru
Requires-Dist: matplotlib
Requires-Dist: networkx
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: pynvml
Requires-Dist: pytorch-lightning>=2
Requires-Dist: pyyaml
Requires-Dist: rich
Requires-Dist: scanpy
Requires-Dist: scikit-learn
Requires-Dist: scipy
Requires-Dist: seaborn
Requires-Dist: tensorboard
Requires-Dist: torch>=2
Requires-Dist: sphinx ; extra == "doc"
Requires-Dist: sphinx-autobuild ; extra == "doc"
Requires-Dist: sphinx-autodoc-typehints ; extra == "doc"
Requires-Dist: sphinx-rtd-theme ; extra == "doc"
Requires-Dist: sphinx-copybutton ; extra == "doc"
Requires-Dist: sphinxcontrib-programoutput ; extra == "doc"
Requires-Dist: nbsphinx ; extra == "doc"
Requires-Dist: allpairspy ; extra == "test"
Requires-Dist: black<25 ; extra == "test"
Requires-Dist: dynamicTreeCut ; extra == "test"
Requires-Dist: filelock ; extra == "test"
Requires-Dist: flake8 ; extra == "test"
Requires-Dist: opencv-python ; extra == "test"
Requires-Dist: plotly ; extra == "test"
Requires-Dist: pytest-cov ; extra == "test"
Requires-Dist: pytest ; extra == "test"
Project-URL: Github, https://github.com/gao-lab/CASCADE-dev
Provides-Extra: doc
Provides-Extra: test

# Causal discovery of gene regulatory programs from single-cell genomics

[![stars-badge](https://img.shields.io/github/stars/gao-lab/CASCADE?logo=GitHub&color=yellow)](https://github.com/gao-lab/CASCADE/stargazers)
[![pypi-badge](https://img.shields.io/pypi/v/cascade-reg)](https://pypi.org/project/cascade-reg)
[![build-badge](https://github.com/gao-lab/CASCADE/actions/workflows/build.yml/badge.svg)](https://github.com/gao-lab/CASCADE/actions/workflows/build.yml)
[![codecov-badge](https://codecov.io/gh/gao-lab/CASCADE/graph/badge.svg?token=49YVG6XHSG)](https://codecov.io/gh/gao-lab/CASCADE)
[![docs-badge](https://readthedocs.org/projects/cascade-reg/badge/?version=latest)](https://cascade-reg.readthedocs.io/en/latest/?badge=latest)
[![license-badge](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![style-badge](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)

**CASCADE** stands for **C**ausality-**A**ware **S**ingle-**C**ell **A**daptive
**D**iscover/**D**eduction/**D**esign **E**ngine. It is a deep learning-based
bioinformatics tool for causal gene regulatory network discovery, counterfactual
perturbation effect prediction, and targeted intervention design based on
high-content single-cell perturbation screens.

Trained on single-cell perturbation data, CASCADE models the causal gene
regulatory network as a directed acyclic graph (DAG) and leverages
differentiable causal discovery (DCD) to transform the search of discrete
network structures into a manageable optimization problem. We achieve causal
discovery with thousands of genes by incorporating a scaffold graph built from
context-agnostic, coarse prior regulatory knowledge to constrain search space
and enhance computational efficiency in an evidence-guided manner. Additionally,
technical confounding covariate as well as gene-wise perturbation latent
variables encoded from gene ontology (GO) annotations are also included to
account for effects not explained by the causal structure. The complete CASCADE
model is constructed within a Bayesian framework, allowing for the estimation of
causal uncertainty under limited data regimes typical of practical biological
experiments.

![Overview](docs/_static/overview.png)

Using the inferred causal regulatory network, CASCADE supports two types of
downstream inference. First, it performs counterfactual deduction of unseen
perturbation effects by iteratively propagating perturbation effects following
the topological order of the causal graph. Notably, this deduction process
remains end-to-end differentiable, allowing it to be inverted into intervention
design by treating gene intervention as an optimizable parameter trained to
minimize deviation between the counterfactual outcome and desired target
transcriptomes.

For more details, please check out our preprint at TODO.

## Install

CASCADE is implemented in the ``cascade-reg`` package. It can be installed
directly using pip:

```sh
pip install cascade-reg
```

To avoid potential dependency conflicts, installing within a
[conda environment](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)
is recommended.

A conda build will be available in the future.

## How to use

Proceed to our [documentation site](https://cascade-reg.readthedocs.io) for how to
use the ``cascade-reg`` package.

## Replicate results

1. Check out the repository to branch `repicate`:
   ```sh
   git checkout replicate
   ```
2. Create a local conda environment using the `env.sh` script:
   ```sh
   ./env.sh create
   ```
3. Activate the local conda environment:
   ```sh
   mamba activate ./conda
   ```
4. Use scripts in `data/download` to prepare necessary data
5. Use scripts in `data/scaffold` to prepare the scaffold graphs
6. Use pipeline in `evaluation` for running systematic benchmarks
7. Use notebooks in `experiments` for intervention design case studies

## Development

Instructions below are only for development purpose.

### Environment setup

Use the following commands to manage the development environment:

```sh
./env.sh create  # Create new environment based on config files
./env.sh export  # Export environment changes to config files
./env.sh update  # Update environment based on config files
```

Use the following commands to activate and deactivate the environment:

```sh
mamba activate ./conda
mamba deactivate
```

### Build documentation

```sh
sphinx-build -b html -D language=en docs docs/_build/html/en
```

