Skip to contents

Compiling and running population genetic models

slim()
Run a slendr model in SLiM
msprime()
Run a slendr model in msprime
compile_model()
Compile a slendr demographic model
read_model()
Read a previously serialized model configuration
schedule_sampling()
Define sampling events for a given set of populations

Installation and configuration of external dependencies

setup_env()
Setup a dedicated Python virtual environment for slendr
init_env()
Activate slendr's own dedicated Python environment
check_env()
Check that the active Python environment is setup for slendr
clear_env()
Remove the automatically created slendr Python environment
get_env()
Get the name of the current slendr Python environment
check_dependencies()
Check that the required dependencies are available for slendr to work

Model components

population()
Define a population
world()
Define a world map for all spatial operations

Spatial population dynamics

move()
Move the population to a new location in a given amount of time
expand_range()
Expand the population range
shrink_range()
Shrink the population range
set_range()
Update the population range
set_dispersal()
Change dispersal parameters

Non-spatial population dynamics

gene_flow()
Define a gene-flow event between two populations
resize()
Change the population size

Manipulation of spatial objects

region()
Define a geographic region
join()
Merge two spatial slendr objects into one
overlap()
Generate the overlap of two slendr objects
subtract()
Generate the difference between two slendr objects
reproject()
Reproject coordinates between coordinate systems
distance()
Calculate the distance between a pair of spatial boundaries
area()
Calculate the area covered by the given slendr object

Model visualization and diagnostics

plot_map()
Plot slendr geographic features on a map
plot_model()
Plot demographic history encoded in a slendr model
animate_model()
Animate the simulated population dynamics
explore_model()
Open an interactive browser of the spatial model
print(<slendr_pop>) print(<slendr_region>) print(<slendr_map>) print(<slendr_model>)
Print a short summary of a slendr object
print(<slendr_ts>)
Print tskit's summary table of the Python tree-sequence object
summary(<slendr_nodes>)
Summarise the contents of a ts_nodes result
extract_parameters()
Extract information from a compiled model or a simulated tree sequence

Tree sequence loading and processing

ts_load()
Load a tree sequence file produced by a given model
ts_save()
Save a tree sequence to a file
ts_recapitate()
Recapitate the tree sequence
ts_simplify()
Simplify the tree sequence down to a given set of individuals
ts_mutate()
Add mutations to the given tree sequence
ts_samples()
Extract names and times of individuals of interest in the current tree sequence (either all sampled individuals or those that the user simplified to)
ts_names()
Extract names of individuals in a tree sequence
ts_coalesced()
Check that all trees in the tree sequence are fully coalesced

Tree sequence format conversion

ts_genotypes()
Extract genotype table from the tree sequence
ts_eigenstrat()
Convert genotypes to the EIGENSTRAT file format
ts_vcf()
Save genotypes from the tree sequence as a VCF file

Accessing tree sequence components

ts_nodes()
Extract combined annotated table of individuals and nodes
ts_edges()
Extract spatio-temporal edge annotation table from a given tree or tree sequence
ts_table()
Get the table of individuals/nodes/edges/mutations from the tree sequence
ts_phylo()
Convert a tree in the tree sequence to an object of the class phylo
ts_tree()
Get a tree from a given tree sequence
ts_draw()
Plot a graphical representation of a single tree
ts_metadata()
Extract list with tree sequence metadata saved by SLiM
ts_ancestors()
Extract (spatio-)temporal ancestral history for given nodes/individuals
ts_descendants()
Extract all descendants of a given tree-sequence node

Tree sequence statistics

ts_f2() ts_f3() ts_f4() ts_f4ratio()
Calculate the f2, f3, f4, and f4-ratio statistics
ts_afs()
Compute the allele frequency spectrum (AFS)
ts_divergence()
Calculate pairwise divergence between sets of individuals
ts_diversity()
Calculate diversity in given sets of individuals
ts_fst()
Calculate pairwise statistics between sets of individuals
ts_tajima()
Calculate Tajima's D for given sets of individuals
ts_segregating()
Calculate the density of segregating sites for the given sets of individuals
ts_ibd()
Collect Identity-by-Descent (IBD) segments (EXPERIMENTAL)
ts_tracts()
Extract ancestry tracts from a tree sequence (EXPERIMENTAL)