| Title: | In-Silico Knockout Experiments from Single-Cell Gene Regulatory Networks |
|---|---|
| Description: | A workflow based on 'scTenifoldNet' to perform in-silico knockout experiments using single-cell RNA sequencing (scRNA-seq) data from wild-type (WT) control samples as input. First, the package constructs a single-cell gene regulatory network (scGRN) and knocks out a target gene from the adjacency matrix of the WT scGRN by setting the gene’s outdegree edges to zero. Then, it compares the knocked out scGRN with the WT scGRN to identify differentially regulated genes, called virtual-knockout perturbed genes, which are used to assess the impact of the gene knockout and reveal the gene’s function in the analyzed cells. |
| Authors: | Daniel Osorio [aut, cre] (ORCID: <https://orcid.org/0000-0003-4424-8422>), Yan Zhong [aut, ctb], Guanxun Li [aut, ctb], Qian Xu [aut, ctb], Yongjian Yang [aut, ctb], Yanan Tian [aut, ctb], Robert Chapkin [aut, ctb], Jianhua Huang [aut, ctb], James J. Cai [aut, ctb, ths] (ORCID: <https://orcid.org/0000-0002-8081-6725>) |
| Maintainer: | Daniel Osorio <[email protected]> |
| License: | GPL (>=2) |
| Version: | 1.1 |
| Built: | 2026-07-10 21:52:08 UTC |
| Source: | https://github.com/cailab-tamu/sctenifoldknk |
Using the output of the non-linear manifold alignment, this function computes the Euclidean distance between the coordinates for the same gene in both conditions. Calculated distances are then transformed using Box-Cox power transformation, and standardized to ensure normality. P-values are assigned following the chi-square distribution over the fold-change of the squared distance computed with respect to the expectation.
dRegulation(manifoldOutput)dRegulation(manifoldOutput)
manifoldOutput |
A matrix. The output of the non-linear manifold
alignment, a labeled matrix with two times the number of shared genes as
rows (X_ genes followed by Y_ genes in the same order) and |
A data frame with 6 columns as follows:
gene A character vector with the gene id identified from the
manifoldAlignment output.
distance A numeric vector of the Euclidean distance computed
between the coordinates of the same gene in both conditions.
Z A numeric vector of the Z-scores computed after Box-Cox power
transformation.
FC A numeric vector of the FC computed with respect to the
expectation.
p.value A numeric vector of the p-values associated to the
fold-changes, probabilities are assigned as using the
Chi-square distribution with one degree of freedom.
p.adj A numeric vector of adjusted p-values using Benjamini &
Hochberg (1995) FDR correction.
Benjamini, Y., and Yekutieli, D. (2001). The control of the false discovery rate in multiple testing under dependency. Annals of Statistics, 29, 1165-1188. doi: 10.1214/aos/1013699998.
library(scTenifoldKnk) # Simulating a dataset following a negative binomial distribution with high sparsity (~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 3 gene regulatory networks from subsamples of 500 cells xNetworks <- scTenifoldNet::makeNetworks( X = qcOutput, nNet = 3, nCells = 500, nComp = 3, scaleScores = TRUE, symmetric = FALSE, q = 0.95 ) # Computing a K = 3 CANDECOMP/PARAFAC (CP) Tensor Decomposition tdOutput <- scTenifoldNet::tensorDecomposition(xNetworks, K = 3, maxError = 1e5, maxIter = 1e3) ## Not run: # Computing the manifold alignment maOutput <- scTenifoldNet::manifoldAlignment(tdOutput$X, tdOutput$X) # Evaluating differential regulation drOutput <- dRegulation(maOutput) head(drOutput) # Plotting — genes with FDR < 0.05 colored in red geneColor <- ifelse(drOutput$p.adj < 0.05, 'red', 'black') qqnorm(drOutput$Z, main = 'Standardized Distance', pch = 16, col = geneColor) qqline(drOutput$Z) ## End(Not run)library(scTenifoldKnk) # Simulating a dataset following a negative binomial distribution with high sparsity (~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 3 gene regulatory networks from subsamples of 500 cells xNetworks <- scTenifoldNet::makeNetworks( X = qcOutput, nNet = 3, nCells = 500, nComp = 3, scaleScores = TRUE, symmetric = FALSE, q = 0.95 ) # Computing a K = 3 CANDECOMP/PARAFAC (CP) Tensor Decomposition tdOutput <- scTenifoldNet::tensorDecomposition(xNetworks, K = 3, maxError = 1e5, maxIter = 1e3) ## Not run: # Computing the manifold alignment maOutput <- scTenifoldNet::manifoldAlignment(tdOutput$X, tdOutput$X) # Evaluating differential regulation drOutput <- dRegulation(maOutput) head(drOutput) # Plotting — genes with FDR < 0.05 colored in red geneColor <- ifelse(drOutput$p.adj < 0.05, 'red', 'black') qqnorm(drOutput$Z, main = 'Standardized Distance', pch = 16, col = geneColor) qqline(drOutput$Z) ## End(Not run)
Generate and plot a KO-centered subnetwork from the output of
scTenifoldKnk. The function selects genes with significant
differential regulation (FDR < 0.05), extracts their interactions from the
reconstructed WT network, filters edges by weight quantile, and displays
the network using igraph. When annotate = TRUE the function
queries enrichment databases via enrichR and overlays category pies
on nodes with a legend of significant terms.
plotKO( X, gKO, q = 0.99, annotate = TRUE, nCategories = 20, fdrThreshold = 0.05 )plotKO( X, gKO, q = 0.99, annotate = TRUE, nCategories = 20, fdrThreshold = 0.05 )
X |
A list. Output from |
gKO |
Character. Gene symbol of the simulated knockout gene. |
q |
Numeric. Edge-weight quantile used to threshold weak edges. Default: 0.99. |
annotate |
Logical. If |
nCategories |
Integer. Maximum number of enrichment categories to show in the legend. Default: 20. |
fdrThreshold |
Numeric. Adjusted p-value cutoff (FDR) for reporting enriched terms. Default: 0.05. |
Invisibly returns NULL. Called for the side effect of
plotting the network.
## Not run: library(scTenifoldKnk) # Load example data scRNAseq <- system.file("single-cell/example.csv", package = "scTenifoldKnk") scRNAseq <- read.csv(scRNAseq, row.names = 1) # Run scTenifoldKnk output <- scTenifoldKnk(countMatrix = scRNAseq, gKO = "G100", qc_minLibSize = 0) # Plot the KO-centered subnetwork with enrichment annotation plotKO(output, gKO = "G100") # Plot without enrichment annotation plotKO(output, gKO = "G100", annotate = FALSE) ## End(Not run)## Not run: library(scTenifoldKnk) # Load example data scRNAseq <- system.file("single-cell/example.csv", package = "scTenifoldKnk") scRNAseq <- read.csv(scRNAseq, row.names = 1) # Run scTenifoldKnk output <- scTenifoldKnk(countMatrix = scRNAseq, gKO = "G100", qc_minLibSize = 0) # Plot the KO-centered subnetwork with enrichment annotation plotKO(output, gKO = "G100") # Plot without enrichment annotation plotKO(output, gKO = "G100", annotate = FALSE) ## End(Not run)
This function performs quality control filters over the provided input matrix. It checks for minimum cell library size, mitochondrial ratio, outlier cells, and the fraction of cells where a gene is expressed.
scQC( X, minLibSize = 1000, removeOutlierCells = TRUE, minPCT = 0.05, maxMTratio = 0.1, label = NULL )scQC( X, minLibSize = 1000, removeOutlierCells = TRUE, minPCT = 0.05, maxMTratio = 0.1, label = NULL )
X |
Raw counts matrix with cells as columns and genes (symbols) as rows. |
minLibSize |
An integer value. Defines the minimum library size required for a cell to be included in the analysis. |
removeOutlierCells |
A boolean value ( |
minPCT |
A decimal value between 0 and 1. Defines the minimum fraction of cells where the gene needs to be expressed to be included in the analysis. |
maxMTratio |
A decimal value between 0 and 1. Defines the maximum ratio of mitochondrial reads (mitochondrial reads / library size) present in a cell to be included in the analysis. It's computed using the symbol genes starting with 'MT-' non-case sensitive. |
label |
Optional character label prepended to progress messages when running inside a pipeline. |
A dgCMatrix object with the cells and the genes that pass the quality control filters.
Ilicic, Tomislav, et al. "Classification of low quality cells from single-cell RNA-seq data." Genome biology 17.1 (2016): 29.
library(scTenifoldKnk) # Simulating a dataset following a negative binomial distribution with high sparsity (~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 ) # Comparing dimensions before and after QC dim(X) dim(qcOutput)library(scTenifoldKnk) # Simulating a dataset following a negative binomial distribution with high sparsity (~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 ) # Comparing dimensions before and after QC dim(X) dim(qcOutput)
Predict gene perturbations using in-silico knockout experiments from single-cell gene regulatory networks.
scTenifoldKnk( countMatrix, gKO = NULL, qc = TRUE, qc_minLibSize = 1000, qc_removeOutlierCells = TRUE, qc_minPCT = 0.05, qc_maxMTratio = 0.1, nc_lambda = 0, nc_nNet = 10, nc_nCells = 500, nc_nComp = 3, nc_scaleScores = TRUE, nc_symmetric = FALSE, nc_q = 0.9, nc_priorNetwork = NULL, td_K = 3, td_maxIter = 1000, td_maxError = 1e-05, td_nDecimal = 3, ma_nDim = 2, nCores = parallel::detectCores() )scTenifoldKnk( countMatrix, gKO = NULL, qc = TRUE, qc_minLibSize = 1000, qc_removeOutlierCells = TRUE, qc_minPCT = 0.05, qc_maxMTratio = 0.1, nc_lambda = 0, nc_nNet = 10, nc_nCells = 500, nc_nComp = 3, nc_scaleScores = TRUE, nc_symmetric = FALSE, nc_q = 0.9, nc_priorNetwork = NULL, td_K = 3, td_maxIter = 1000, td_maxError = 1e-05, td_nDecimal = 3, ma_nDim = 2, nCores = parallel::detectCores() )
countMatrix |
Raw counts matrix with cells as columns and genes (symbols) as rows. |
gKO |
Character. Gene symbol of the gene to knock out. |
qc |
A boolean value (TRUE/FALSE), if TRUE, a quality control is applied over the data. |
qc_minLibSize |
An integer value. Defines the minimum library size required for a cell to be included in the analysis. |
qc_removeOutlierCells |
A boolean value (TRUE/FALSE), if TRUE, cells with library size identified as outliers are removed. For further details see: |
qc_minPCT |
A decimal value between 0 and 1. Defines the minimum fraction of cells where the gene needs to be expressed to be included in the analysis. |
qc_maxMTratio |
A decimal value between 0 and 1. Defines the maximum ratio of mitochondrial reads (mitochondrial reads / library size) present in a cell to be included in the analysis. It's computed using the symbol genes starting with 'MT-' non-case sensitive. |
nc_lambda |
A continuous value between 0 and 1. Defines the multiplicative value (1-lambda) to be applied over the weaker edge connecting two genes to maximize the adjacency matrix directionality. |
nc_nNet |
An integer value. The number of networks based on principal components regression to generate. |
nc_nCells |
An integer value. The number of cells to subsample each time to generate a network. |
nc_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. |
nc_scaleScores |
A boolean value (TRUE/FALSE), if TRUE, the weights will be normalized such that the maximum absolute value is 1. |
nc_symmetric |
A boolean value (TRUE/FALSE), if TRUE, the weights matrix returned will be symmetric. |
nc_q |
A decimal value between 0 and 1. Defines the cut-off threshold of top q% relationships to be returned. |
nc_priorNetwork |
A data.frame containing a prior gene regulatory network. The data.frame must have two columns: 'regulators' and 'targets'. Default: NULL. |
td_K |
An integer value. Defines the number of rank-one tensors used to approximate the data using CANDECOMP/PARAFAC (CP) Tensor Decomposition. |
td_maxIter |
An integer value. Defines the maximum number of iterations if error stay above |
td_maxError |
A decimal value between 0 and 1. Defines the relative Frobenius norm error tolerance. |
td_nDecimal |
An integer value indicating the number of decimal places to be used. |
ma_nDim |
An integer value. Defines the number of dimensions of the low-dimensional feature space to be returned from the non-linear manifold alignment. |
nCores |
An integer value. Defines the number of cores to be used. |
A list with 3 slots as follows:
tensorNetworks: The WT and KO weight-averaged denoised gene regulatory networks.
manifoldAlignment: The generated low-dimensional features result of the non-linear manifold alignment.
diffRegulation: The results of the differential regulation analysis.
Daniel Osorio <[email protected]>
library(scTenifoldKnk) # Simulating a dataset following a negative binomial distribution with high sparsity (~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)) ## Not run: # Running scTenifoldKnk — simulating knockout of gene ng10 output <- scTenifoldKnk( countMatrix = X, gKO = "ng10", nc_nNet = 10, nc_nCells = 500, td_K = 3, qc_minLibSize = 30 ) # Structure of the output str(output) # Accessing the WT and KO gene regulatory networks dim(output$tensorNetworks$WT) dim(output$tensorNetworks$KO) # Accessing the manifold alignment result head(output$manifoldAlignment) # Differential regulation results — top perturbed genes head(output$diffRegulation, n = 10) # Plotting the KO-centered subnetwork plotKO(output, gKO = "ng10") ## End(Not run)library(scTenifoldKnk) # Simulating a dataset following a negative binomial distribution with high sparsity (~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)) ## Not run: # Running scTenifoldKnk — simulating knockout of gene ng10 output <- scTenifoldKnk( countMatrix = X, gKO = "ng10", nc_nNet = 10, nc_nCells = 500, td_K = 3, qc_minLibSize = 30 ) # Structure of the output str(output) # Accessing the WT and KO gene regulatory networks dim(output$tensorNetworks$WT) dim(output$tensorNetworks$KO) # Accessing the manifold alignment result head(output$manifoldAlignment) # Differential regulation results — top perturbed genes head(output$diffRegulation, n = 10) # Plotting the KO-centered subnetwork plotKO(output, gKO = "ng10") ## End(Not run)