| Title: | Plot Glycans using 'ggplot2' |
| Version: | 0.0.3 |
| Description: | Plot glycans following the Symbol Nomenclature for Glycans (SNFG) using 'ggplot2'. SNFG provides a standardized visual representation of glycan structures. |
| License: | Artistic-2.0 |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1.0) |
| Imports: | dplyr, ggplot2, ggtangle (≥ 0.1.0), ggstar, ggrepel, igraph, rlang, yulab.utils |
| Suggests: | quarto |
| VignetteBuilder: | quarto |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-01-13 05:19:09 UTC; HUAWEI |
| Author: | Guangchuang Yu |
| Maintainer: | Guangchuang Yu <guangchuangyu@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-01-18 11:00:08 UTC |
Format Linkage Labels
Description
Converts 'a'/'b' to Greek letters alpha/beta.
Usage
format_linkage_label(labels)
Arguments
labels |
A character vector of linkage labels. |
Value
A character vector with Greek letters.
Examples
labels <- c("a1-3", "b1-4")
format_linkage_label(labels)
Glycan Geometry Layer
Description
A convenient wrapper to add edges, edge labels, and SNFG nodes to a glycan plot.
Usage
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,
...
)
Arguments
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). |
Value
A list of 'ggplot2' layers.
Examples
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)
Get Highlight Alpha
Description
Gets the current alpha value for motif highlighting.
Usage
get_hl_alpha(default = 0.4)
Arguments
default |
Default value if not set (0.4). |
Value
A numeric value representing the alpha level.
Examples
get_hl_alpha()
Plot Glycan Structure
Description
Visualizes a glycan structure using ggplot2 and ggtangle.
Usage
gglycan(
data,
mapping = aes(),
layout = ggtangle::layout_fishbone,
direction = "left",
length = 1,
angle_sep = 30,
motif = NULL,
...
)
Arguments
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'. |
Value
A 'ggplot' object.
Examples
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)
Identify Motif in Glycan Graph
Description
Finds occurrences of a motif subsequence in the main glycan graph and marks them.
Usage
highlight_motif(graph, motif_str)
Arguments
graph |
The main glycan graph (an 'igraph' object). |
motif_str |
The motif string (IUPAC format). |
Value
An 'igraph' object with an added 'alpha' vertex attribute (1 for motif, 0.4 for others).
Examples
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")
Match SNFG Style to Graph Nodes
Description
Maps glycan node labels to SNFG shapes and colors.
Usage
match_snfg_style(graph)
Arguments
graph |
An 'igraph' object. |
Value
An 'igraph' object with additional vertex attributes: 'snfg_shape' (numeric starshape) and 'snfg_fill' (color).
Examples
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)
Read Glycan Data
Description
Parses a glycan string (IUPAC condensed format) and returns a graph object.
Usage
read_glycan(x, format = "iupac")
Arguments
x |
A character string representing the glycan structure. |
format |
The format of the string. Currently only "iupac" is supported. |
Value
An 'igraph' object representing the glycan structure.
Examples
s <- "Neu5Ac(a2-3)Gal(b1-4)GlcNAc(b1-2)Man(a1-3)Man(b1-4)GlcNAc(b1-4)GlcNAc"
g <- read_glycan(s)
Set Highlight Alpha
Description
Sets the alpha value for motif highlighting.
Usage
set_hl_alpha(value = 0.4)
Arguments
value |
Numeric value for alpha (default 0.4). |
Value
No return value, called for side effects.
Examples
set_hl_alpha(0.5)
SNFG Symbol Mapping
Description
A dataset containing the shapes and colors for SNFG symbols.
Usage
snfg_map
Format
A data frame with columns:
- monosaccharide
The name of the monosaccharide (e.g., Glc, Gal, Man)
- shape
The shape of the symbol (e.g., circle, square)
- color
The fill color of the symbol (hex code)
- starshape
The ggstar shape ID