count_mono: Get the Number of Monosaccharides

View source: R/count-mono.R

count_monoR Documentation

Get the Number of Monosaccharides

Description

When mono is:

  • NULL (default), returns the total number of monosaccharides and substituents.

  • A string, returns the number of the specified monosaccharide or substituent.

Usage

count_mono(x, mono = NULL, include_subs = FALSE)

## S3 method for class 'glyrepr_composition'
count_mono(x, mono = NULL, include_subs = FALSE)

## S3 method for class 'glyrepr_structure'
count_mono(x, mono = NULL, include_subs = FALSE)

## S3 method for class 'igraph'
count_mono(x, mono = NULL, include_subs = FALSE)

Arguments

x

A glycan composition (glyrepr_composition), a glycan structure (glyrepr_structure) vector, or a glycan igraph.

mono

The monosaccharide or substituent to count. A character scalar. If NULL (default), return the total number of monosaccharides.

include_subs

Whether to include substituents when mono is NULL. Default is FALSE.

Details

When mono is "generic" (e.g. "Hex", "HexNAc"), it counts all "concrete" monosaccharides that match. For example, "Hex" will count all Glc, Man, Gal, etc. When mono is "concrete" (e.g. "Gal", "GalNAc"), NA is returned when the composition contains generic residues. Floating substituents are counted like substituents attached to known residues.

Value

A numeric vector of the same length as x, or a numeric scalar for graph input.

Examples

comp <- glycan_composition(c(Gal = 1, Man = 1, GalNAc = 1))
count_mono(comp, "Hex")
count_mono(comp, "Gal")

struct <- as_glycan_structure("Gal(b1-3)GlcNAc(b1-4)Glc(a1-")
count_mono(struct, "Gal")

# Total number of monosaccharides
count_mono(comp)


glyrepr documentation built on Sept. 22, 2026, 5:09 p.m.