Skip to main content

scRL: Single-Cell Reinforcement Learning

PyPI Python Versions Documentation Status Publish to PyPI GitHub Release License: MIT

Overview

scRL (single-cell Reinforcement Learning) is a computational framework that applies reinforcement learning to single-cell RNA sequencing data to study cellular fate decisions. By treating cell differentiation as a sequential decision-making process, scRL is designed to help analyze when and where fate commitments emerge during development and disease.

Key Features

  • Actor-Critic Architecture: Uses deep reinforcement learning to model cellular differentiation trajectories
  • Grid-Based Embedding: Transforms high-dimensional single-cell data into an interpretable 2D manifold
  • Fate Decision Detection: Identifies early decision points that precede overt lineage commitment
  • Multiple Analysis Modes:
    • Gene Module: Analyzes gene expression patterns and regulatory roles
    • Lineage Module: Evaluates lineage commitments and differentiation potentials
    • Trajectory Module: Simulates and visualizes differentiation pathways
  • Flexible Reward Systems: Supports both contribution-based and decision-based reward patterns

Installation

Requirements

  • Python >= 3.9
  • PyTorch >= 1.13.1
  • CUDA support (optional, for GPU acceleration)

Core dependencies (automatically installed):

  • anndata >= 0.8.0
  • numpy >= 1.23.5
  • pandas >= 1.5.2
  • scikit-learn >= 1.2.1
  • networkx >= 2.8.8
  • matplotlib >= 3.6.3
  • seaborn >= 0.11.2
  • joblib >= 1.2.0
  • tqdm >= 4.64.1
  • pygam >= 0.8.0

Install from PyPI

pip install scrl-fatedecision

Note: For the examples in this README, you'll also need Scanpy:

pip install scanpy

Install from Source

git clone https://github.com/PeterPonyu/scRL.git
cd scRL
pip install -e .

Quick Start

import scRL
import scanpy as sc

# Load and preprocess your single-cell data
adata = sc.datasets.paul15()
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
sc.pp.pca(adata, n_comps=50)
sc.tl.tsne(adata)
sc.pp.neighbors(adata)
sc.tl.leiden(adata)

# Extract embedding and cluster information
X = adata.obsm['X_tsne']
clusters = adata.obs['leiden']

# Create grid embedding
gres = scRL.grids_from_embedding(X)

# Project cluster information onto grids
gres = scRL.project_cluster(gres, clusters)

# Align pseudotime
gres = scRL.align_pseudotime(gres, start_cluster='0')

# Train reinforcement learning model
trainer = scRL.trainer(
    algo='ActorCritic',
    gres=gres,
    reward_type='c',
    reward_mode='Decision'
)

# Get state values for fate decisions
scRL.get_state_value(gres, trainer, key='state_value')

Documentation

Comprehensive documentation is available at https://scrl.readthedocs.io

Tutorials

API Reference

How It Works

scRL integrates three key components:

  1. Grid Embedding Generation: Transforms single-cell data into a structured 2D grid space using boundary scanning algorithms, preserving topological relationships while enabling efficient exploration.

  2. Reinforcement Learning Training: An Actor-Critic agent learns to navigate the grid environment, guided by rewards based on gene expression patterns or lineage commitments. The critic evaluates the strength of fate decisions at each state, while the actor identifies optimal differentiation routes.

  3. Functional Analysis Modules:

    • Gene Module: Explores how individual genes contribute to or determine cell fate
    • Lineage Module: Analyzes commitment to specific cell lineages
    • Trajectory Module: Simulates future differentiation paths using an autoencoder trained alongside the RL agent

Scientific Background

Understanding how cells develop into different types during growth and disease is a central problem in single-cell analysis. scRL frames cell development as a sequential decision-making problem to estimate when cells begin committing to future fates.

Reported Findings

  • Identifies early decision points before cells show obvious lineage commitment
  • Evaluated across hematopoiesis, cancer, organogenesis, and perturbation datasets
  • Includes analyses of regulatory factors associated with fate decisions

Citation

If you use scRL in your research, please cite:

@article{fu2025scrl,
  title={scRL: Utilizing Reinforcement Learning to Evaluate Fate Decisions in Single-Cell Data},
  author={Fu, Zeyu and Chen, Chunlin and Wang, Song and Wang, Junping and Chen, Shilei},
  journal={Biology},
  volume={14},
  number={6},
  pages={679},
  year={2025},
  doi={10.3390/biology14060679}
}

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs, questions, or new features.

Metadata

Release files for scrl-fatedecision 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrl-fatedecision 0.0.8
File Size Uploaded Provenance Actions
scrl_fatedecision-0.0.8.tar.gz 30.3 kB With provenance Details for scrl_fatedecision-0.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scrl-fatedecision 0.0.8
File Interpreter ABI Platform Actions
scrl_fatedecision-0.0.8-py3-none-any.whl Python 3 none any Details for scrl_fatedecision-0.0.8-py3-none-any.whl

Total release size: 61.8 kB

Release files / scrl_fatedecision-0.0.8.tar.gz

Download URL scrl_fatedecision-0.0.8.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
77a96c3e6b21d001682508454ce1695be0edaa368d40d6dc9eb21c9d3d5bcaff
BLAKE2b-256 checksum
How to use checksums
57197efed1e9080eeda4447b03df7d64d95f5f8ba57dc661c63a218c55a2ab11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / scrl_fatedecision-0.0.8-py3-none-any.whl

Download URL scrl_fatedecision-0.0.8-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f4bb3ac290616cef9157e736ca934fdd8c7fe5964d2fadd37c2319db0fc5ec3
BLAKE2b-256 checksum
How to use checksums
c40dfe375db591dda08107cafbc87d80af640be216d4c924463e6455b4963bcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for scrl-fatedecision 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for scrl_fatedecision-0.0.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page