pcNet: Computes a gene regulatory network based on principal...

Description Usage Arguments Details Value References Examples

View source: R/pcNet.R

Description

This function computes a gene regulatory network based on principal component regression (PCR), a technique based on principal component analysis. In PCR, the outcome variable is regressed over a nComp number of for principal components computed from a set of covariates to estimate the unknown regression coefficients in the model. pcNet function computes the PCR coefficients for each gene one at a time using all the others as covariates, to construct an all by all gene regulatory network.

Usage

1
2
3
4
5
6
7
8
9
pcNet(
  X,
  nComp = 3,
  scaleScores = TRUE,
  symmetric = FALSE,
  q = 0,
  verbose = TRUE,
  nCores = parallel::detectCores()
)

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. 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. Defines the cut-off threshold of top q% relationships to be returned.

verbose

A boolean value (TRUE/FALSE), if TRUE, a progress bar is shown.

nCores

An integer value. Defines the number of cores to be used.

Details

Principal component regression may be broadly divided into three major steps:

  1. Perform PCA on the observed covariates data matrix to obtain nComp number of the principal components.

  2. Regress the observed vector of outcomes on the selected principal components as covariates, using ordinary least squares regression to get a vector of estimated regression coefficients

  3. Transform this vector back to the scale of the actual covariates, using the eigenvectors corresponding to the selected principal components to get the final PCR estimator for estimating the regression coefficients characterizing the original model.

Value

A gene regulatory network in dgCMatrix format.

References

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(scTenifoldNet)

# Simulating of a dataset following a negative binomial distribution with high sparcity (~67%)
nCells = 2000
nGenes = 100
set.seed(1)
X <- rnbinom(n = nGenes * nCells, size = 20, prob = 0.98)
X <- round(X)
X <- matrix(X, ncol = nCells)
rownames(X) <- c(paste0('ng', 1:90), paste0('mt-', 1:10))

# Performing Single cell quality control
qcOutput <- scQC(
  X = X,
  minLibSize = 30,
  removeOutlierCells = TRUE,
  minPCT = 0.05,
  maxMTratio = 0.1
)

# Computing a single-cell gene regulatory network using principal component regression
# Non-symmetric
pcnetOutput <- pcNet(X = qcOutput, nComp = 3, scaleScores = TRUE, symmetric = FALSE, q = 0)
pcnetOutput[1:10,1:10]

# Symmetric
pcnetOutput <- pcNet(X = qcOutput, nComp = 3, scaleScores = TRUE, symmetric = TRUE, q = 0)
pcnetOutput[1:5,1:5]

Example output

10 x 10 sparse Matrix of class "dgCMatrix"
   [[ suppressing 10 column namesng1,ng2,ng3... ]]
                                                                    
ng1   .           1.077021e-02  0.016473187 -0.023585533  0.12402425
ng2  -0.02607322  .            -0.023892400  0.005330788  0.01886079
ng3   0.01557352 -3.178560e-02  .            0.096184386  0.01061588
ng4  -0.01971662  1.805290e-02  0.088842650  .            0.22399513
ng5   0.11736647  1.358439e-03  0.009529118  0.253772623  .         
ng6   0.05143466 -4.770325e-05 -0.034135316 -0.075622852 -0.03202026
ng7  -0.23030046  1.321160e-01  0.005441822  0.510377045  0.35729733
ng8   0.06414008  4.283480e-02 -0.142608166 -0.052987855  0.06115278
ng9   0.03971948  1.319026e-02  0.010274154  0.252954574  0.26717766
ng10  0.23560012 -8.871451e-03  0.031993022  0.126119200  0.22069422
                                                                   
ng1   9.114591e-03 -0.22503973  0.05139981  0.03237926 0.2078452679
ng2  -9.798429e-05  0.05617648  0.02983717  0.05303700 0.0007886476
ng3  -3.730091e-02  0.01508346 -0.13434367 -0.03770662 0.0145115551
ng4  -6.524852e-02  0.35917498 -0.05629773  0.28488850 0.1204480735
ng5  -4.273415e-02  0.31093029  0.05671861  0.34872939 0.2351658052
ng6   .            -0.11246618  0.03995390 -0.03240232 0.0194230165
ng7  -1.409269e-01  .           0.02302562  0.55414343 0.0909724897
ng8   3.529148e-02  0.01518856  .           0.18183621 0.1308546440
ng9   3.471133e-02  0.39186428  0.18753997  .          0.1886128756
ng10  4.259395e-02  0.03262423  0.15231725  0.21879783 .           
5 x 5 sparse Matrix of class "dgCMatrix"
             ng1          ng2         ng3         ng4        ng5
ng1  .           -0.008029349  0.01681461 -0.02272024 0.12665549
ng2 -0.008029349  .           -0.02921373  0.01226920 0.01060884
ng3  0.016814614 -0.029213731  .           0.09708198 0.01056989
ng4 -0.022720241  0.012269204  0.09708198  .          0.25068033
ng5  0.126655486  0.010608843  0.01056989  0.25068033 .         

scTenifoldNet documentation built on Oct. 29, 2021, 9:08 a.m.