geom_node_glycan: Draw glycans as ggraph nodes

View source: R/geom-node-glycan.R

geom_node_glycanR Documentation

Draw glycans as ggraph nodes

Description

geom_node_glycan() is a ggraph node layer backed by geom_glycan(). It supplies the node layout's x and y columns as the default position aesthetics and supports ggraph's filter aesthetic.

Usage

geom_node_glycan(
  mapping = NULL,
  data = NULL,
  position = "identity",
  show.legend = NA,
  ...
)

Arguments

mapping

Set of aesthetic mappings created by ggplot2::aes(). The structure aesthetic is required. The x and y aesthetics default to the node coordinates calculated by ggraph.

data

The node data to display. When NULL, the default, the layer uses the node data calculated by ggraph::ggraph().

position

A position adjustment. Defaults to "identity".

show.legend

Logical. Should this layer be included in legends?

...

Arguments passed to geom_glycan(), including fixed aesthetics and glycan rendering options.

Value

A ggplot2 layer that can be added to a ggraph::ggraph() plot.

Aesthetics

geom_node_glycan() understands the same aesthetics as geom_glycan(). structure is required, while x and y default to the node layout coordinates. It additionally supports filter, a logical aesthetic that selects which nodes are drawn.

Examples

if (requireNamespace("ggraph", quietly = TRUE)) {
  graph <- igraph::make_ring(2)
  igraph::V(graph)$glycan <- c(
    "GalNAc(a1-",
    "Gal(b1-3)GalNAc(a1-"
  )

  ggraph::ggraph(graph, layout = "linear") +
    ggraph::geom_edge_link() +
    geom_node_glycan(ggplot2::aes(structure = .data$glycan))
}

glydraw documentation built on July 25, 2026, 9:06 a.m.