Skip to content

API reference

Import the toolkit's main entry points as:

from deeplife.twincell import TwinCell, read_h5ad

Most workflows only use TwinCell — target validation (with its causal mechanism) and simulation. The Preprocessing helpers (pseudobulk() / pydeseq2()) are the upstream tools you use to build TwinCell's inputs.

Start with the data requirements

Every workflow expects raw counts, a condition label, and sample grouping (plus cell-type annotations for single-cell). See Data requirements before building a study.

TwinCell

The high-level study object and the helpers used to inspect its results. → full page

Object Summary
TwinCell Build a study from a control + perturbed AnnData pair and a DEG list.
TwinCell.target_validation Submit the arms + DEGs and run target validation for a target.
TwinCell.get_target_score Target efficacy (% of DEGs covered) and supporting detail.
TwinCell.get_causal_paths Ranked causal paths from the impacted DEGs to the target.
TwinCell.plot_causal_graph Render the target → DEGs causal graph.
TwinCell.get_degs_impacted_by_target DEGs with causal support above the model threshold.
TwinCell.get_all_degs DEGs that mapped onto the interactome.
read_h5ad Load an .h5ad file (local path or URL) into an AnnData.

Preprocessing

Notebook-friendly pseudobulk() / pydeseq2() helpers — the exact functions used in the tutorial. → full page

Function Summary
pseudobulk Aggregate single-cell AnnData into sample-level pseudo-bulk profiles (perturbation, cell_line, batch_id, n_min_replicates).
pydeseq2 Run PyDESeq2 differential expression on two arms (design_factor, control_group, log2fc_sig, mlog10pvalue_sig).

The standalone deeplife.pseudobulk / deeplife.differential_expression packages and their CLIs (twincell-pseudobulk, twincell-diffexpr) are summarized under Batch / CLI use on the same page.