Package 'inferCSN'

Title: Inferring Cell-Specific Gene Regulatory Network
Description: Inferring cell-type specific gene regulatory network using sparse regression model from single-cell transcriptomic data.
Authors: Meng Xu [aut, cre] (ORCID: <https://orcid.org/0000-0002-8300-1054>)
Maintainer: Meng Xu <[email protected]>
License: MIT + file LICENSE
Version: 1.2.5
Built: 2026-10-14 14:09:10 UTC
Source: https://github.com/mengxu98/infercsn

Help Index


Inferring Cell-Specific Gene Regulatory Network

Description

Inferring cell-type specific gene regulatory network using sparse regression model from single-cell transcriptomic data.

Author(s)

Meng Xu (Maintainer), [email protected]

Source

https://mengxu98.github.io/inferCSN/

See Also

Useful links:


Example ground truth data

Description

Ground-truth edges for the bundled synthetic example.


Example matrix data

Description

Expression matrix for the bundled synthetic example.


Example meta data

Description

Cell metadata for the bundled synthetic example.


Filter and sort a network matrix

Description

Filter and sort a network matrix

Usage

filter_sort_matrix(network_matrix, regulators = NULL, targets = NULL)

Arguments

network_matrix

Network weight matrix.

regulators, targets

Nodes to include.

Value

A filtered and sorted matrix.


Fit greedy L0 regression

Description

Fits a standardized sparse linear model by BIC-decreasing support updates.

Usage

fit_greedy_l0(
  x,
  y,
  max_support_size = NULL,
  min_improvement = 1e-10,
  verbose = TRUE
)

Arguments

x

Numeric predictor matrix with observations in rows.

y

Numeric response vector.

max_support_size

Optional positive integer support limit.

min_improvement

Minimum RSS improvement considered.

verbose

Logical verbosity flag.

Value

A list with 'model', 'metrics', and 'coefficients'.


Fit batched greedy L0 regressions

Description

Fits multiple responses from shared predictor cross-products.

Usage

fit_greedy_l0_batch(
  gram,
  xty,
  response_ss,
  candidates,
  n_obs,
  max_support_size = NULL,
  min_improvement = 1e-10
)

Arguments

gram

Numeric square predictor cross-product matrix.

xty

Numeric predictor-by-response cross-product matrix.

response_ss

Numeric response sums of squares.

candidates

List of one-based predictor indices, one element per response.

n_obs

Number of observations used for the cross-products.

max_support_size

Optional positive integer support limit.

min_improvement

Minimum RSS reduction proposed during forward search.

Value

Batched coefficients, deletion evidence, and fit summaries.


inferring cell-type specific gene regulatory network

Description

inferring cell-type specific gene regulatory network

Usage

inferCSN(
  object,
  pseudotime = NULL,
  regulators = NULL,
  targets = NULL,
  max_support_size = NULL,
  lag_fraction = 0.05,
  lag_steps = NULL,
  cores = 1,
  verbose = TRUE,
  method = c("greedy_l0", "L0", "L0L1", "L0L2"),
  ...
)

## S4 method for signature 'matrix'
inferCSN(
  object,
  pseudotime = NULL,
  regulators = NULL,
  targets = NULL,
  max_support_size = NULL,
  lag_fraction = 0.05,
  lag_steps = NULL,
  cores = 1,
  verbose = TRUE,
  method = c("greedy_l0", "L0", "L0L1", "L0L2"),
  ...
)

## S4 method for signature 'sparseMatrix'
inferCSN(
  object,
  pseudotime = NULL,
  regulators = NULL,
  targets = NULL,
  max_support_size = NULL,
  lag_fraction = 0.05,
  lag_steps = NULL,
  cores = 1,
  verbose = TRUE,
  method = c("greedy_l0", "L0", "L0L1", "L0L2"),
  ...
)

Arguments

object

Numeric expression matrix with cells in rows and genes in columns.

pseudotime

Optional pseudotime vector or branch matrix for either method. Regulators in earlier states predict targets in later states; tied states are averaged and shared branch transitions are counted once.

regulators, targets

Optional gene subsets.

max_support_size

Optional support-size limit.

lag_fraction

Fractional lag used when lag_steps is NULL.

lag_steps

Optional integer lag. L0Learn centers and scales lagged expression within each branch and defaults to fitting without an intercept.

cores

Number of inference workers.

verbose

Whether to report progress.

method

greedy_l0 (default), or L0Learn with the L0, L0L1, or L0L2 penalty.

...

Arguments passed to the method.

Value

A data frame containing exactly regulator, target, and weight.

Examples

data(example_matrix)
data(example_meta_data)
network_table <- inferCSN(
  example_matrix,
  pseudotime = example_meta_data$pseudotime
)
head(network_table)

inferCSN(
  example_matrix,
  regulators = c("g1", "g2"),
  targets = c("g3", "g4")
)

Format a network table

Description

Format a network table

Usage

network_format(
  network_table,
  regulators = NULL,
  targets = NULL,
  abs_weight = TRUE
)

Arguments

network_table

Network edge table.

regulators, targets

Nodes to include.

abs_weight

Whether to use absolute weights and add interaction signs.

Value

A formatted network edge table.


Select features with significant trends

Description

Select features with significant trends

Usage

select_trend_features(
  x = NULL,
  pseudotime = NULL,
  method = c("pretsa", "gam"),
  padjust_threshold = 0.05,
  n_candidates = NULL,
  statistics = NULL,
  ...
)

Arguments

x

Numeric matrix with observations in rows and features in columns, or NULL when supplying statistics.

pseudotime

Numeric coordinate per observation.

method

Fitting method: "pretsa" or "gam".

padjust_threshold

Strict adjusted P-value cutoff between zero and one.

n_candidates

Maximum number of selected features, or NULL for no cap.

statistics

Precomputed table with feature row names and padjust (or pvalue if padjust is absent).

...

Numerical options passed to thisutils::fit_trends().

Value

A list with features, statistics, and fit (NULL for precomputed input). Nonfinite P-values are excluded. Input order is retained unless the cap is exceeded; then the smallest P-values are selected with stable ties.

Examples

t <- seq(0, 1, length.out = 40)
x <- cbind(a = sin(t * 5), b = cos(t * 3))
select_trend_features(x, t)$features

Construct network for single target gene

Description

Construct network for single target gene

Usage

single_network(
  matrix,
  regulators,
  target,
  pseudotime = NULL,
  max_support_size = NULL,
  lag_fraction = 0.05,
  lag_steps = NULL,
  cores = 1,
  verbose = TRUE,
  method = c("greedy_l0", "L0", "L0L1", "L0L2"),
  ...
)

Arguments

matrix

An expression matrix.

regulators

Candidate regulator genes.

target

The target gene.

pseudotime

Optional pseudotime vector or branch matrix passed to [inferCSN()].

max_support_size

Optional support-size cap passed to [inferCSN()].

lag_fraction

Fractional state lag passed to [inferCSN()].

lag_steps

Optional integer state lag passed to [inferCSN()].

cores

Number of inference workers.

verbose

Whether to report progress.

method

greedy_l0 (default), or L0Learn with the L0, L0L1, or L0L2 penalty.

...

Arguments passed to the method.

Value

A data frame with regulator, target, and weight columns. Greedy-L0 returns selected edges. L0Learn retains the original per-regulator coefficients, including zeros; [inferCSN()] removes zero weights from the complete network.

Examples

data(example_matrix)
head(
  single_network(
    example_matrix,
    regulators = colnames(example_matrix),
    target = "g1"
  )
)
single_network(
  example_matrix,
  regulators = c("g1", "g2", "g3"),
  target = "g1"
)