nucleotide_diff: Find single character differences in sequences

Description Usage Arguments Value Examples

View source: R/sequence_diffs.R

Description

Function takes a baseline sequence and any number of sequences to compare to and determines the number or the positions of single character differences. Note that this function can be used with amino acid sequences (1 letter abbreviation) as well.

Usage

1
2
3
4
5
6
nucleotide_diff(
  baseline_seq,
  compare_seqs,
  output = c("num", "position"),
  ignore_case = TRUE
)

Arguments

baseline_seq

Character vector of length one that all other sequences are being compared to.

compare_seqs

Character vector of any length that will be compared to the baseline seq.

output

Either "num" (return the number of differences) or "position" (return the positions of the differences).

ignore_case

Logical value (TRUE / FALSE) designating whether the function should ignore case. Defaults to TRUE.

Value

Either a list of numeric vectors describing the positions of differences or a numeric vector of the number of differences.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
nucleotide_diff('AGTGGG', 'CGTGAG', output = 'num')

seq1 = 'ACTGACTGG'
seq2 = c('ACGGGCCGG', 'ACTGACTGG', 'GCTCAGTGG')
nucleotide_diff(seq1, seq2, output = 'num', ignore_case = TRUE)
nucleotide_diff(seq1, seq2, output = 'position', ignore_case = FALSE)

## Not run: 
nucleotide_diff(seq1, seq2)
nucleotide_diff('AGTCGA', 'TTA')

## End(Not run)

ryanmcnamara4/myPackage documentation built on Dec. 22, 2021, 8:18 p.m.