Double Optimal Transport for Differential Gene Regulatory Network Inference with Unpaired Samples
Project description
ot-grn
Double Optimal Transport for Differential Gene Regulatory Network Inference with Unpaired Samples
ot-grn is a Python library designed to infer differential gene regulatory networks (GRNs) from gene expression data using optimal transport (OT) theory, applicable to unpaired samples. The library implements a robust and scalable framework, named Double OT, that integrates OT at the gene and sample levels to reconstruct GRNs effectively.
Features
- Data Preparaion: Generate simulated datasets; load real-world gastric cancer gene expression data.
- Network Inference: Use the Double OT method to align unpaired samples and infer regulatory relationships.
- Evaluation and Interpretation: Evaluate the inferred network using metrics like AUROC, AUPR, and early precision; extract key regulatory edges and genes from the inferred network.
Installation
You can install the library via pip:
pip install ot-grn
To install from source:
git clone https://github.com/Mengyu8042/ot-grn.git
cd ot-grn
pip install .
Quick Start
1. Simulation Studies
from ot_grn import generate_simulated_data, double_ot, evaluate_grn_accuracy
# (i) Generate synthetic normal and tumor expression data
exp1, exp2, true_plan = generate_simulated_data(p=500, n=100, diffgene=0.2, indegree=5)
# (ii) Infer differential GRN using Double OT method
ot_plan = double_ot(exp1, exp2)
# (iii) Calculate evaluation metrics for the inferred GRN
auroc, aupr, ep = evaluate_grn_accuracy(true_plan, ot_plan)
print(f"AUROC: {auroc}, AUPR: {aupr}, Early Precision: {ep}")
2. Real Data Analyses
from ot_grn import load_gastric_cancer_data, double_ot, extract_top_edges
# (i) Load normal and tumor expression data from gastric cancer patients
exp1, exp2 = load_gastric_cancer_data(same_source=True, paired=True)
# (ii) Infer differential GRN using Double OT method
ot_plan = double_ot(exp1, exp2)
# (iii) Extract top regulatory edges and key genes
gene_names = exp1.index.tolist()
top_edges, key_genes = extract_top_edges(ot_plan, gene_names, num=500)
print(top_edges)
print(key_genes)
Documentation
Core Functions
-
generate_simulated_data- Generates simulated datasets for testing GRN inference methods.
- Parameters:
p: Number of genes.n: Number of samples.diffgene(optional): Proportion of differentially expressed genes, by default 0.2.indegree(optional): Expected number of parents for differential genes, by default 5.snr(optional): Signal-to-noise ratio, by default 2.outlier_ratio(optional): Proportion of outliers, by default 0.
- Returns: Normal expression matrix, tumor expression matrix, and true regulatory relationships.
-
load_gastric_cancer_data- Loads gastric cancer gene expression data from the same or different sources.
- Parameters:
same_source(optional): If True, normal and tumor samples are from the same source, by default True.paired(optional): Only relevant ifsame_sourceis True. If True, samples are paired, by default True.
- Returns: Normal and tumor expression matrices.
-
double_ot- Implements the Double OT method for differential GRN inference.
- Parameters:
exp1: Expression matrix for condition 1 (e.g., normal state).exp2: Expression matrix for condition 2 (e.g., tumor state).paired(optional): If True, assumes the samples are paired. If False, uses partial OT to align samples, by default True.reg_m(optional): Marginal relaxation hyperparameter for robust OT, by default 0.05.reg(optional): Entropy regularization hyperparameter for partial OT and robust OT; either a scalar or a tuple (reg_pot, reg_rot), by default (0.005, 0.05).s(optional): Transport budget in partial OT, by default None (min(n_samples1, n_samples2)).n_components(optional): Number of principal components for PCA in sample alignment, by default None (all components).return_alignment(optional): If True and samples are unpaired (paired=False), returns the sample alignment result (sample-level OT plan), by default False.
- Returns: Gene-level OT plan (and sample-level OT plan).
-
evaluate_grn_accuracy- Calculate performance metrics for the inferred GRN.
- Parameters:
y_true: Ground truth binary labels (genes x genes).y_score: Predicted scores (genes x genes).
- Returns: AUROC, AUPR, Early Precision.
-
extract_top_edges- Extracts top regulatory edges and associated genes from the inferred GRN.
- Parameters:
y_score: Predicted scores (genes x genes).gene_names: List of gene names.num: Number of top edges to extract.
- Returns: DataFrame of top edges and a list of connected genes.
Dependencies
- Python 3.7 or higher
numpyscipypandasscikit-learnpot(Python Optimal Transport library)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
For questions, bug reports, or feature requests, please read our Contribution Guide. If your issue is not covered there, feel free to open a GitHub issue in the repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ot_grn-1.0.0.tar.gz.
File metadata
- Download URL: ot_grn-1.0.0.tar.gz
- Upload date:
- Size: 5.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
690911683106011acb18a797a20cdcf7c6bde388702ee681bea80379002cf6e5
|
|
| MD5 |
1e88858155325d7c2b61f06f63392787
|
|
| BLAKE2b-256 |
fd44e8ff09c73d3e68c9d3367a268e8f46d1442a4b314bfc3a122e3a53527bfa
|
File details
Details for the file ot_grn-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ot_grn-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
868678a09ca80548049fd1d2f93ee4ec18cc995cb3260f8899fa92c82a44dea5
|
|
| MD5 |
7e9d19821dd57478561236362747c9cb
|
|
| BLAKE2b-256 |
682019f86a8adffa9e38df3e79ecb78a2f2a1f0224e533ccb98ee3e07d9532bc
|