degenerate: Degenerate protein sequence

Description Usage Arguments Value Note See Also Examples

View source: R/degenerate.R

Description

'Degenerates' amino acid or nucleic sequence by aggregating elements to bigger groups.

Usage

1
degenerate(seq, element_groups)

Arguments

seq

character vector or matrix representing single sequence.

element_groups

encoding of elements: list of groups to which elements of sequence should be aggregated. Must have unique names.

Value

A character vector or matrix (if input is a matrix) containing aggregated elements.

Note

Characters not present in the element_groups will be converted to NA with a warning.

See Also

l2n to easily convert information stored in biological sequences from letters to numbers. calc_ed to calculate distance between encodings.

Examples

1
2
3
4
5
6
sample_seq <- c(1, 3, 1, 3, 4, 4, 3, 1, 2)
table(sample_seq)

# aggregate sequence to purins and pyrimidines
deg_seq <- degenerate(sample_seq, list(w = c(1, 4), s = c(2, 3)))
table(deg_seq)

Example output

Loading required package: slam
sample_seq
1 2 3 4 
3 1 3 2 
deg_seq
s w 
4 5 

biogram documentation built on March 31, 2020, 5:14 p.m.