Skip to contents

Infer gene regulatory networks

Usage

RunGRN(object, ...)

# S3 method for class 'Seurat'
RunGRN(
  object,
  assay = NULL,
  layer = "counts",
  regulators = NULL,
  targets = NULL,
  methods = "grnboost2",
  backend = c("cpp", "python"),
  ...
)

# Default S3 method
RunGRN(
  object,
  regulators = NULL,
  targets = NULL,
  genes_in = c("rows", "columns"),
  methods = "grnboost2",
  backend = c("cpp", "python"),
  output_file = NULL,
  work_dir = tempdir(),
  prefix = "grn",
  max_edges_per_target = Inf,
  n_rounds = 5000,
  learning_rate = 0.01,
  max_depth = 3,
  max_features = 0.1,
  subsample = 0.9,
  early_stop_window_length = 25,
  exclude_self = TRUE,
  correlation_threshold = 0.3,
  lasso_degree = 30,
  lasso_alpha = 0.1,
  max_lag = 3,
  envname = NULL,
  conda = "auto",
  cores = 1,
  seed = 1234,
  force = FALSE,
  verbose = TRUE,
  return_type = NULL,
  input_mode = NULL,
  assay = NULL,
  layer = "counts",
  atac_assay = NULL,
  atac_layer = NULL,
  group.by = NULL,
  groups = NULL,
  pseudotime = NULL,
  resources = list(),
  method_args = list(),
  tool_name = NULL,
  overwrite = FALSE,
  ...
)

Arguments

object

A Seurat object or expression matrix.

...

Additional parameters to other functions.

assay

Assay used when `object` is a Seurat object.

layer

Assay layer used when `object` is a Seurat object.

regulators

Candidate transcription factor genes.

targets

Candidate target genes. NULL uses all genes for most methods; Pando selects variable genes.

methods

One method name (case insensitive): GENIE3, GRNBoost2, GNIPLR, PPCOR, PIDC, SCORPION, SCSGL, LEAP, SCODE, SINCERITIES, Pando, LINGER, SCENIC+, RegDiffusion, or SCENIC.

backend

Method-specific implementation. NULL uses the method default.

genes_in

Matrix orientation for matrix inputs. `"rows"` means genes x cells; `"columns"` means cells x genes.

output_file

Optional adjacency file for return_type = "edges".

work_dir

Directory for method outputs and logs.

prefix

Prefix for run directories.

max_edges_per_target

Maximum incoming edges per target for methods that support it.

n_rounds

Number of boosting rounds for GRNBoost2-like tree ensemble inference. The default follows arboreto `SGBM_KWARGS`.

learning_rate

GRNBoost2-like tree ensemble learning rate.

max_depth

Maximum depth of each regression tree.

max_features

Fraction of candidate regulators sampled at each tree split.

subsample

Fraction of cells sampled for each boosting round.

early_stop_window_length

Out-of-bag improvement window used for GRNBoost2 early stopping.

exclude_self

Whether GRNBoost2-like inference excludes a target gene from its own regulator feature set.

correlation_threshold

Relative correlation filter used before lagged regression. A gene pair is tested when its absolute correlation is at least this fraction of the maximum absolute correlation for the regulator.

lasso_degree

Polynomial degree used by the LASSO projection step.

lasso_alpha

LASSO regularization strength used by the projection step.

max_lag

Maximum lag used by Granger-style lagged regression. Values above `3` are capped at `3` to match the GNIPLR reference implementation.

envname

Python environment. NULL uses the method default.

conda

Conda-compatible executable used by Python backends.

cores

Number of workers for methods that support parallel execution.

seed

Random seed passed to supported backends.

force

Overwrite an existing output_file. Otherwise read it back.

verbose

Whether to print progress messages.

return_type

"seurat", "edges", or "result". The default is "seurat" for Seurat input and "edges" for matrix input.

input_mode

"rna" or "multiome". Multiome input requires a Seurat object.

atac_assay, atac_layer

Chromatin assay and exact layer. Join split layers first.

group.by

Metadata column or cell-named vector defining separate networks.

groups

Group labels to fit, in the requested order.

pseudotime

Metadata column, cell-named numeric vector, or cell-by-trajectory matrix.

resources

Named backend resources. For SCSGL, SCODE, and Python GNIPLR, set source_dir to the corresponding upstream checkout.

method_args

Named backend arguments. runtime accepts python and timeout for subprocesses. resume_dir resumes one LINGER or SCENIC+ group.

tool_name, overwrite

Name and replacement policy for the Seurat tools entry.

Value

A Seurat object with the network in tools, an edge table (TF, target, importance), or a GRNResult. Multiple groups require "seurat" or "result".

See also

Examples

data(pancreas_sub)
expr <- GetAssayData5(
  pancreas_sub,
  assay = SeuratObject::DefaultAssay(pancreas_sub),
  layer = "counts"
)
expr <- as.matrix(expr[, seq_len(8)])
expr <- expr[
  names(sort(apply(expr, 1, stats::var), decreasing = TRUE))[seq_len(5)],
]

gniplr_grn <- RunGRN(
  expr,
  genes_in = "rows",
  methods = "gniplr",
  backend = "cpp",
  correlation_threshold = 0,
  lasso_degree = 1,
  max_lag = 1,
  max_edges_per_target = 2,
  verbose = FALSE
)