This tutorial builds an advanced multiagent pipeline to interpret integrated omics data including transcriptomics and proteomics. It also includes metabolomics. The goal is to reveal key biological insights. To begin, we generate coherent synthetic datasets to mimic real biological trends. Next, agents are used for network inference, pathway enhancement, statistical analysis, and drug repurposing. We use each component to build a complex interpretation system that helps us identify genes of importance, generate hypotheses, and infer causal connections. Click here to see the FULL CODES here.
Import numpy as an np
import pandas as pd
Deque import collections defaultdict
Import dataclasses from dataclasses
Typing import Dict list, Tuple
import warnings
warnings.filterwarnings('ignore')
PATHWAY_DB = {
'Glycolysis': {'genes': ['HK2', 'PFKM', 'PKM', 'LDHA', 'GAPDH', 'ENO1'],
'metabolites': ['Glucose', 'G6P', 'F16BP', 'Pyruvate', 'Lactate'], 'score': 0},
'TCA_Cycle': {'genes': ['CS', 'IDH1', 'IDH2', 'OGDH', 'SDHA', 'MDH2'],
'metabolites': ['Citrate', 'Isocitrate', 'α-KG', 'Succinate', 'Malate'], 'score': 0},
'Oxidative_Phosphorylation': {'genes': ['NDUFA1', 'NDUFB5', 'COX5A', 'COX7A1', 'ATP5A1', 'ATP5B'],
'metabolites': ['ATP', 'ADP', 'NAD+', 'NADH'], 'score': 0},
'Fatty_Acid_Synthesis': {'genes': ['ACACA', 'FASN', 'SCD1', 'ACLY'],
'metabolites': ['Malonyl-CoA', 'Palmitate', 'Oleate'], 'score': 0},
'Fatty_Acid_Oxidation': {'genes': ['CPT1A', 'ACOX1', 'HADHA', 'ACADM'],
'metabolites': ['Acyl-CoA', 'Acetyl-CoA'], 'score': 0},
'Amino_Acid_Metabolism': {'genes': ['GOT1', 'GOT2', 'GLUD1', 'BCAT1', 'BCAT2'],
'metabolites': ['Glutamate', 'Glutamine', 'Alanine', 'Aspartate'], 'score': 0},
'Pentose_Phosphate': {'genes': ['G6PD', 'PGD', 'TKTL1'],
'metabolites': ['R5P', 'NADPH'], 'score': 0},
'Cell_Cycle_G1S': {'genes': ['CCND1', 'CDK4', 'CDK6', 'RB1', 'E2F1'], 'metabolites': [], 'score': 0},
'Cell_Cycle_G2M': {'genes': ['CCNB1', 'CDK1', 'CDC25C', 'WEE1'], 'metabolites': [], 'score': 0},
'Apoptosis': {'genes': ['BCL2', 'BAX', 'BID', 'CASP3', 'CASP8', 'CASP9'], 'metabolites': [], 'score': 0},
'mTOR_Signaling': {'genes': ['MTOR', 'RPTOR', 'RICTOR', 'AKT1', 'TSC1', 'TSC2'],
'metabolites': ['Leucine', 'ATP'], 'score': 0},
'HIF1_Signaling': {'genes': ['HIF1A', 'EPAS1', 'VEGFA', 'SLC2A1'], 'metabolites': ['Lactate'], 'score': 0},
'p53_Signaling': {'genes': ['TP53', 'MDM2', 'CDKN1A', 'BAX'], 'metabolites': [], 'score': 0},
'PI3K_AKT': {'genes': ['PIK3CA', 'AKT1', 'AKT2', 'PTEN', 'PDK1'], 'metabolites': [], 'score': 0},
}
GENE_INTERACTIONS = {
'HK2': ['PFKM', 'HIF1A', 'MTOR'], 'PFKM': ['PKM', 'HK2'], 'PKM': ['LDHA', 'HIF1A'],
'MTOR': ['AKT1', 'HIF1A', 'TSC2'], 'HIF1A': ['VEGFA', 'SLC2A1', 'PKM', 'LDHA'],
'TP53': ['MDM2', 'CDKN1A', 'BAX', 'CASP3'], 'AKT1': ['MTOR', 'TSC2', 'MDM2'],
'CCND1': ['CDK4', 'RB1'], 'CDK4': ['RB1'], 'RB1': ['E2F1'],
}
DRUG_TARGETS = {
'Metformin': ['NDUFA1'], 'Rapamycin': ['MTOR'], '2-DG': ['HK2'],
'Bevacizumab': ['VEGFA'], 'Palbociclib': ['CDK4', 'CDK6'], 'Nutlin-3': ['MDM2']
}
@dataclass
class OmicsProfile:
transcriptomics: pd.DataFrame
proteomics: pd.DataFrame
metabolomics: pd.DataFrame
The Dict
The biological basis of the system is established. We define pathway databases, gene–gene interactions, and drug–target mappings that serve as the reference network for all downstream analyses. Also, we create an organized data class and import libraries. Visit the FULL CODES here.
class AdvancedOmicsGenerator:
@staticmethod
def generate_coherent_omics(n_samples=30, n_timepoints=4, noise=0.2):
List(g for PATHWAY_DB.values)() For example, if you want to write g instead of p['genes']))
Metabolites = set(m for PATHWAY_DB.values() This is a m in P['metabolites'] If m), then m"
proteins = [f"P_{g}" for g in genes]
n_control = n_samples // 2
samples_per_tp = n_samples // n_timepoints
trans = np.random.randn(len(genes), n_samples) * noise + 10
metab = np.random.randn(len(metabolites), n_samples) * noise + 5
For tp within range(n_timepoints), use:
start_idx = n_control + tp * samples_per_tp
end_idx = start_idx + samples_per_tp
Progression = (tp+1) / N_timepoints
For i, the gene is enumerate (genes).
if gene in PATHWAY_DB['Glycolysis']['genes']:
You can also transact with us[i, start_idx:end_idx] += np.random.uniform(1.5, 3.5) * progression
elif gene in PATHWAY_DB['Oxidative_Phosphorylation']['genes']:
You can also transact with us[i, start_idx:end_idx] -= np.random.uniform(1, 2.5) * progression
elif gene in PATHWAY_DB['Cell_Cycle_G1S']['genes'] + PATHWAY_DB['Cell_Cycle_G2M']['genes']:
You can also transact with us[i, start_idx:end_idx] += np.random.uniform(1, 2) * progression
elif gene in PATHWAY_DB['HIF1_Signaling']['genes']:
You can also transact with us[i, start_idx:end_idx] += np.random.uniform(2, 4) * progression
elif gene in PATHWAY_DB['p53_Signaling']['genes']:
You can also transact with us[i, start_idx:end_idx] -= np.random.uniform(0.5, 1.5) * progression
for i, met in enumerate(metabolites):
if met in ['Lactate', 'Pyruvate', 'G6P']:
The Metab[i, start_idx:end_idx] += np.random.uniform(1.5, 3) * progression
elif met in ['ATP', 'Citrate', 'Malate']:
The Metab[i, start_idx:end_idx] -= np.random.uniform(1, 2) * progression
elif met in ['NADPH']:
The Metab[i, start_idx:end_idx] += np.random.uniform(1, 2) * progression
prot = trans * 0.8 + np.random.randn(*trans.shape) * (noise * 2)
Condition = ['Control'] * n_control + [f'Disease_T{i//samples_per_tp}' for i in range(n_samples - n_control)]
trans_df = pd.DataFrame(trans, index=genes, columns=[f"S{i}_{c}" for i, c in enumerate(conditions)])
prot_df = pd.DataFrame(prot, index=proteins, columns=trans_df.columns)
metab_df = pd.DataFrame(metab, index=metabolites, columns=trans_df.columns)
metadata = {'conditions': conditions, 'n_timepoints': n_timepoints}
return OmicsProfile(trans_df, prot_df, metab_df, metadata)
Class StatisticalAgent
@staticmethod
def differential_analysis(data_df, control_samples, disease_samples):
Control = data_df[control_samples]
Data_df = disease[disease_samples]
fc = (disease.mean(axis=1) - control.mean(axis=1))
pooled_std = np.sqrt((control.var(axis=1) + disease.var(axis=1)) / 2)
t_stat = (pooled_std plus 1e-6)
p_values = 2 * (1 - np.minimum(np.abs(t_stat) / (np.abs(t_stat).max() + 1e-6), 0.999))
sorted_pvals = np.sort(p_values)
ranks = np.searchsorted(sorted_pvals, p_values) + 1
fdr = p_values * len(p_values) / ranks
return pd.DataFrame({'log2FC': fc, 't_stat': t_stat, 'p_value': p_values,
'FDR': np.minimum(fdr, 1.0), 'significant': (np.abs(fc) > 1.0) & (fdr < 0.05)}).sort_values('log2FC', ascending=False)
@staticmethod
def temporal_analysis(data_df, metadata):
Timepoints = Metadata['n_timepoints']
samples_per_tp = data_df.shape[1] // (timepoints + 1)
trends = {}
for gene in data_df.index:
means = []
For the tp range:
start = samples_per_tp + tp * samples_per_tp
Get the sample count by adding up all of your samples.
means.append(data_df.iloc[:, start:end].loc[gene].mean())
if len(means) > 1:
x = np.arange(len(means))
coeffs = np.polyfit(x, means, deg=min(2, len(means)-1))
You can also check out our other blog posts.[gene] = {Coeffs[0] if len(coeffs) > 1 else 0, 'trajectory': means}
Return Trends
The initial statistical analysis and generation of multi-omics synthetic data are our main focus. We simulate the progression of disease across multiple timepoints. Then, we compute fold-changes, p values, and significance levels corrected for FDR, for genes, proteins and metabolites. We examine temporal changes to see how the expression of genes and proteins evolves over time. Look at the FULL CODES here.
class NetworkAnalysisAgent:
def __init__(self, interactions):
Self-graph = interaction
def find_master_regulators(self, diff_genes):
sig_genes = diff_genes[diff_genes['significant']].index.tolist()
impact_scores = {}
for gene in sig_genes:
if gene in self.graph:
downstream = self._bfs_downstream(gene, max_depth=2)
sig_downstream = [g for g in downstream if g in sig_genes]
impact_scores[gene] = {
'downstream_count': len(downstream),
'sig_downstream': len(sig_downstream),
'score': len(sig_downstream) / (len(downstream) + 1),
'fc': diff_genes.loc[gene, 'log2FC']
}
return sorted(impact_scores.items()", key=lambda" x:[1]['score'], reverse=True)
def _bfs_downstream(self, start, max_depth=2):
visited, queue = set(), deque([(start, 0)])
The downstream is: []
While you wait
node, depth = queue.popleft()
if depth >= max_depth or node in visited:
Continue reading
visited.add(node)
If node is in the self.graph
For neighbor, self.[node]:
If the neighbor is not visited
downstream.append(neighbor)
queue.append((neighbor, depth + 1))
return downstream
def causal_inference(self, diff_trans, diff_prot, diff_metab):
causal_links = []
for gene in diff_trans[diff_trans['significant']].index:
gene_fc = diff_trans.loc[gene, 'log2FC']
protein = f"P_{gene}"
if protein in diff_prot.index:
prot_fc = diff_prot.loc[protein, 'log2FC']
Correlation = np.sign (gene_fc). == np.sign (prot_fc).
if correlation and abs(prot_fc) > 0.5:
causal_links.append(('transcription', gene, protein, gene_fc, prot_fc))
PATHWAY_DB.items is the content of the path.():
if gene in content['genes']:
For metab, in the content['metabolites']:
If metab is in diff_metab.index or diff_metab.loc[metab, 'significant']:
metab_fc = diff_metab.loc[metab, 'log2FC']
causal_links.append(('enzymatic', gene, metab, gene_fc, metab_fc))
Return causal_links
The network analysis agent identifies master controllers and determines causal relations. We use graph traversal in order to determine the effect of each gene and identify links between transcriptional and proteomic layers. We can use this to determine which nodes are most important for biological processes. Take a look at the FULL CODES here.
class PathwayEnrichmentAgent:
def __init__(self, pathway_db, interactions):
self.pathway_db = pathway_db
Self.interactions is the same as interactions
def topology_weighted_enrichment(self, diff_genes, diff_metab, network_agent):
enriched = {}
for pathway, content in self.pathway_db.items():
sig_genes = [g for g in content['genes'] If g is in diff_genes.index, and diff_genes.loc[g, 'significant']]
weighted_score = 0
for gene in sig_genes:
base_score = abs(diff_genes.loc[gene, 'log2FC'])
downstream = network_agent._bfs_downstream(gene, max_depth=1)
The centrality of the system is equal to len(downstream).
weighted_score += base_score * (1 + centrality)
sig_metabs = [m for m in content['metabolites'] If m is in diff_metab.index or diff_metab.loc[m, 'significant']]
metab_score = sum(abs(diff_metab.loc[m, 'log2FC'](m for sig_metabs).
total_score = (weighted_score + metab_score * 2) / max(len(content['genes']) + len(content['metabolites']), 1)
if total_score > 0.5:
enriched[pathway] = {'score': total_score, 'genes': sig_genes, 'metabolites': sig_metabs,
'gene_fc': {g: diff_genes.loc[g, 'log2FC'] for g in sig_genes},
'metab_fc': {m: diff_metab.loc[m, 'log2FC'] for m in sig_metabs},
'coherence': self._pathway_coherence(sig_genes, diff_genes)}
return enriched
def _pathway_coherence(self, genes, diff_genes):
if len(genes) < 2:
Return to 0
The fcs is [diff_genes.loc[g, 'log2FC'] For g in gene]
Same_direction = Sum(1 for each fc and fcs in the case where np.sign (fc) >= np.sign (fcs[0]))
return same_direction / len(genes)
By incorporating topology weighted enrichment analyses, we add pathway-level analysis. To reflect their wider influence, we weigh them based on network centrality. We then assess which pathways are significantly active or suppressed. It also measures pathway coherence to determine whether the genes within a particular pathway move in one direction. Click here to see the FULL CODES here.
class DrugRepurposingAgent:
def __init__(self, drug_db):
self.drug_db = drug_db
def predict_drug_response(self, diff_genes, master_regulators):
Predictions []
Self.drug_db.items contains drug targets():
Score = 0
affected_targets = []
Targets:
if target in diff_genes.index:
fc = diff_genes.loc[target, 'log2FC']
is_sig = diff_genes.loc[target, 'significant']
If_sig_is_true
drug_benefit = -fc if fc > 0 else 0
Score += Drug_Benefit
affected_targets.append((target, fc))
IF target in [mr[0] Master_regulators[:5]]:
Score += 2
if score > 0:
predictions.append({
'drug': drug,
'score': score,
'targets': affected_targets,
Inhibition of pathway upregulated
})
Sorted(predictions key=lambda, x:['score'], reverse=True)
Class AIHypothesisEngine
def generate_comprehensive_report(self, omics_data, analysis_results):
Report ["="*80, "ADVANCED MULTI-OMICS INTERPRETATION REPORT", "="*80, ""]
Trends = Analysis_Results['temporal']
top_trends = sorted(trends.items(), key=lambda x: abs(x[1]['slope']), reverse=True)[:5]
report.append(" TEMPORAL DYNAMICS ANALYSIS -
Top_trends for data on gene:
Direction = "↑ Increasing" if data['slope'] > 0 else "↓ Decreasing"
report.append(f" {gene}: {direction} (slope: {data['slope']:.3f})")
report.append("n
Top 5 ):") Master Regulators
For gene, results in analysis['master_regs'][:5]:
report.append(f" • {gene}: Controls {data['sig_downstream']} dysregulated genes (FC: {data['fc']:+.2f}, Impact: {data['score']:.3f})")
report.append("n
"ENHANCED PATHWAYS"
for pathway, data in sorted(analysis_results['pathways'].items()", key=lambda" x:[1]['score'], reverse=True):
report.append(f"n ► {pathway} (Score: {data['score']:.3f}, Coherence: {data['coherence']:.2f})")
report.append(f" Genes: {', '.join(data['genes'][:6])}")
if data['metabolites']:
report.append(f" Metabolites: {', '.join(data['metabolites'][:4])}")
report.append("n
Top 10 ):") CAUSAL RELATIONSHIPS
For link_type in the analysis_results, it will include source, destination, fc1, and fc2.['causal'][:10]:
report.append(f" {source} →[{link_type}]→ {target} (FC: {fc1:+.2f} → {fc2:+.2f})")
report.append("n
"DRUG REPURPOSING - PREDICTIONS"
Analysis_results for Pred['drugs'][:5]:
report.append(f" • {pred['drug']} (Score: {pred['score']:.2f})")
report.append(f" Targets: {', '.join([f'{t[0]}({t[1]:+.1f})' for t in pred['targets']])}")
report.append("n
AI-GENERATED HYPOTHESES BIOLOGICAL: n"
for i, hyp in enumerate(self._generate_advanced_hypotheses(analysis_results), 1):
report.append(f"{i}. {hyp}n")
report.append("="*80)
Return to the Homepage "n".join(report)
def _generate_advanced_hypotheses(self, results):
Hypotheses []
Pathways = Results['pathways']
if 'Glycolysis' in pathways and 'Oxidative_Phosphorylation' in pathways:
Glyc = Pathways['Glycolysis']['score']
oxphos = pathways['Oxidative_Phosphorylation']['score']
if glyc > oxphos * 1.5:
hypotheses.append(
"WARBURG EFFECT DETECTED: Aerobic glycolysis upregulation with oxidative phosphorylation suppression suggests metabolic reprogramming driven by HIF1A."
)
If you have a 'Cell_Cycle_G1S in Pathways and mTOR_Signaling in Pathways:
hypotheses.append(
"PROLIFERATIVE SIGNATURE: Cell-cycle activation with mTOR signaling indicates anabolic reprogramming; dual CDK4/6 and mTOR inhibition may be effective."
)
Results are not guaranteed['master_regs']:
Top_mr = Results['master_regs'][0]
hypotheses.append(
F"UPSTREAM REGULATOR: {top_mr[0]} controls {top_mr[1]['sig_downstream']} dysregulated genes; targeting this node can propagate network-wide correction."
)
Trends = Results['temporal']
The progressive is [g for g, d in trends.items() if abs(d['slope']) > 0.5]
if len(progressive) > 5:
hypotheses.append(
F"PROGRESSIVE DYSREGULATION: {len(progressive)} genes show strong temporal shifts, indicating evolving pathology and benefit from early pathway intervention."
)
If 'HIF1_Signaling" is in the pathways:
hypotheses.append(
"HYPOXIA RESPONSE: HIF1 signaling suggests oxygen-poor microenvironment; anti-angiogenic strategies may normalize perfusion."
)
If you see 'p53_Signaling in paths:
hypotheses.append(
"TUMOR SUPPRESSOR LOSS: p53 pathway suppression suggests benefit from MDM2 inhibition if TP53 is wild-type."
)
Return hypotheses in case hypotheses are not returned ["Complex multi-factorial dysregulation detected."]
Drug repurposing agents and hypothesis generators are introduced. Score potential drugs on dysregulation, network importance and target genes. Compile interpretational hypotheses linking pathway activity and possible interventions. Report generation summarizes the findings of these studies in a structured and readable format. Visit the FULL CODES here.
def run_advanced_omics_interpretation():
print("
Initializing Advanced Multi-Agent Omics System"
omics = AdvancedOmicsGenerator.generate_coherent_omics()
print("
Generated multi-omics dataset")
Stat_agent = StatisticalAgentResults =()
control_samples = [c for c in omics.transcriptomics.columns if 'Control' in c]
disease_samples = [c for c in omics.transcriptomics.columns if 'Disease' in c]
diff_trans = stat_agent.differential_analysis(omics.transcriptomics, control_samples, disease_samples)
diff_prot = stat_agent.differential_analysis(omics.proteomics, control_samples, disease_samples)
diff_metab = stat_agent.differential_analysis(omics.metabolomics, control_samples, disease_samples)
temporal = stat_agent.temporal_analysis(omics.transcriptomics, omics.metadata)
network_agent = NetworkAnalysisAgent(GENE_INTERACTIONS)
master_regs = network_agent.find_master_regulators(diff_trans)
causal_links = network_agent.causal_inference(diff_trans, diff_prot, diff_metab)
pathway_agent = PathwayEnrichmentAgent(PATHWAY_DB, GENE_INTERACTIONS)
enriched = pathway_agent.topology_weighted_enrichment(diff_trans, diff_metab, network_agent)
drug_agent = DrugRepurposingAgent(DRUG_TARGETS)
drug_predictions = drug_agent.predict_drug_response(diff_trans, master_regs)
results = {
'temporal': temporal,
'master_regs': master_regs,
'causal': causal_links,
'pathways': enriched,
'drugs': drug_predictions
}
AIHypothesisEngine()
report = hypothesis_engine.generate_comprehensive_report(omics, results)
print(report)
Results return omics
If the __name__ equals "__main__":
omics_data, analysis = run_advanced_omics_interpretation()
The entire workflow is orchestrated, with all agents running sequentially. Their results are then compiled into one comprehensive report. The pipeline is executed end-to-end from data collection to insights generation. We verify that all components contribute to the interpretation. The output of the pipeline is an actionable multi-omics analysis with an integrated view.
The tutorial showed how to connect different layers of Omics data using a modular, structured workflow. Combining statistical reasoning, topology of networks, and biological context we were able to produce a summary which highlights regulatory mechanisms as well as potential therapeutic approaches. The method is data-driven and clear. It can also be applied to real or simulated datasets.
Take a look at the FULL CODES here. Please feel free to browse our GitHub Page for Tutorials, Codes and Notebooks. Also, feel free to follow us on Twitter Don’t forget about our 100k+ ML SubReddit Subscribe now our Newsletter. Wait! Are you using Telegram? now you can join us on telegram as well.
This post is about Build a Multi-Agent System for Integrated Transcriptomic, Proteomic, and Metabolomic Data Interpretation with Pathway Reasoning First on MarkTechPost.

