Skip to main content

deeplife

PyPI version CI Python 3.12+ License: MIT

Official DeepLife Python toolkit for TwinCell and related analysis: call the Open API from Python, pseudo-bulk with deeplife.pseudobulk, and run sample-level differential expression with deeplife.differential_expression (suitable for pseudo-bulk, bulk, or other compatible count tables). TwinCell code is split into focused subpackages under deeplife.twincell (HTTP client, workflows, preprocess, validation); deeplife.twincell itself still exposes a flat import surface for notebooks.

Source: github.com/deeplifeai/deeplife · Documentation: twincell.deeplife.co/docs · Python: 3.12+ (see pyproject.toml).


Install

pip install deeplife

API key: you need a DeepLife key (usually dl_…). Create or copy one from the TwinCell console (sign in, then open API keys / Keys). In code, set DEEPLIFE_API_KEY in the environment or pass api_key= when constructing the client. API documentation for your deployment is usually at {base_url}/docs when enabled (the client defaults to the production Open API host; pass base_url= for another environment).

Network: the TwinCell Open API is not on the public Internet today. It runs in DeepLife’s cluster and is reachable only when your machine has access to that network—for example by being signed into your organization’s Tailscale tailnet (or whatever access path your team documents). Local-only features (pseudo-bulk, differential expression on .h5ad) do not require API connectivity.

From a git clone (contributors):

uv sync --group dev

Documentation

Hosted docs (same content as the Documentation link on PyPI):

Guide Description
Quick Start pip install, optional [notebook], API keys, first TwinCell workflow
Tutorials Single-cell and bulk RNA-seq target-validation notebooks
API Reference TwinCell, preprocessing, validation, pseudo-bulk, differential expression

Source: docs/index.md.


Package layout

TwinCell (deeplife.twincell)

Import Role
deeplife.twincell Convenience namespace: DeepLifeClient, TwinCell, TwinCellSession, TwinCellStudy (alias of TwinCell), read_h5ad, adata_to_h5ad_bytes, etc.; plus the preprocess helpers pseudobulk, pydeseq2 (and lazy preprocessing).
deeplife.twincell.http REST client (DeepLifeClient, AsyncDeepLifeClient), request/response models, errors, HTTP helpers, logging (DeepLifeClient lives in twincell.http.client).
deeplife.twincell.workflows High-level session and study code: import submodules explicitly, e.g. twincell.workflows.workflows (TwinCellSession, …), twincell.workflows.study (TwinCell, …), twincell.validation.upload_helpers (adata_to_h5ad_bytes for client-side serialization), twincell.workflows.h5ad_io (read_h5ad for local paths and remote .h5ad URIs). The package __init__ resolves names lazily to avoid import cycles.
deeplife.twincell.preprocess Notebook-oriented pseudo-bulk and PyDESeq2 helpers (preprocess.pseudobulk, preprocess.pydeseq2).
deeplife.twincell.validation Local checks for the split inference upload path (validate_twincell_split_anndata, shared with the HTTP client). Exceptions live under validation.core; shared result types under validation.checks.

Other packages

Import Role
deeplife.pseudobulk, deeplife.differential_expression Pseudo-bulk from single-cell AnnData, and sample-level DE (CLIs twincell-pseudobulk, twincell-diffexpr)

Install with pip install deeplife. Import deeplife.twincell (flat or by submodule), deeplife.pseudobulk, and deeplife.differential_expression.


Minimal API usage

End-to-end flow: prepare .h5ad or AnnData yourself → create_prediction (single file) or create_prediction_split (control + perturbed + DEGs; validated locally) → poll or watch_prediction → read results (and optional influence / causal helpers).

import os
from deeplife.twincell import DeepLifeClient

client = DeepLifeClient(api_key=os.environ["DEEPLIFE_API_KEY"])
prediction = client.create_prediction(dataset="twincell_ready.h5ad")
final = client.wait_for_prediction(prediction_id=prediction.prediction_id)
print(final.status)

The same client is available explicitly as from deeplife.twincell.http import DeepLifeClient (recommended in application code so imports stay close to the HTTP layer).

Defaults: the client uses the toolkit’s configured API base URL; pass base_url= for another environment. You must be able to reach that host from your network (see Network under Install). Retries apply to safe GET-style calls (polling), not duplicate uploads on POST. For TLS/proxy issues, use tls_verify= and trust_env= on the client—see DeepLifeClient in deeplife.twincell.http.client.

For richer AnnData preparation (QC, column mapping, pseudo-bulk), use deeplife.twincell.preprocess or the tutorial notebooks.


Tutorials

Tutorial .ipynb files are published on the docs site (interactive + download). getting-started-single-cell.ipynb covers Kang PBMC pseudo-bulk, PyDESeq2, and TwinCell target validation. getting-started-bulk.ipynb is the bulk RNA-seq companion.

Run locally from a git clone:

pip install "deeplife[notebook]" jupyterlab
git clone https://github.com/deeplifeai/deeplife
cd deeplife
jupyter lab tutorials/

Set DEEPLIFE_API_KEY (or use the notebook getpass prompt) before the TwinCell API steps. Network access to the Open API is required for those cells — see Install.

Location Role
twincell.deeplife.co/docs/tutorials/ Canonical hosted tutorials (browse or download)
tutorials/ in a git clone Same notebooks for local Jupyter

Contributors can use uv sync --group dev --extra notebook instead of pip if you prefer the locked lockfile.

After pip install -U deeplife, confirm imports match the layout you expect; the latest release is always on PyPI.


Development

uv sync --group dev
make check-all    # or: ruff, mypy, pytest — see Makefile

CI: .github/workflows/ci.yml runs on pushes and PRs to main / master: uv sync --frozen --group dev, Ruff, mypy, pytest, uv build, twine check --strict. .github/dependabot.yml bumps GitHub Actions weekly.

Releases to PyPI: .github/workflows/pypi-publish.yml runs the same checks, then publishes with OIDC trusted publishing (GitHub environment pypi, trusted publisher configured on the deeplife PyPI project). Bump version in pyproject.toml, push to main, then either push a tag matching v* or run the workflow manually from the Actions tab.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deeplife-1.0.3.tar.gz (697.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deeplife-1.0.3-py3-none-any.whl (177.8 kB view details)

Uploaded Python 3

File details

Details for the file deeplife-1.0.3.tar.gz.

File metadata

  • Download URL: deeplife-1.0.3.tar.gz
  • Upload date:
  • Size: 697.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for deeplife-1.0.3.tar.gz
Algorithm Hash digest
SHA256 6c638467c5c6025e20b530b3b8564d33230224d80555335849d85a1fa41edd65
MD5 c2bc524c51d21b9c09705abdc9b36e0b
BLAKE2b-256 a0ddb2d7342d64b0b35c71af72f56799bf9af01afca41bc7b34322c10b62d784

See more details on using hashes here.

Provenance

The following attestation bundles were made for deeplife-1.0.3.tar.gz:

Publisher: pypi-publish.yml on deeplifeai/deeplife

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deeplife-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: deeplife-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 177.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for deeplife-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 170541423a11c144448bcf9deb2d90d9d3960460d5f99f8d72133d3b58d59c79
MD5 28046346c588f150f8ca637f33cafaa2
BLAKE2b-256 287b5b5a4c53328ea761ae91dc2361872f0973cffeec5499b15385307c194216

See more details on using hashes here.

Provenance

The following attestation bundles were made for deeplife-1.0.3-py3-none-any.whl:

Publisher: pypi-publish.yml on deeplifeai/deeplife

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.0.5

2 files

1.0.4

2 files

This release

1.0.3 This release

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.0.1

2 files

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