Skip to contents

Supports thresholding or top-k nearest neighbors to reduce matrix density, improving interpretability and biological signal in diffusion tasks.

Usage

prune_matrix(
  mat,
  value = NULL,
  auto = FALSE,
  target_sparsity = 0.05,
  verbose = TRUE
)

Arguments

mat

A square similarity matrix (e.g., TOM or adjacency)

value

A numeric threshold (if method = "threshold") or number of neighbors (if method = "topk")

auto

If TRUE, determine threshold automatically to achieve target sparsity

target_sparsity

Desired sparsity level (only used if auto = TRUE and method = "threshold")

verbose

If TRUE, prints pruning diagnostics

Value

A pruned matrix with zeroed weak connections