ts_mutate: Add mutations to the given tree sequence

View source: R/tree-sequences.R

ts_mutateR Documentation

Add mutations to the given tree sequence

Description

Add mutations to the given tree sequence

Usage

ts_mutate(
  ts,
  mutation_rate,
  random_seed = NULL,
  keep_existing = TRUE,
  mutation_model = NULL
)

Arguments

ts

Tree sequence object of the class slendr_ts

mutation_rate

Mutation rate used by msprime to simulate mutations

random_seed

Random seed passed to msprime's mutate method (if NULL, a seed will be generated between 0 and the maximum integer number available)

keep_existing

Keep existing mutations?

mutation_model

Which mutation model to use? If NULL (default), no special mutation type will be used. Otherwise, a mutation model matching https://tskit.dev/msprime/docs/stable/mutations.html may be provided as a Python/reticulate object. For instance, msprime$SLiMMutationModel(type=42L) will add SLiM mutation with the mutation type 42.

Value

Tree-sequence object of the class slendr_ts, which serves as an interface point for the Python module tskit using slendr functions with the ts_ prefix.

See Also

ts_nodes for extracting useful information about individuals, nodes, coalescent times and geospatial locations of nodes on a map

Examples


init_env()

# load an example model with an already simulated tree sequence
slendr_ts <- system.file("extdata/models/introgression_slim.trees", package = "slendr")
model <- read_model(path = system.file("extdata/models/introgression", package = "slendr"))

ts <- ts_read(slendr_ts, model)
ts_mutate <- ts_mutate(ts, mutation_rate = 1e-8, random_seed = 42)

ts_mutate

bodkan/slendr documentation built on Dec. 19, 2024, 11:41 p.m.