plot_subgraph: Extract and plot one pathway subgraph

View source: R/plot-subgraph.R

plot_subgraphR Documentation

Extract and plot one pathway subgraph

Description

Quickly extract the network induced by one pathway and optionally draw it with igraph. Pathway members are retained even when they are isolated in the selected scope, and the extracted igraph object is returned invisibly.

Usage

plot_subgraph(
  net,
  fgs,
  scope = c("within-pathway", "boundary-expanded"),
  attributes = NULL,
  plot = TRUE,
  main = NULL,
  case_sensitive = FALSE,
  ...
)

Arguments

net

An undirected igraph network, a legacy network with a named adjacency list in links, an indexed sparse NEArender network, or a sparse adjacency matrix.

fgs

A character vector containing one pathway, or a one-element named gene-set list. A named list supplies the default plot title.

scope

Graph scope. "within-pathway" returns the subgraph induced by mapped pathway members. "boundary-expanded" also includes all one-hop neighbors and edges among the selected nodes.

attributes

Optional node display attributes. Supply a named vector to color-code nodes, a named list with color and/or size vectors, or a data frame or matrix with node identifiers as row names and color and/or size columns. Numeric color values use a continuous palette; categorical values use a discrete palette; valid R colors are used literally. Sizes are non-negative values in igraph plotting units. Attribute node names use the same case policy as fgs and net; omitted or NA values retain the defaults.

plot

Draw the extracted graph.

main

Plot title. By default, use the pathway name when fgs is a named list, otherwise "Pathway subgraph".

case_sensitive

Use case-sensitive identifier matching.

...

Additional arguments passed to igraph's plot method. Explicit vertex.color and vertex.size arguments override the stored display attributes for that drawing.

Details

By default, pathway members are orange and boundary nodes are blue. The returned graph has a logical pathway_member vertex attribute, display color (and, when supplied, size) vertex attributes, and retains source edge weights. Partial pathway and attribute mapping is allowed, but at least one pathway member must map to the network.

Value

Invisibly, a simple undirected igraph graph for the selected scope.

See Also

spectral_eigenpairs(), as_igraph_network()

Examples

net <- list(
  links = list(A = "B", B = c("A", "C"), C = "B"),
  Ntotal = 2)
graph <- plot_subgraph(net, list(signaling = c("A", "B")),
  scope = "boundary-expanded", plot = FALSE,
  attributes = list(color = c(A = "activated", B = "repressed"),
    size = c(A = 20, B = 12)))
igraph::vertex_attr(graph, "pathway_member")

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