Skip to contents

Iteratively removes edges from an estimated network by evaluating the percentage of variation each edge explains in the target variable's trajectory. Edges explaining less than prune_thres are pruned. The process repeats up to depth times or until no further edges can be pruned. Applicable only when interaction_term = FALSE.

Supports pruning using multiple samples (cells) jointly, where edge contributions (\(R^2\)) are averaged across samples.

Usage

prune_network(
  network_original,
  prune_thres = 0.05,
  depth = NULL,
  eval_edge_R2_pruned = FALSE,
  Y_list,
  yy_smth_list,
  obs_time_list,
  tt,
  kernel,
  kernel_params_list,
  interaction_term,
  theta_initial_list = NULL,
  max_iter = 5,
  tol = 0.001,
  parallel = FALSE,
  mc.cores = NULL,
  verbose = 0
)

Arguments

network_original

The original network (adjacency matrix) to prune.

prune_thres

A number in [0, 1] that specifies the threshold for pruning. Edges explaining less than this proportion of variation are removed.

depth

Maximum number of pruning steps per variable. Use NULL to continue pruning until all edges meet the threshold.

eval_edge_R2_pruned

A logical value. If TRUE, evaluates the contribution (\(R^2\)) of each remaining edge in the pruned network.

Y_list

A list of observed trajectories (Y), each corresponding to a sample (cell). See kernelODE_step2() for the format of Y.

yy_smth_list

A list of smoothed trajectories (yy_smth).

obs_time_list

A list of standardized observation time points (obs_time).

tt

A numeric vector representing a finer time grid used for evaluating the smoothed trajectories and their derivatives.

kernel

Kernel function to use.

kernel_params_list

A list of kernel parameter lists (kernel_params).

interaction_term

A logical value specifying whether to include interaction effects in the model.

theta_initial_list

A list of initial \(\theta_j\) matrices for iterative optimization (theta_initial).

max_iter

Maximum number of iterations for the optimization.

tol

Convergence tolerance for the relative improvement in the Frobenius norm of the \(\theta\) matrix.

parallel

A logical value. If TRUE, use parallel computing (Linux/macOS only). Parallelization is applied over variables and samples.

mc.cores

An integer specifying the number of cores for parallel computing. Defaults to all but one available cores.

verbose

Integer; if greater than 0, prints progress messages during optimization.

Value

A list with components:

res_prune_path

History of pruning steps.

network_pruned

Final pruned network.

R2_avg_mat_pruned

\(R^2\) contribution per edge in the pruned network, averaged across all samples. Set to NULL if eval_edge_R2_pruned = FALSE.

R2_multi_arr_pruned

Per-sample edge \(R^2\) contributions. Set to NULL if eval_edge_R2_pruned = FALSE.

config

List of pruning configuration and inputs.

Examples

set.seed(1)
obs_time <- seq(0, 1, length.out = 10)
Y <- cbind(sin(2 * pi * obs_time), cos(4 * pi * obs_time)) + 0.1 * matrix(rnorm(20), 10, 2)  # each col is a variable
tt <- seq(0, 1, length.out = 100)
res_step1 <- kernelODE_step1(Y = Y, obs_time = obs_time, tt = tt)

kernel <- "gaussian"
kernel_params <- auto_select_kernel_params(kernel = kernel, Y = Y)
res_step2 <- kernelODE_step2(Y = Y, obs_time = obs_time, yy_smth = res_step1$yy_smth, tt = tt, kernel = kernel, kernel_params = kernel_params)

res_prune <- prune_network(network_original = res_step2$network_est,
                           depth = 1,
                           Y_list = list(Y),  # fed in as a list
                           yy_smth_list = list(res_step1$yy_smth),  # fed in as a list
                           obs_time_list = list(obs_time),  # fed in as a list
                           tt = tt,
                           kernel = kernel,
                           kernel_params_list = list(kernel_params),  # fed in as a list
                           interaction_term = FALSE)
#> Note: R2 increases when removing these edges:  1->2 
network_pruned <- res_prune$network_pruned
network_pruned
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    1    1