| Title: | Plot Glycans using 'ggplot2' |
|---|---|
| Description: | Plot glycans following the Symbol Nomenclature for Glycans (SNFG) using 'ggplot2'. SNFG provides a standardized visual representation of glycan structures. |
| Authors: | Guangchuang Yu [aut, cre] (ORCID: <https://orcid.org/0000-0002-6485-8781>) |
| Maintainer: | Guangchuang Yu <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 0.0.3 |
| Built: | 2026-05-22 09:15:08 UTC |
| Source: | https://github.com/cran/gglycan |
Converts 'a'/'b' to Greek letters alpha/beta.
format_linkage_label(labels)format_linkage_label(labels)
labels |
A character vector of linkage labels. |
A character vector with Greek letters.
labels <- c("a1-3", "b1-4") format_linkage_label(labels)labels <- c("a1-3", "b1-4") format_linkage_label(labels)
A convenient wrapper to add edges, edge labels, and SNFG nodes to a glycan plot.
geom_glycan( edge_color = "black", edge_width = 0.5, arrow_length = unit(2, "mm"), node_size = 5, node_label = FALSE, label_size = 3.88, edge_label_size = 3.88, ... )geom_glycan( edge_color = "black", edge_width = 0.5, arrow_length = unit(2, "mm"), node_size = 5, node_label = FALSE, label_size = 3.88, edge_label_size = 3.88, ... )
edge_color |
Color of the edges. |
edge_width |
Width of the edges. |
arrow_length |
Length of the edge arrows. |
node_size |
Size of the node symbols. |
node_label |
Logical. Whether to show node labels (monosaccharide names). Default is FALSE. |
label_size |
Size of the node labels. |
edge_label_size |
Size of the edge labels (linkage). |
... |
Additional arguments (currently unused). |
A list of 'ggplot2' layers.
s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" ## Not run: gglycan(s) + geom_glycan() ## End(Not run)s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" ## Not run: gglycan(s) + geom_glycan() ## End(Not run)
Gets the current alpha value for motif highlighting.
get_hl_alpha(default = 0.4)get_hl_alpha(default = 0.4)
default |
Default value if not set (0.4). |
A numeric value representing the alpha level.
get_hl_alpha()get_hl_alpha()
Visualizes a glycan structure using ggplot2 and ggtangle.
gglycan( data, mapping = aes(), layout = ggtangle::layout_fishbone, direction = "left", length = 1, angle_sep = 30, motif = NULL, ... )gglycan( data, mapping = aes(), layout = ggtangle::layout_fishbone, direction = "left", length = 1, angle_sep = 30, motif = NULL, ... )
data |
A glycan graph object (from 'read_glycan') or an IUPAC string. |
mapping |
Default list of aesthetic mappings to use for plot. |
layout |
The layout algorithm to use. Default is 'ggtangle::layout_fishbone'. Can be a string ("tree", "nicely") or a function. |
direction |
The direction of the main chain growth ("left", "right", "up", "down"). Default is "left". |
length |
The distance between nodes. Default is 1. |
angle_sep |
The angle separation for branches in degrees. Default is 30. |
motif |
A motif string (IUPAC format) to highlight in the structure. Default is NULL. |
... |
Additional arguments passed to 'ggplot'. |
A 'ggplot' object.
s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" ## Not run: gglycan(s) + geom_glycan() ## End(Not run)s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" ## Not run: gglycan(s) + geom_glycan() ## End(Not run)
Finds occurrences of a motif subsequence in the main glycan graph and marks them.
highlight_motif(graph, motif_str)highlight_motif(graph, motif_str)
graph |
The main glycan graph (an 'igraph' object). |
motif_str |
The motif string (IUPAC format). |
An 'igraph' object with an added 'alpha' vertex attribute (1 for motif, 0.4 for others).
s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" g <- read_glycan(s) g <- highlight_motif(g, "Neu5Ac(a2-3)Gal(b1-4)GlcNAc")s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" g <- read_glycan(s) g <- highlight_motif(g, "Neu5Ac(a2-3)Gal(b1-4)GlcNAc")
Maps glycan node labels to SNFG shapes and colors.
match_snfg_style(graph)match_snfg_style(graph)
graph |
An 'igraph' object. |
An 'igraph' object with additional vertex attributes: 'snfg_shape' (numeric starshape) and 'snfg_fill' (color).
s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" g <- read_glycan(s) g <- match_snfg_style(g)s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" g <- read_glycan(s) g <- match_snfg_style(g)
Parses a glycan string (IUPAC condensed format) and returns a graph object.
read_glycan(x, format = "iupac")read_glycan(x, format = "iupac")
x |
A character string representing the glycan structure. |
format |
The format of the string. Currently only "iupac" is supported. |
An 'igraph' object representing the glycan structure.
s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" g <- read_glycan(s)s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc" g <- read_glycan(s)
Sets the alpha value for motif highlighting.
set_hl_alpha(value = 0.4)set_hl_alpha(value = 0.4)
value |
Numeric value for alpha (default 0.4). |
No return value, called for side effects.
set_hl_alpha(0.5)set_hl_alpha(0.5)
A dataset containing the shapes and colors for SNFG symbols.
snfg_mapsnfg_map
A data frame with columns:
The name of the monosaccharide (e.g., Glc, Gal, Man)
The shape of the symbol (e.g., circle, square)
The fill color of the symbol (hex code)
The ggstar shape ID