
glydraw is a ggplot2-native R engine for drawing reproducible SNFG
glycan cartoons from glycan structure objects or text notations, with
support for batch export, structural highlighting, and deep appearance
customization.
We recommend installing the meta-package glycoverse, which includes this package and other core glycoverse packages.
If you don’t want to install all glycoverse packages, you can only install glydraw.
You can install the latest release of glydraw from CRAN:
install.packages("glydraw")
Or from r-universe:
install.packages('glydraw', repos = c('https://glycoverse.r-universe.dev', 'https://cloud.r-project.org'))
Or from GitHub:
remotes::install_github("glycoverse/glydraw@*release")
Or install the development version:
remotes::install_github("glycoverse/glydraw")
library(glydraw)
glycan <- paste0(
"Glc(a1-2)Glc(a1-3)Glc(a1-3)Man(a1-2)Man(a1-2)Man(a1-3)[Man(a1-2)Man(a1-3)",
"[Man(a1-2)Man(a1-6)]Man(a1-6)]Man(b1-4)GlcNAc(b1-4)GlcNAc(a1-"
)
draw_cartoon(glycan, red_end = "PP-Dol")

scale_x_glycan() and scale_y_glycan() can add glycan cartoons to
standard ggplot2 figures. For example, you can use glycan cartoons as
labels in a heatmap:
library(ggplot2)
library(glydraw)
library(tibble)
set.seed(123)
plot_data <- tibble(
`z-score` = rnorm(25),
branch = rep(c(
"GlcNAc(??-",
"Gal(??-?)GlcNAc(??-",
"Neu5Ac(??-?)Gal(??-?)GlcNAc(??-",
"Neu5Ac(??-?)Gal(??-?)[Fuc(??-?)]GlcNAc(??-",
"Gal(??-?)[Fuc(??-?)]GlcNAc(??-"
), 5),
sample = rep(paste0("Sample ", 1:5), each = 5)
)
ggplot(plot_data, aes(branch, sample)) +
geom_tile(aes(fill = `z-score`), color = "white", linewidth = 1) +
scale_fill_viridis_c(option = "plasma") +
scale_x_glycan(
position = "top",
size = 0.2,
show_linkage = FALSE,
red_end = "~"
) +
coord_equal() +
theme_void() +
theme(axis.text.y = element_text())

glycan <- paste0(
"Neu5Ac(a2-3)Gal(b1-3)[Fuc(a1-2)Gal(b1-3)[Fuc(a1-4)]GlcNAc(b1-3)",
"[Gal(b1-4)[Fuc(a1-3)]GlcNAc(b1-6)]Gal(b1-4)GlcNAc(b1-6)]GalNAc(a1-"
)
draw_cartoon(glycan, red_end = "~", node_size = 1.2)

glycan <- "Gal(b1-3)[Neu5Ac(a2-3)Gal6S(b1-4)[Fuc(a1-3)]GlcNAc(b1-6)]GalNAc(a1-"
draw_cartoon(glycan, orient = "V", red_end = "Ser/Thr")

glycan <- "Fuc(a1-3)[Fuc(a1-6)]GlcNAc(b1-"
draw_cartoon(glycan, orient = "V", red_end = "Asn", fuc_orient = "up")

glycan <- paste0(
"WURCS=2.0/3,4,3/[a2122h-1a_1-5_2*N][a1122h-1a_1-5_2*OP^XOCCN/3O/3=O]",
"[a1122h-1a_1-5_6*OP^XOCCN/3O/3=O]/1-2-3-3/a4-b1_b6-c1_c2-d1"
)
draw_cartoon(glycan)

glycan <- "Glc(b1-4)[Xyl(a1-6)][Xyl(a1-2)]Glc(b1-4)[Xyl(a1-6)]Glc(b1-4)[Fuc(a1-2)Gal(b1-2)Xyl(a1-6)]Glc(b1-4)Glc(b1-4)[Xyl(a1-6)]Glc(b1-"
draw_cartoon(glycan, fuc_orient = "up")

Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.