Skip to contents

Usage

pcNetFast(
  X,
  nComp = 3,
  scaleScores = TRUE,
  symmetric = FALSE,
  q = 0,
  verbose = TRUE,
  nCores = 1,
  use_approximate = FALSE
)

Arguments

X

A filtered and normalized gene expression matrix with cells as columns and genes as rows.

nComp

An integer value. The number of principal components in PCA to generate the networks.

scaleScores

A boolean value (TRUE/FALSE), if TRUE, the weights will be normalized such that the maximum absolute value is 1.

symmetric

A boolean value (TRUE/FALSE), if TRUE, the weights matrix returned will be symmetric.

q

A decimal value between 0 and 1. Defines the cut-off threshold of top q

verboseA boolean value (TRUE/FALSE), if TRUE, progress information is shown.

nCoresAn integer value. Defines the number of cores for BLAS operations (not for parallelization).

use_approximateLogical. If TRUE, uses approximate method (faster but less accurate). Default FALSE.

A gene regulatory network in dgCMatrix format. This is an optimized version of pcNet that maintains scientific accuracy while improving performance through efficient matrix operations, caching, and vectorization. Unlike naive batch approaches, this version uses smart caching of SVD results to avoid redundant computations while maintaining leave-one-out accuracy. This optimized implementation uses several strategies:

  1. Pre-standardization of the data matrix

  2. Vectorized operations where possible

  3. Efficient sparse matrix operations

  4. Smart memory management

When use_approximate=TRUE, it uses a global PCA approach (30-50x faster but correlation ~0.76 with original). When use_approximate=FALSE (default), it maintains leave-one-out accuracy with modest speedup (5-10x) through efficient matrix operations. library(scTenifoldKnk)# Simulating dataset nCells <- 2000 nGenes <- 100 set.seed(1) X <- rnbinom(n = nGenes * nCells, size = 20, prob = 0.98) X <- matrix(X, ncol = nCells) rownames(X) <- paste0("gene", 1:nGenes)# Quality control X <- X[rowSums(X) > 0, ]# Compute network (accurate, default) network <- pcNetFast(X, nComp = 3, use_approximate = FALSE)# Compute network (fast approximation) network_fast <- pcNetFast(X, nComp = 3, use_approximate = TRUE)