shmulateSeq - Simulate mutations in a single sequence
Description¶
Generates random mutations in a sequence iteratively using a targeting model. Targeting probabilities at each position are updated after each iteration.
Usage¶
shmulateSeq(
sequence,
numMutations,
targetingModel = HH_S5F,
start = 1,
end = nchar(sequence),
frequency = FALSE
)
Arguments¶
- sequence
- sequence string in which mutations are to be introduced.
Accepted alphabet:
{A, T, G, C, N, .}. Note that-is not accepted. - numMutations
- a whole number indicating the number of mutations to be
introduced into
sequence, iffrequency=FALSE. A fraction between 0 and 1 indicating the mutation frequency iffrequency=TRUE. - targetingModel
- 5-mer TargetingModel object to be used for computing probabilities of mutations at each position. Defaults to HH_S5F.
- start
- Initial position in
sequencewhere mutations can be introduced. Default: 1 - end
- Last position in
sequencewhere mutations can be introduced. Default: last position (sequence length). - frequency
- If
TRUE, treatnumMutationsas a frequency.
Value¶
A string defining the mutated sequence.
Details¶
If the input sequence has a non-triplet overhang at the end, it will be trimmed
to the last codon. For example, ATGCATGC will be trimmed to ATGCAT.
Mutations are not introduced to positions in the input sequence that contain
. or N.
With frequency=TRUE, the number of mutations is calculated according to the probability
of mutation at each position. For example, if numMutations=0.05 and the length of
the input sequence is 100, then the number of mutations will be sampled from a
binomial distribution with 100 trials and a probability of 0.05.
Examples¶
# Define example input sequence
sequence <- "NGATCTGACGACACGGCCGTGTATTACTGTGCGAGAGATA.TTTA"
# Simulate using the default human 5-mer targeting model
# Introduce 6 mutations
shmulateSeq(sequence, numMutations=6, frequency=FALSE)
[1] "NGGTCTGACGACACGGCCATGTATTATTCTGCCAGAGATG.TTTA"
# Introduction 5% mutations
shmulateSeq(sequence, numMutations=0.05, frequency=TRUE)
[1] "NGATCTGACGACACGGCCGTGTACTGCCGTGCGAGAGATT.TTTA"
See also¶
See shmulateTree for imposing mutations on a lineage tree. See HH_S5F and MK_RS5NF for predefined TargetingModel objects.