spectral.render: Render a sample matrix as pathway-level spectral features

View source: R/render-spectral.R

spectral.renderR Documentation

Render a sample matrix as pathway-level spectral features

Description

Calculate pathway-level Dirichlet sums and Rayleigh quotients from a sample matrix. Dirichlet sums quantify contrasts between adjacent node states; Rayleigh quotients additionally normalize those contrasts by individual node states.

Usage

spectral.render(
  fgs,
  mtr,
  net,
  min_ngenes = 5,
  features = c("rlq", "rlw", "dir", "diw"),
  scope = c("within-pathway", "boundary-expanded"),
  case_sensitive = FALSE,
  n_cores = 1L,
  verbose = TRUE
)

Arguments

fgs

Named list of functional gene sets whose subnetworks are extracted from the global network net.

mtr

Numeric gene-by-sample matrix. Values become sample-specific node attributes.

net

Undirected igraph network, or a legacy network with a named adjacency list in links. Weighted features use the igraph weight edge attribute or legacy named edge-weight vectors in weights.

min_ngenes

Minimum mapped genes per set before scope expansion.

features

Unique spectral features. rlq and dir use binary topology; rlw and diw use stored network edge weights. The default requests all four implemented features.

scope

Graph scope: "within-pathway" uses within-set edges; "boundary-expanded" also uses boundary edges to one-hop neighbors.

case_sensitive

Use case-sensitive identifier matching.

n_cores

Positive integer number of worker processes. Independent spectral features are distributed across workers when n_cores > 1.

verbose

Report progress with message().

Details

The implemented spectral features are Dirichlet sums (dir and diw for edge-unweighted and weighted versions, respectively) and Rayleigh quotients (rlq and rlw for edge-unweighted and weighted versions, respectively). The former summarize contrasts between states of adjacent network nodes within a pathway, whereas the latter also normalize the contrasts by individual node states. A separate pathway-by-sample matrix is produced for each requested feature. Running scope = "boundary-expanded" may take about ten times as long as "within-pathway"; the exact increase depends on the network and pathway sizes. Submit alternative scope analyses as separate calls so that each result has an unambiguous graph scope.

Value

A nearender_result. scores contains one pathway-by-sample matrix for every requested feature, in request order. statistics contains the same master score matrices under the same names. rlq and rlw are Rayleigh quotients; dir and diw are Dirichlet sums. Rows with fewer than min_ngenes mapped genes, or with no usable scoped edges, contain NA. diagnostics$fgs_network_sizes reports mapped pathway sizes; no p- or q-values are calculated.

References

Chung FRK (1997). Spectral Graph Theory. CBMS Regional Conference Series in Mathematics 92, American Mathematical Society. ISBN 978-0-8218-0315-8.

See Also

spectral_eigenpairs(), texture.render(), gsva.render()

Examples

profiles <- matrix(c(1, 3, 5, 2, 2, 2), nrow = 3,
  dimnames = list(c("A", "B", "C"), c("sample_1", "sample_2")))
fgs <- list(pathway = c("A", "B"))
net <- list(
  links = list(A = "B", B = c("A", "C"), C = "B"),
  weights = list(A = c(B = 2), B = c(A = 2, C = 1), C = c(B = 1)),
  Ntotal = 2)
spectral <- spectral.render(fgs, profiles, net, min_ngenes = 2,
  scope = "within-pathway", verbose = FALSE)
spectral$scores$rlq
spectral$scores$rlw

NEArender documentation built on Nov. 28, 2026, 5:10 p.m.