Skip to contents

Return character sequence corresponding to one-hot elements in matrix or tensor.

Usage

one_hot_to_seq(
  m,
  vocabulary = c("A", "C", "G", "T"),
  amb_enc = "zero",
  amb_char = "N",
  paste_chars = TRUE
)

Arguments

m

One-hot encoding matrix or 3d array where each element of first axis is one-hot matrix.

vocabulary

Vector of allowed characters. Characters outside vocabulary get encoded as specified in ambiguous_nuc.

amb_enc

Either "zero" or "equal". How oov tokens where treated for one-hot encoding.

amb_char

Char to use for oov positions.

paste_chars

Whether to return vector or single sequence.

Value

A string.

Examples

m <- matrix(c(1,0,0,0,0,1,0,0), 2)
one_hot_to_seq(m)
#> [1] "AG"