concatenate: Sequence Concatenation

View source: R/concatenate.R

concatenateR Documentation

Sequence Concatenation

Description

A function to transform a raw matrix, used to store sets of single nucleotides, into a vector of strings, optionally removing specific value(s).

Usage

concatenate(x, discard = NULL)

Arguments

x

A raw vector storing the molecular traits (single nucleotides, gaps, and so on).

discard

A vector of characters to exclude from the results (default: NULL, meaning nothing is excluded).

Details

That function concatenates the rows of a raw matrix, which is used for storing the molecular trait values, into a vector of strings. If argument discard is given a set of values, they will be excluded from the resulting strings.

Value

A vector of character strings.

Author(s)

Guillaume Guénard [aut, cre] (<https://orcid.org/0000-0003-0761-3072>), Pierre Legendre [ctb] (<https://orcid.org/0000-0002-3838-3305>)

Examples

## Define a raw vector for storing nuceotide values:
c(Sequence_1 = "ATCG-TTTCG--CCCCA--TTA--TTAA-GTAA-GTAATCTTTCA",
  Sequence_2 = "TTGGCTTCC--TC--CAT-TTC--TTCA-GT-ACG-ATTCTTTTA",
  Sequence_3 = "TTCG-TACC-T-T---A-ATAA--T-AA-GTCTTGTAATCGTTCA") %>%
  sapply(charToRaw) %>%
  t -> sqn

## Display the raw sequence:
sqn

## Transforming the sequence to character strings
concatenate(sqn)

## Transforming the sequence to character strings without the gaps:
concatenate(sqn, discard="-")

## Clean-up:
rm(sqn)


guenardg/MPSEM documentation built on April 14, 2025, 3:53 p.m.