check_dependencies(python = TRUE, quit = TRUE) # dependencies must be present
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"))
# load tree sequence generated by a given model
ts <- ts_read(slendr_ts, model)
# even tree sequences generated by non-slendr models can be
msprime_ts <- system.file("extdata/models/msprime.trees", package = "slendr")
ts <- ts_read(msprime_ts)
# load tree sequence and immediately simplify it only to sampled individuals
# (note that the example tree sequence is already simplified so this operation
# does not do anything in this case)
ts <- ts_read(slendr_ts, model = model) %>% ts_simplify(keep_input_roots = TRUE)
# load tree sequence and simplify it to a subset of sampled individuals
ts_small <- ts_simplify(ts, simplify_to = c("CH_1", "NEA_1", "NEA_2",
"AFR_1", "AFR_2", "EUR_1", "EUR_2"))
# load tree sequence, recapitate it and simplify it
ts <- ts_read(slendr_ts, model) %>%
ts_recapitate(recombination_rate = 1e-8, Ne = 10000, random_seed = 42) %>%
ts_simplify()
# load tree sequence, recapitate it, simplify it and overlay neutral mutations
ts <- ts_read(slendr_ts, model) %>%
ts_recapitate(recombination_rate = 1e-8, Ne = 10000, random_seed = 42) %>%
ts_simplify() %>%
ts_mutate(mutation_rate = 1e-8)
ts
Run the code above in your browser using DataLab