| name | bio-temporal-genomics-temporal-grn |
| description | Infers dynamic gene regulatory networks from bulk time-series expression data using Granger causality (statsmodels), dynGENIE3 (Extra-Trees on ODE-derived expression derivatives), and dynamic Bayesian networks (bnlearn). Identifies time-delayed regulatory relationships and tracks network rewiring across conditions. Use when inferring causal regulatory relationships from bulk temporal expression data or detecting TF influence propagation over time. Not for static co-expression networks (see gene-regulatory-networks/coexpression-networks). |
| tool_type | mixed |
| primary_tool | statsmodels |
Temporal Gene Regulatory Network Inference
Infers directed, time-delayed regulatory relationships from bulk time-series expression data. Captures how transcription factor activity propagates through gene regulatory networks over time.
Core Workflow
- Select candidate regulators (transcription factors) and target genes
- Prepare lagged expression matrices from time-series data
- Apply temporal inference method (Granger, dynGENIE3, or DBN)
- Filter significant regulatory edges by statistical threshold
- Compare networks across conditions or time windows
Granger Causality (Python/statsmodels)
Tests whether past values of gene X improve prediction of gene Y beyond past values of Y alone. Significant Granger causality suggests X temporally influences Y.
Pairwise Granger Test
import numpy as np
import pandas as pd
from statsmodels.tsa.stattools import grangercausalitytests
from statsmodels.stats.multitest import multipletests
tf_genes = ['TF1', 'TF2', 'TF3']
target_genes = ['geneA', 'geneB', 'geneC']
maxlag = 2
results = []
for tf in tf_genes:
for target in target_genes:
if tf == target:
continue
pair_data = pd.DataFrame({'target': expr_df.loc[target], 'tf': expr_df.loc[tf]}).values
gc_result = grangercausalitytests(pair_data, maxlag=maxlag, verbose=False)
min_p = min(gc_result[lag][0]['ssr_ftest'][1] for lag in range(1, maxlag + 1))
best_lag = min(range(1, maxlag + 1), key=lambda l: gc_result[l][0]['ssr_ftest'][1])
results.append({'tf': tf, 'target': target, 'p_value': min_p, 'best_lag': best_lag})
results_df = pd.DataFrame(results)
Multiple Testing Correction
reject, qvals, _, _ = multipletests(results_df['p_value'], method='fdr_bh')
results_df['q_value'] = qvals
significant_edges = results_df[results_df['q_value'] < 0.05].copy()
significant_edges = significant_edges.sort_values('q_value')
Build Adjacency Matrix
all_genes = list(set(tf_genes + target_genes))
adj_matrix = pd.DataFrame(0.0, index=all_genes, columns=all_genes)
for _, row in significant_edges.iterrows():
adj_matrix.loc[row['tf'], row['target']] = -np.log10(row['q_value'])
Stationarity Check
from statsmodels.tsa.stattools import adfuller
expr_df = expr_df.diff(axis=1).iloc[:, 1:]
dynGENIE3 (R)
Extension of GENIE3 for time-series data. Estimates expression derivatives from consecutive timepoints, then uses Extra-Trees regression to predict derivatives from current expression of candidate regulators.
Basic dynGENIE3
library(dynGENIE3)
expr_list <- list(as.matrix(expr_series1), as.matrix(expr_series2))
time_list <- list(c(0, 4, 8, 12, 24, 48), c(0, 4, 8, 12, 24, 48))
tf_indices <- which(rownames(expr_list[[1] tf_names
res dynGENIE3
TS.data expr_list
time.points time_list
regulators tf_indices
link_list get.link.listresweight.matrix report.max
headlink_list
With Known Regulators
tf_names <- readLines('tf_list.txt')
tf_idx <- which(rownames(expr_list[[1]]) %in% tf_names)
res_tf <- dynGENIE3(
TS.data = expr_list,
time.points = time_list,
regulators = tf_idx
)
Multiple Time Series
expr_list <- list(replicate1_mat, replicate2_mat, replicate3_mat)
time_list <- list(timepoints, timepoints, timepoints)
res_multi <- dynGENIE3(
TS.data = expr_list,
time.points = time_list,
regulators = tf_idx
)
Dynamic Bayesian Networks (R/bnlearn)
Models probabilistic dependencies between genes across time slices.
Structure Learning
library(bnlearn)
lagged_df <- data.frame()
for (t in 2:ncol(expr_mat)) {
row <- c(expr_mat[, t], expr_mat[, t - 1])
lagged_df <- rbind(lagged_df, row)
}
colnames(lagged_df) <- c(
paste0(rownames(expr_mat), '_t'),
paste0(rownames(expr_mat), '_t1')
)
dag hclagged_df score
edges arcsdag
temporal_edges edgesgrepl edges grepl edges
Bootstrap for Edge Confidence
boot_res <- boot.strength(lagged_df, algorithm = 'hc',
algorithm.args = list(score = 'bic-g'), R = 200)
confident_edges <- boot_res[boot_res$strength >= 0.7 & boot_res$direction >= 0.5, ]
Network Comparison Across Conditions
Jaccard Similarity of Edge Sets
def edge_jaccard(edges_a, edges_b):
set_a = set(map(tuple, edges_a))
set_b = set(map(tuple, edges_b))
intersection = len(set_a & set_b)
union = len(set_a | set_b)
if union == 0:
return 0.0
return intersection / union
jaccard = edge_jaccard(condition1_edges, condition2_edges)
Differential Edge Detection
edges_1 = set(map(tuple, condition1_edges))
edges_2 = set(map(tuple, condition2_edges))
gained_edges = edges_2 - edges_1
lost_edges = edges_1 - edges_2
conserved_edges = edges_1 & edges_2
Method Comparison
| Method | Approach | Strengths | Limitations |
|---|
| Granger causality | VAR model comparison | Statistically principled, pairwise | Assumes stationarity, linear |
| dynGENIE3 | ODE + tree regression | Non-linear, multi-regulator | No p-values, ranking-based |
| DBN (bnlearn) | Probabilistic graphical model | Multivariate, captures conditional dependencies | Computationally expensive |
Parameter Guide
| Parameter | Typical Value | Rationale |
|---|
| Granger maxlag | 1-3 | Need n > 3*maxlag timepoints; lag 1-2 captures most direct regulation |
| dynGENIE3 threshold | Top 1000-5000 edges | 10-50 edges per TF for focused networks |
| DBN bootstrap R | 200 | Standard for moderate datasets; increase to 500 for noisy data |
| DBN strength cutoff | 0.7 | Edge in >70% of bootstraps; conservative but reliable |
| Granger FDR | q < 0.05 | Standard multiple testing threshold |
Related Skills
- gene-regulatory-networks/coexpression-networks - Static co-expression networks
- gene-regulatory-networks/scenic-regulons - Single-cell regulon inference with pySCENIC
- gene-regulatory-networks/differential-networks - Condition-specific network comparison
- data-visualization/network-visualization - Network plotting with NetworkX and Cytoscape