Add mutations to the given tree sequence
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- keep_existing
Keep existing mutations?
- mut_type
Assign SLiM mutation type to neutral mutations? If
NULL
(default), no special mutation type will be used. If an integer number is given, mutations of the SLiM mutation type with that integer identifier will be created.
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
check_dependencies(python = TRUE, quit = TRUE) # dependencies must be present
init_env()
#> The interface to all required Python modules has been activated.
# load an example model with an already simulated tree sequence
slendr_ts <- system.file("extdata/models/introgression.trees", package = "slendr")
model <- read_model(path = system.file("extdata/models/introgression", package = "slendr"))
ts <- ts_load(slendr_ts, model)
ts_mutate <- ts_mutate(ts, mutation_rate = 1e-8, random_seed = 42)
ts_mutate
#> ╔═════════════════════════╗
#> ║TreeSequence ║
#> ╠═══════════════╤═════════╣
#> ║Trees │ 24║
#> ╟───────────────┼─────────╢
#> ║Sequence Length│ 500000║
#> ╟───────────────┼─────────╢
#> ║Time Units │ ticks║
#> ╟───────────────┼─────────╢
#> ║Sample Nodes │ 26║
#> ╟───────────────┼─────────╢
#> ║Total Size │197.3 KiB║
#> ╚═══════════════╧═════════╝
#> ╔═══════════╤════╤════════╤════════════╗
#> ║Table │Rows│Size │Has Metadata║
#> ╠═══════════╪════╪════════╪════════════╣
#> ║Edges │ 134│ 4.2 KiB│ No║
#> ╟───────────┼────┼────────┼────────────╢
#> ║Individuals│ 56│ 7.3 KiB│ Yes║
#> ╟───────────┼────┼────────┼────────────╢
#> ║Migrations │ 0│ 8 Bytes│ No║
#> ╟───────────┼────┼────────┼────────────╢
#> ║Mutations │2269│83.2 KiB│ No║
#> ╟───────────┼────┼────────┼────────────╢
#> ║Nodes │ 69│ 3.2 KiB│ Yes║
#> ╟───────────┼────┼────────┼────────────╢
#> ║Populations│ 5│ 2.6 KiB│ Yes║
#> ╟───────────┼────┼────────┼────────────╢
#> ║Provenances│ 4│37.8 KiB│ No║
#> ╟───────────┼────┼────────┼────────────╢
#> ║Sites │2265│55.3 KiB│ No║
#> ╚═══════════╧════╧════════╧════════════╝
#>