slendr1.4.0 package

A Simulation Framework for Spatiotemporal Population Genetics

animate_model

Animate the simulated population dynamics

area

Calculate the area covered by the given slendr object

as.phylo.slendr_phylo

Convert an annotated slendr_phylo object to a phylo object

check_dependencies

Check that the required dependencies are available for slendr to work

check_env

Check that the active Python environment is setup for slendr

clear_env

Remove the automatically created slendr Python environment

compile_model

Compile a slendr demographic model

distance

Calculate the distance between a pair of spatial boundaries

expand_range

Expand the population range

explore_model

Open an interactive browser of the spatial model

extract_parameters

Extract information from a compiled model or a simulated tree sequence

gene_flow

Define a gene-flow event between two populations

get_python

Get a path to internal Python interpreter of slendr

init_env

Activate slendr's own dedicated Python environment

join

Merge two spatial slendr objects into one

move

Move the population to a new location in a given amount of time

msprime

Run a slendr model in msprime

overlap

Generate the overlap of two slendr objects

pipe

Pipe operator

plot_map

Plot slendr geographic features on a map

plot_model

Plot demographic history encoded in a slendr model

population

Define a population

print.slendr_pop

Print a short summary of a slendr object

print.slendr_ts

Print tskit's summary table of the Python tree-sequence object

read_model

Read a previously serialized model configuration

region

Define a geographic region

reproject

Reproject coordinates between coordinate systems

resize

Change the population size

schedule_sampling

Define sampling events for a given set of populations

set_dispersal

Change dispersal parameters

set_range

Update the population range

setup_env

Setup a dedicated Python virtual environment for slendr

shrink_range

Shrink the population range

slendr

A Simulation Framework for Spatiotemporal Population Genetics

slim

Run a slendr model in SLiM

substitute_values

Substitute values of parameters in a SLiM extension template

subtract

Generate the difference between two slendr objects

summary.slendr_nodes

Summarise the contents of a ts_nodes result

ts_afs

Compute the allele frequency spectrum (AFS)

ts_ancestors

Extract (spatio-)temporal ancestral history for given nodes/individual...

ts_coalesced

Check that all trees in the tree sequence are fully coalesced

ts_descendants

Extract all descendants of a given tree-sequence node

ts_divergence

Calculate pairwise divergence between sets of individuals

ts_diversity

Calculate diversity in given sets of individuals

ts_draw

Plot a graphical representation of a single tree

ts_edges

Extract spatio-temporal edge annotation table from a given tree or tre...

ts_eigenstrat

Convert genotypes to the EIGENSTRAT file format

ts_f4ratio

Calculate the f2, f3, f4, and f4-ratio statistics

ts_fst

Calculate pairwise statistics between sets of individuals

ts_genotypes

Extract genotype table from the tree sequence

ts_ibd

Collect Identity-by-Descent (IBD) segments (EXPERIMENTAL)

ts_load

Read a tree sequence from a file

ts_metadata

Extract list with tree sequence metadata saved by SLiM

ts_mutate

Add mutations to the given tree sequence

ts_names

Extract names of individuals in a tree sequence

ts_nodes

Extract combined annotated table of individuals and nodes

ts_phylo

Convert a tree in the tree sequence to an object of the class phylo

ts_read

Read a tree sequence from a file

ts_recapitate

Recapitate the tree sequence

ts_samples

Extract names and times of individuals of interest in the current tree...

ts_save

Write a tree sequence to a file

ts_segregating

Calculate the density of segregating sites for the given sets of indiv...

ts_simplify

Simplify the tree sequence down to a given set of individuals

ts_table

Get the table of individuals/nodes/edges/mutations/sites from the tree...

ts_tajima

Calculate Tajima's D for given sets of individuals

ts_tracts

Extract ancestry tracts from a tree sequence (EXPERIMENTAL)

ts_tree

Get a tree from a given tree sequence

ts_vcf

Save genotypes from the tree sequence as a VCF file

ts_write

Save a tree sequence to a file

world

Define a world map for all spatial operations

A framework for simulating spatially explicit genomic data which leverages real cartographic information for programmatic and visual encoding of spatiotemporal population dynamics on real geographic landscapes. Population genetic models are then automatically executed by the 'SLiM' software by Haller et al. (2019) <doi:10.1093/molbev/msy228> behind the scenes, using a custom built-in simulation 'SLiM' script. Additionally, fully abstract spatial models not tied to a specific geographic location are supported, and users can also simulate data from standard, non-spatial, random-mating models. These can be simulated either with the 'SLiM' built-in back-end script, or using an efficient coalescent population genetics simulator 'msprime' by Baumdicker et al. (2022) <doi:10.1093/genetics/iyab229> with a custom-built 'Python' script bundled with the R package. Simulated genomic data is saved in a tree-sequence format and can be loaded, manipulated, and summarised using tree-sequence functionality via an R interface to the 'Python' module 'tskit' by Kelleher et al. (2019) <doi:10.1038/s41588-019-0483-y>. Complete model configuration, simulation and analysis pipelines can be therefore constructed without a need to leave the R environment, eliminating friction between disparate tools for population genetic simulations and data analysis.

  • Maintainer: Martin Petr
  • License: MIT + file LICENSE
  • Last published: 2026-01-16