Skip to main content

TxOptimus

Zero-shot drug repurposing via TxGNN on PrimeKG and OptimusKG.

TxOptimus is a unified Python package that wraps TxGNN (Huang et al., Nature Medicine, 2024) with two knowledge graph backends:

  • TxGNN Prime — the original baseline trained on Harvard PrimeKG
  • TxGNN Optimus — an enriched model trained on the Zitnik Lab's OptimusKG, a multimodal knowledge graph validated by LLM extraction (PaperQA3)

OptimusKG achieves a ~34% improvement in Macro AUROC over PrimeKG in zero-shot drug repurposing for oncology under the cell_proliferation split.

Installation

# Create a dedicated environment (recommended)
conda create -n txoptimus python=3.8
conda activate txoptimus

# Install DGL first (not available on PyPI, requires separate wheel)
# For CUDA 12.1:
pip install https://data.dgl.ai/wheels/torch-2.4/cu121/dgl-2.4.0%2Bcu121-cp38-cp38-manylinux1_x86_64.whl
# For CPU only:
# pip install https://data.dgl.ai/wheels/torch-2.4/cpu/dgl-2.4.0-cp38-cp38-manylinux1_x86_64.whl

# Install TxOptimus
pip install txoptimus

⚠ System Requirements:

  • RAM: ≥32 GB (OptimusKG loads a 21.8M-edge graph)
  • Storage: ≥8 GB free disk space
  • Python: 3.8+ (tested on 3.8.20)
  • GPU: Optional (CPU inference supported)

Quick Start

1. Download data files

txoptimus --setup              # downloads both PrimeKG and OptimusKG data
txoptimus --setup prime        # only PrimeKG
txoptimus --setup optimus      # only OptimusKG

2. Run zero-shot drug repurposing

# Using OptimusKG (recommended)
txoptimus --engine optimus --diseases "oral cavity cancer" "glioblastoma"

# Using PrimeKG baseline
txoptimus --engine prime --diseases "oral cavity cancer"

# Benchmark mode — runs both and generates a comparison report
txoptimus --engine benchmark --diseases "oral cavity cancer"

3. Fuzzy disease matching

TxOptimus uses PubMedBERT embeddings to fuzzy-match your disease terms against the knowledge graph vocabulary. If your input doesn't match exactly, the tool will show the top-10 closest matches and let you pick:

Disease term: "breast cancer"

Matched terms in OPTIMUS:
  [1] invasive breast carcinoma (similarity: 0.94)
  [2] breast carcinoma (similarity: 0.91)
  [3] triple-negative breast cancer (similarity: 0.89)

Select terms (e.g., '1 3' or 'all'): 1 3

4. Enable explainability & Subgraph Extraction (v0.1.9)

TxOptimus can automatically extract drug-specific, 2-hop biological subgraphs (e.g., Drug -> Target -> Disease) for your top candidate drugs to explain why the model made its prediction.

# Enable GraphMask for PrimeKG
txoptimus --engine prime --diseases "oral cavity cancer" --graphmask

# OptimusKG is too large for standard GraphMask. Use the --low-memory gradient workaround!
txoptimus --engine optimus --diseases "oral cavity cancer" --graphmask --low-memory

Note: Full GraphMask training requires ≥30 GB RAM and takes 2-4 hours on CPU. The --low-memory flag for Optimus bypasses this by using gradient attribution and explicit neighborhood intersection.

Full CLI Reference

Argument Type Default Description
--engine str optimus prime, optimus, or benchmark
--diseases str[] (required) Disease terms (fuzzy matched)
--graphmask flag False Enable GraphMask explainability
--low-memory flag False Use low-memory integrated gradients for Optimus
--output_dir str ./txoptimus_output Output directory
--prefix str txoptimus File prefix
--threads int 18 CPU threads
--top_k int 100 Drug candidates per disease
--setup str? — Download data (prime/optimus/both)
--data_dir str ~/.txoptimus Data directory override

Output Files

File Description
{prefix}_{engine}_results.json Full metrics (AUROC, AUPRC, per-relation, graph profile)
{prefix}_{engine}_candidates.csv Top-K drug candidates ranked by score
{prefix}_comparison_report.md Side-by-side comparison (benchmark mode only)
{prefix}_{engine}_drug_subgraphs.csv Automated 2-hop biological subgraphs explaining predictions

Citation

If you use TxOptimus in your research, please cite the original TxGNN paper:

@article{huang2024txgnn,
  title={Zero-shot prediction of therapeutic use with geometric deep learning and clinician centered design},
  author={Huang, Kexin and Chandak, Payal and Wang, Qianwen and Haber, Shreyas and Zitnik, Marinka},
  journal={Nature Medicine},
  year={2024}
}

License

MIT License — see LICENSE for details.

Author

arsalanriaz38[AT]gmail[DOT]com

Metadata

Release files for txoptimus 0.1.9

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

Source distribution (sdist)

Source distribution for txoptimus 0.1.9
File Size Uploaded Provenance Actions
txoptimus-0.1.9.tar.gz 2.5 MB Without provenance Details for txoptimus-0.1.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for txoptimus 0.1.9
File Interpreter ABI Platform Actions
txoptimus-0.1.9-py3-none-any.whl Python 3 none any Details for txoptimus-0.1.9-py3-none-any.whl

Total release size: 5.1 MB

Release files / txoptimus-0.1.9.tar.gz

Download URL txoptimus-0.1.9.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
1095f38619a0c859f53be52759e25b3c5565c66994362d6dd2fb48431f9791e6
BLAKE2b-256 checksum
How to use checksums
e160b927d61c1fa7e9f9f9d9d1a7984a383a97f8cf6f8808273580d9fd0c5221
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / txoptimus-0.1.9-py3-none-any.whl

Download URL txoptimus-0.1.9-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3c034a88b48b79d149d31c0a04d70ee12c5040bba7a9fda828950591ebf038d7
BLAKE2b-256 checksum
How to use checksums
db2b8ce1d42a83df8c5ef62f93d40fe53ea9f80d57d68fb711fd1d0e45c019f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Security for txoptimus 0.1.9

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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