iddn.bcd
Block coordinate descent for iDDN
This module implements the block coordinate descent in [1]. Most methods are also Numba accelerated.
For iddn_data with lots of samples, consider using bcd_corr. For iddn_data with lots of features, the bcd_residual is faster.
[1] Fu, Yi, et al. “DDN3. 0: Determining significant rewiring of biological network structure with differential dependency networks.” Bioinformatics (2024).
Functions
|
BCD algorithm for iDDN using residual update strategy |
|
BCD algorithm for iDDN using correlation matrix update strategy |
|
Optimize for two variables corresponding to one node |
Module Contents
- iddn.bcd.bcd_residual(beta_in, X1, X2, y1_resi, y2_resi, cur_node, dep_nodes, lambda1, lambda2, threshold, max_iter=10000)
BCD algorithm for iDDN using residual update strategy
The algorithm allows warm start, which requires initial beta_in, y1_resi, and y2_resi. See run_resi on how to prepare these inputs. Denote P be the number features. N1 be the sample size for condition 1, and N2 for condition 2.
- Parameters:
beta_in ((2P) array_like) – Initial beta. If initialization is not needed, use an array of all zeros
X1 ((N1,P) array_like) – The iddn_data from condition 1
X2 ((N2,P) array_like) – The iddn_data from condition 2
y1_resi ((N1,1) array_like) – The initial residual signal for condition 1. If warm start is not used, it is column CurrIdx of X1.
y2_resi ((N2,1) array_like) – The initial residual signal for condition 2. If warm start is not used, it is column CurrIdx of X2.
cur_node (int) – Index of the current node that serve as the response variable.
dep_nodes – Nodes that point to current node will be 1.
lambda1 (array_like) – DDN parameter lambda1.
lambda2 (array_like) – DDN parameter lambda2.
threshold (float) – Convergence threshold.
max_iter (int) – Maximum number of iterations
- Returns:
beta (ndarray, shape 2P) – Estimated beta for two conditions on node CurrIdx
r (int) – Number of iterations taken
betaerr (float) – The error term
- iddn.bcd.bcd_corr(beta_in, cur_node, dep_nodes, lambda1, lambda2, corr_matrix_1, corr_matrix_2, threshold=1e-06, max_iter=100000)
BCD algorithm for iDDN using correlation matrix update strategy
This approach is more suitable for larger sample sizes. The algorithm allows warm start, which requires initial beta_in. Denote P be the number features. N1 be the sample size for condition 1, and N2 for condition 2.
- Parameters:
beta_in (array_like, length 2P) – Initial beta. If initialization is not needed, use an array of all zeros
cur_node (int) – Index of the current node that serve as the response variable.
dep_nodes – Nodes that point to current node will be 1.
lambda1 (array_like) – DDN parameter lambda1.
lambda2 (array_like) – DDN parameter lambda2.
corr_matrix_1 (array_like, P by P) – Correlation matrix for condition 1
corr_matrix_2 (array_like, P by P) – Correlation matrix for condition 2
threshold (float) – Convergence threshold.
max_iter (int) – Maximum number of iterations
- Returns:
beta (ndarray, shape 2P) – Estimated beta for two conditions on node CurrIdx
r (int) – Number of iterations taken
delta_beta (float) – The error term
- iddn.bcd.solve2d(rho1, rho2, lambda1, lambda2)
Optimize for two variables corresponding to one node
The details can be found in https://arxiv.org/abs/1203.3532
- Parameters:
rho1 (float) – The rho from data1
rho2 (float) – The rho from data2
lambda1 (float) – DDN parameter lambda1
lambda2 (float) – DDN parameter lambda2
- Returns:
beta1 (float) – Optimal coefficient for data1
beta2 (float) – Optimal coefficient for data2