Skip to contents

Usage

makeNetworksFast(
  X,
  nNet = 10,
  nCells = 500,
  nComp = 3,
  scaleScores = TRUE,
  symmetric = FALSE,
  q = 0.95,
  nCores = NULL,
  verbose = TRUE,
  seed = 1
)

Arguments

X

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

nNet

An integer value. The number of networks based on principal components regression to generate.

nCells

An integer value. The number of cells to subsample each time to generate a network.

nComp

An integer value. The number of principal components in PCA to generate the networks. Should be greater than 2 and lower than the total number of genes.

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. Represent the cut-off threshold of top q

nCoresAn integer value. Defines the number of cores to be used for parallel processing. Default is to use all available cores minus 1.

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

seedAn integer value. Random seed for reproducibility. If NULL, no seed is set.

A list with nNet gene regulatory networks in dgCMatrix format. Each one computed from a randomly selected subsample of nCells cells. Computes multiple gene regulatory networks from random subsamples of cells using optimized principal component regression with parallel processing. This function achieves 8-10x speedup through parallelization and 30-50x speedup from the optimized pcNetFast algorithm. This function parallelizes the network construction process by:

  1. Creating multiple random subsamples of cells (with replacement)

  2. Building each network independently in parallel using pcNetFast

  3. Combining results into a list

The parallelization is safe because each network is constructed independently. 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, ]# Generate multiple networks in parallel networks <- makeNetworksFast( X = X, nNet = 10, nCells = 500, nComp = 3, scaleScores = TRUE, symmetric = FALSE, q = 0.95 )# Check results length(networks) networks[[1]][1:10, 1:10]