Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

n2s

function to convert the numeric encoding of a DNA sequence into a vector of characters


Description

By default, if no ‘levels’ arguments is provided, this function will just transform your vector of integer into a DNA sequence according to the lexical order: 0 -> "a", 1 -> "c", 2 -> "g", 3 -> "t", others -> NA.

Usage

n2s(nseq, levels = c("a", "c", "g", "t"), base4 = TRUE)

Arguments

nseq

A vector of integers

levels

the translation vector

base4

when this logical is true, the numerical encoding of levels starts at 0, when it is false the numerical encoding of levels starts at 1.

Value

a vector of characters

Author(s)

J.R. Lobry

References

citation("seqinr")

See Also

Examples

##example of the default behaviour:
nseq <- sample(x = 0:3, size = 100, replace = TRUE)
n2s(nseq) 
# Show what happens with out-of-range and NA values:
nseq[1] <- NA
nseq[2] <- 777
n2s(nseq)[1:10]
# How to get an RNA instead:
n2s(nseq, levels = c("a", "c", "g", "u"))

seqinr

Biological Sequences Retrieval and Analysis

v4.2-16
GPL (>= 2)
Authors
Delphine Charif [aut], Olivier Clerc [ctb], Carolin Frank [ctb], Jean R. Lobry [aut, cph], Anamaria Necşulea [ctb], Leonor Palmeira [ctb], Simon Penel [cre], Guy Perrière [ctb]
Initial release
2022-05-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.