Learn R Programming

slendr (version 1.1.0)

ts_write: Save a tree sequence to a file

Description

Save a tree sequence to a file

Usage

ts_write(ts, file)

Value

No return value, called for side effects

Arguments

ts

Tree sequence object loaded by ts_read

file

File to which the tree sequence should be saved

Examples

Run this code
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 the tree sequence
ts <- ts_read(slendr_ts, model)

# save the tree-sequence object to a different location
another_file <- paste(tempfile(), ".trees")
ts_write(ts, another_file)

Run the code above in your browser using DataLab