sim_alignment_with_n_mutations: Converts a phylogeny to a random DNA alignment

View source: R/sim_alignment_with_n_mutations.R

sim_alignment_with_n_mutationsR Documentation

Converts a phylogeny to a random DNA alignment

Description

The function is used to create both the true (see create_true_alignment) and twin alignment (see sim_twin_alignment).

Usage

sim_alignment_with_n_mutations(
  phylogeny,
  root_sequence,
  n_mutations,
  mutation_rate = 1,
  site_model = beautier::create_jc69_site_model(),
  max_n_tries = 100,
  verbose = FALSE
)

Arguments

phylogeny

a phylogeny of class phylo

root_sequence

the DNA sequence at the root of the phylogeny. By default, this will consist out of an equal amount of each letter Use check_root_sequence to check if a root sequence is valid.

n_mutations

the number of different base pairs between root sequence and the resulting alignment. Set to NA if any number of mutations is fine.

mutation_rate

the mutation rate per base pair per time unit. Use check_mutation_rate to check if a mutation rate is valid.

site_model

a nucleotide substitution model, which can be:

  • A standard nucloetide substitution model, as created by create_site_model

  • lns: a linked node-substitution model

  • uns: an unlinked node-substitution model

max_n_tries

number of attempts to simulate a DNA alignment with the desired number of mutations. If this number of attempts is reached, the funcion will show a warning and return the last DNA alignment simulated.

verbose

if TRUE, show more output

Value

an alignment

an alignment of type DNAbin

Author(s)

Richèl J.C. Bilderbeek, Giovanni Laudanno

Richèl J.C. Bilderbeek

See Also

Use create_tral_file to save the simulated alignment directly to a file.

Use sim_tral_with_std_nsm simulate the true alignment with a standard site model. Use sim_twal_with_std_nsm simulate the twin alignment with a standard site model.

Examples

# Create the phylogeny to simulate the alignment on
n_taxa <- 5
phylogeny <- ape::rcoal(n_taxa)

# Use default settings to create the alignment
alignment_params <- create_alignment_params()

# Simulate the alignment
alignment <- sim_true_alignment(
   true_phylogeny = phylogeny,
   alignment_params = alignment_params,
 )
check_alignment(alignment)

richelbilderbeek/pirouette documentation built on Oct. 18, 2023, 3:09 p.m.