Computes a gene co-expression network using Principal Component Regression.
Each gene is regressed against principal components derived from all other genes.
A sparse matrix (Matrix::dgCMatrix) representing the gene network.
Entry [i,j] contains the regression coefficient from gene i to gene j.
Diagonal is always zero (no self-loops).
Arguments
X
A matrix with genes as rows and cells/samples as columns.
Can be a regular matrix or dgCMatrix (sparse).
Must have positive row sums (quality control applied).
nComp
Number of principal components to use for regression.
Must be >= 2 and < number of genes. Default: 3.
scaleScores
If TRUE (default), scales output network by maximum
absolute value to normalize edge weights to [-1, 1].
symmetric
If TRUE, symmetrizes the network matrix as (A + t(A))/2.
Default: FALSE.
q
Quantile threshold for filtering edges. Values below this
quantile are set to zero. Range: [0, 1]. Default: 0 (no filtering).
priorNetwork
A data.frame containing a prior gene regulatory network.
The data.frame must have two columns: `regulators` and `targets`.
Default: NULL.
verbose
If TRUE, prints progress updates. Default: FALSE.
nCores
Number of cores for parallelization. If > 1, uses future
backend (multisession). Default: 1 (sequential).
useRcpp
If TRUE (default), uses compiled Rcpp backend for faster
computation. Falls back to pure R if Rcpp backend unavailable.
Default: TRUE.
Details
Algorithm:
1. Standardize input matrix (center and scale by columns)
2. For each gene K:
a. Extract all other genes as design matrix (Xi)
b. Compute truncated SVD of Xi to get nComp principal components
c. Project gene K onto these components
d. Perform OLS regression to get coefficients
3. Assemble coefficients into sparse network matrix
4. Apply optional scaling and filtering