Package 'glydraw'

Title: Draw beautiful SNFG cartoons
Description: Draw beautiful SNFG cartoons.
Authors: Xisong Feng [aut, cre] (ORCID: <https://orcid.org/0009-0000-4057-1295>)
Maintainer: Xisong Feng <[email protected]>
License: MIT + file LICENSE
Version: 0.4.1
Built: 2026-05-26 15:09:34 UTC
Source: https://github.com/glycoverse/glydraw

Help Index


Draw a Symbol Nomenclature For Glycan (SNFG)

Description

Draw a Symbol Nomenclature For Glycan (SNFG)

Usage

draw_cartoon(
  structure,
  show_linkage = TRUE,
  orient = c("H", "V"),
  highlight = NULL
)

Arguments

structure

A glyrepr::glycan_structure() scalar, or a string of any glycan structure text nomenclatures supported by glyparse::auto_parse().

show_linkage

Show linkage annotation or not. Default is TRUE.

orient

The orientation of glycan structure. "H" for horizontal, "V" for vertical. Default is "H"

highlight

An integer vector specifying the node indices to highlight. This argument is applicable only when structure is a glyrepr::glycan_structure(). Note that for a glyrepr::glycan_structure(), the node indices correspond exactly to the monosaccharides in its printed IUPAC nomenclature. For example, given glyrepr::as_glycan_structure("Gal(b1-3)[GlcNAc(b1-6)]GalNAc(a1-"), setting highlight = c(1, 3) will highlight the "Gal" and "GalNAc" nodes.

Value

a ggplot2 object

Examples

## Not run: 
draw_cartoon("Gal(b1-3)GalNAc(a1-")

## End(Not run)

Export all glycan structures to figures

Description

This function calls draw_cartoon() on each glycan structure in x, then calls save_cartoon() to save a figure for each of them. IUPAC-condensed nomenclatures are used as file names. If x is a named character vector or named glyrepr::glycan_structure() vector, the vector names are used as file names.

Usage

export_cartoons(
  x,
  dirname,
  file_ext = "png",
  dpi = 300,
  show_linkage = TRUE,
  orient = c("H", "V")
)

Arguments

x

A glyexp::experiment(), a glyrepr::glycan_structure() vector, or a character vector of any glycan structure text nomenclatures supported by glyparse::auto_parse().

dirname

Directory name to save the cartoons. If it does not exist, it is created.

file_ext

File extension supported by ggplot2::ggsave(). Defaults to "png".

dpi

Dots per inch. Defaults to 300.

show_linkage

Show linkage annotation or not. Default is TRUE.

orient

The orientation of glycan structure. "H" for horizontal, "V" for vertical. Default is "H"

Value

The function returns the list of cartoons implicitly.

Examples

## Not run: 
library(glyexp)
export_cartoons(real_experiment, "path/to/save")

## End(Not run)

Save fixed-size glycan cartoon image to local device.

Description

In theory, you can just use ggplot2::ggsave() to save the cartoons plotted by draw_cartoon(). However, you can have trouble finding the best sizes for each cartoon to make them look alike. This function is designed to save the cartoons with self-adjusted sizes, based on the size of the glycans, so that when glycans with different sizes are put together, they will look alike.

Usage

save_cartoon(cartoon, file, dpi = 300)

Arguments

cartoon

A ggplot2 object returned by draw_cartoon().

file

File name of glycan cartoon.

dpi

Dots per inch, default = 300.

Examples

## Not run: 
cartoon <- draw_cartoon("Gal(b1-3)GalNAc(a1-")
save_cartoon(cartoon, "p1.png", dpi = 300)

## End(Not run)