Package: slendr 1.0.0

Martin Petr

slendr: A Simulation Framework for Spatiotemporal Population Genetics

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.

Authors:Martin Petr [aut, cre]

slendr_1.0.0.tar.gz
slendr_1.0.0.tar.gz(r-4.5-noble)slendr_1.0.0.tar.gz(r-4.4-noble)
slendr_1.0.0.tgz(r-4.4-emscripten)slendr_1.0.0.tgz(r-4.3-emscripten)
slendr.pdf |slendr.html
slendr/json (API)
NEWS

# Install 'slendr' in R:
install.packages('slendr', repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/bodkan/slendr/issues

5.28 score 70 scripts 368 downloads 69 exports 80 dependencies

Last updated 3 days agofrom:fe745c6902. Checks:OK: 2. Indexed: no.

TargetResultDate
Doc / VignettesOKNov 25 2024
R-4.5-linuxOKNov 25 2024

Exports:%>%animate_modelareaas.phylo.slendr_phylocheck_dependenciescheck_envclear_envcompile_modeldistanceexpand_rangeexplore_modelextract_parametersgene_flowinit_envjoinmovemsprimeoverlapplot_mapplot_modelpopulationprint.slendr_tsread_modelregionreprojectresizeschedule_samplingset_dispersalset_rangesetup_envshrink_rangeslimsubstitute_valuessubtractts_afsts_ancestorsts_coalescedts_descendantsts_divergencets_diversityts_drawts_edgests_eigenstratts_f2ts_f3ts_f4ts_f4ratiots_fstts_genotypests_ibdts_loadts_metadatats_mutatets_namests_nodests_phylots_readts_recapitatets_samplests_savets_segregatingts_simplifyts_tablets_tajimats_tractsts_treets_vcfts_writeworld

Dependencies:apebackportsbase64encbitbit64bslibcachemcheckmateclicliprcolorspacecommonmarkcpp11crayondigestdplyrfansifarverfastmapfontawesomefsgenericsggplot2gluegtableherehmshtmltoolshttpuvijtiffisobandjquerylibjsonlitelabelinglaterlatticelifecyclemagrittrMASSMatrixmemoisemgcvmimemunsellnlmepillarpkgconfigpngprettyunitsprogresspromisespurrrR6rappdirsRColorBrewerRcppRcppTOMLreadrreticulaterlangrprojrootsassscalesshinyshinyWidgetssourcetoolsstrexstringistringrtibbletidyrtidyselecttzdbutf8vctrsviridisLitevroomwithrxtablezeallot

Analyzing non-slendr tree sequences

Rendered fromvignette-08-nonslendr-tskit.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2022-08-09

Demes on a regular spatial grid

Rendered fromvignette-02-grid-model.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2022-08-09

Extending models with custom SLiM code

Rendered fromvignette-11-extensions.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2024-11-22

Extracting true ancestry tracts

Rendered fromvignette-10-tracts.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2023-12-08

Installation instructions

Rendered fromvignette-00-installation.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2022-08-09

Introduction and basic tutorial

Rendered fromvignette-01-tutorial.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2022-08-09

Programming dispersion dynamics

Rendered fromvignette-03-interactions.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2022-08-09

Simulations using SLiM and msprime engines

Rendered fromvignette-07-engines.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2024-11-22

Spatially annotated tree sequences

Rendered fromvignette-06-locations.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2022-08-09

Traditional, non-spatial models

Rendered fromvignette-04-nonspatial-models.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2022-08-09

Tree-sequence processing and statistics

Rendered fromvignette-05-tree-sequences.Rmdusingknitr::rmarkdownon Nov 25 2024.

Last update: 2024-11-22
Started: 2022-08-09

Readme and manuals

Help Manual

Help pageTopics
Animate the simulated population dynamicsanimate_model
Calculate the area covered by the given slendr objectarea
Check that the required dependencies are available for slendr to workcheck_dependencies
Check that the active Python environment is setup for slendrcheck_env
Remove the automatically created slendr Python environmentclear_env
Compile a slendr demographic modelcompile_model
Calculate the distance between a pair of spatial boundariesdistance
Expand the population rangeexpand_range
Open an interactive browser of the spatial modelexplore_model
Extract information from a compiled model or a simulated tree sequenceextract_parameters
Define a gene-flow event between two populationsgene_flow
Get the name of the current slendr Python environmentget_env
Activate slendr's own dedicated Python environmentinit_env
Merge two spatial 'slendr' objects into onejoin
Move the population to a new location in a given amount of timemove
Run a slendr model in msprimemsprime
Generate the overlap of two 'slendr' objectsoverlap
Plot 'slendr' geographic features on a mapplot_map
Plot demographic history encoded in a slendr modelplot_model
Define a populationpopulation
Print a short summary of a 'slendr' objectprint.slendr_map print.slendr_model print.slendr_pop print.slendr_region
Print tskit's summary table of the Python tree-sequence objectprint.slendr_ts
Read a previously serialized model configurationread_model
Define a geographic regionregion
Reproject coordinates between coordinate systemsreproject
Change the population sizeresize
Define sampling events for a given set of populationsschedule_sampling
Change dispersal parametersset_dispersal
Update the population rangeset_range
Setup a dedicated Python virtual environment for slendrsetup_env
Shrink the population rangeshrink_range
Run a slendr model in SLiMslim
Substitute values of parameters in a SLiM extension templatesubstitute_values
Generate the difference between two 'slendr' objectssubtract
Summarise the contents of a 'ts_nodes' resultsummary.slendr_nodes
Compute the allele frequency spectrum (AFS)ts_afs
Extract (spatio-)temporal ancestral history for given nodes/individualsts_ancestors
Check that all trees in the tree sequence are fully coalescedts_coalesced
Extract all descendants of a given tree-sequence nodets_descendants
Calculate pairwise divergence between sets of individualsts_divergence
Calculate diversity in given sets of individualsts_diversity
Plot a graphical representation of a single treets_draw
Extract spatio-temporal edge annotation table from a given tree or tree sequencets_edges
Convert genotypes to the EIGENSTRAT file formatts_eigenstrat
Calculate the f2, f3, f4, and f4-ratio statisticsts_f2 ts_f3 ts_f4 ts_f4ratio
Calculate pairwise statistics between sets of individualsts_fst
Extract genotype table from the tree sequencets_genotypes
Collect Identity-by-Descent (IBD) segments (EXPERIMENTAL)ts_ibd
Read a tree sequence from a filets_load
Extract list with tree sequence metadata saved by SLiMts_metadata
Add mutations to the given tree sequencets_mutate
Extract names of individuals in a tree sequencets_names
Extract combined annotated table of individuals and nodests_nodes
Convert a tree in the tree sequence to an object of the class 'phylo'ts_phylo
Read a tree sequence from a filets_read
Recapitate the tree sequencets_recapitate
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_samples
Write a tree sequence to a filets_save
Calculate the density of segregating sites for the given sets of individualsts_segregating
Simplify the tree sequence down to a given set of individualsts_simplify
Get the table of individuals/nodes/edges/mutations/sites from the tree sequencets_table
Calculate Tajima's D for given sets of individualsts_tajima
Extract ancestry tracts from a tree sequence (EXPERIMENTAL)ts_tracts
Get a tree from a given tree sequencets_tree
Save genotypes from the tree sequence as a VCF filets_vcf
Save a tree sequence to a filets_write
Define a world map for all spatial operationsworld