Skip to contents

Run scTenifoldKnk in-silico knockout analysis

Usage

RunscTenifoldKnk(
  srt,
  gKO,
  assay = NULL,
  layer = "counts",
  features = NULL,
  qc = TRUE,
  qc_mt_threshold = 0.1,
  qc_min_library_size = 1000,
  qc_min_cells = 25,
  nc_lambda = 0,
  nc_nNet = 10,
  nc_nCells = 500,
  nc_nComp = 3,
  nc_scaleScores = TRUE,
  nc_symmetric = FALSE,
  nc_q = 0.9,
  td_K = 3,
  td_maxIter = 1000,
  td_maxError = 1e-05,
  td_nDecimal = 3,
  ma_nDim = 2,
  cores = 1,
  backend = c("r", "cpp"),
  store_networks = TRUE,
  store_manifold = TRUE,
  tool_name = "scTenifoldKnk",
  verbose = TRUE
)

Arguments

srt

A Seurat object.

gKO

Gene symbol or symbols to knock out. All genes must be present after optional feature and QC filtering.

assay

Assay to use. NULL uses the default assay.

layer

Assay layer used as the count matrix.

features

Optional genes to retain before running network construction. If supplied, gKO is always retained when present in the input assay.

qc

Whether to apply scTenifoldKnk-style quality control.

qc_mt_threshold

Maximum mitochondrial read fraction per cell.

qc_min_library_size

Minimum library size per cell.

qc_min_cells

Minimum number of expressing cells required per gene.

nc_lambda, nc_nNet, nc_nCells, nc_nComp, nc_scaleScores, nc_symmetric, nc_q

Network construction parameters forwarded to scTenifoldNet::makeNetworks().

td_K, td_maxIter, td_maxError, td_nDecimal

Tensor decomposition parameters forwarded to scTenifoldNet::tensorDecomposition().

ma_nDim

Manifold-alignment dimension forwarded to scTenifoldNet::manifoldAlignment().

cores

Number of cores used by native network-construction workers and forwarded to downstream linear algebra where applicable.

backend

r calls scTenifoldKnk::scTenifoldKnk() directly and is the default high-consistency path. cpp follows the upstream scTenifoldNet/scTenifoldKnk network construction, tensor decomposition, manifold alignment, and differential-regulation steps while keeping input handling and result storage inside scop.

store_networks

Whether to keep WT/KO tensor networks in srt@tools.

store_manifold

Whether to keep manifold-alignment coordinates in srt@tools.

tool_name

Name of the srt@tools entry.

verbose

Whether to print the message. Default is TRUE.

Value

A Seurat object with scTenifoldKnk results stored in srt@tools[[tool_name]].

Examples

data(pancreas_sub)
gene_use <- "Pdx1"
counts <- GetAssayData5(
  pancreas_sub,
  assay = "RNA",
  layer = "counts"
)
detected <- names(
  sort(Matrix::rowSums(counts > 0),
    decreasing = TRUE
  )
)
features_use <- unique(c(gene_use, head(detected, 300)))

pancreas_sub <- RunscTenifoldKnk(
  pancreas_sub,
  gKO = gene_use,
  features = features_use,
  qc = FALSE,
  nc_nNet = 3,
  nc_nCells = 200,
  td_maxIter = 200,
  store_networks = FALSE,
  store_manifold = TRUE
)
#>  [2026-08-30 05:34:15] Run scTenifoldKnk knockout for "Pdx1" using "r" backend
#>  Building 3 gene regulatory networks (200 cells each)
#> Networks ■■■■■■■■■■■                       33% | ETA:  4s
#> Networks ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% | ETA:  0s
#>  Network construction complete: 3 networks
#>  [X] Tensor: 301 x 301 x 3 (K=3)
#>  [X] CP decomposition complete (norm explained: 42.6%)
#>  Manifold alignment: 301 shared genes, d=2
#>  Manifold alignment complete: 2 dimensions
#>  [2026-08-30 05:34:26] scTenifoldKnk results stored in `srt@tools[[scTenifoldKnk]]`

dr <- pancreas_sub@tools$scTenifoldKnk$diffRegulation
head(dr)
#>        gene     distance        Z         FC      p.value        p.adj
#> 1      Pdx1 6.777580e-04 3.980535 7621.73506 0.000000e+00 0.000000e+00
#> 33     Gnas 4.318053e-05 1.899597   30.93717 2.665186e-08 4.011106e-06
#> 148    Ssr2 3.983706e-05 1.850710   26.33172 2.875281e-07 2.884865e-05
#> 156  Sec61b 3.779421e-05 1.819095   23.70037 1.125610e-06 8.470212e-05
#> 236    Dad1 3.319124e-05 1.742161   18.27896 1.908025e-05 1.148631e-03
#> 279 Rpl36al 3.094061e-05 1.701186   15.88409 6.734262e-05 3.378355e-03

scTenifoldKnkPlot(pancreas_sub, plot_type = "effect")