Skip to content

slendr 1.0.0

Latest
Compare
Choose a tag to compare
@bodkan bodkan released this 28 Nov 09:11
· 26 commits to main since this release

Implementing changes for the v1.0 release (particularly the support for non-neutral models) required changing slendr internals at a very low level across the whole codebase. Feedback on this functionality, missing features, and bug reports are highly appreciated!

Other changes:

  • The behavior previously implemented via the output = and ts = arguments of slim() (and msprime()) has been changed to facilitate more straightforward handling of output paths in user-defined SLiM extensions and other packages leveraging slendr for inference. The slim() and msprime() function interfaces are now simplified in the following way:

    • slim(): the ts argument is now logical. TRUE switches on tree-sequence recording, FALSE switches it off. If tree-sequence recording is on (the default setting), the function automatically returns a tree-sequence R object. If users want to save it to a custom location, they should use the function ts_write() on the returned tree-sequence object. If customized output files are to be produced via user-defined extension scripts, those scripts can use a slendr/SLiM constant PATH, which is always available in the built-in SLiM script and which can be set from R via slim(..., path = <path to a directory>). In that case, the slim() function always returns that path back. Crucially, in this case slim() will not return a tree sequence object, but that object can be loaded by ts_read("<path to a directory>/slim.trees"). In other words, nothing changes for the usual SLiM-based slendr workflow, but for models generating custom output files, a small amount of work is needed to load the tree sequence -- the tree-sequence file outputs are therefore treated exactly the same way as non-tree-sequence user-defined output files. As a result of these changes, slim() no longer accepts a load = TRUE|FALSE argument.

The above is implemented in PR #157.

  • ts_genotypes() now works even for non-slendr tree sequences, which do not have slendr individual names of samples in the ts_nodes() output. (#d348ec)

  • Due to frequent issues with installation of Python dependencies of slendr in a completely platform independent way (in the latest instance this being conda installation of pyslim crashing on M-architecture Macs), setup_env() now only uses conda to install msprime and tskit -- pyslim and tspop are always installed via pip regardless of whether setup_env(pip = FALSE) (the default) or setup_env(pip = TRUE) is used. (#408948)

  • A new function extract_parameters() can extract parameters of either a compiled slendr model object or a tree sequence simulated from a slendr model. This can be useful particularly for simulation-based inferences where model parameters are often drawn from random distributions and there's a need to know which parameters of a model (split times, gene-flow rates, etc.) have been drawn. (#3632bd0)

  • compile_model() now allows to specify a description of time units used while scheduling slendr model events. This has purely descriptive purpose -- in particular, these units are used in model plotting functions, etc. (#9b5b7ea0)

  • The slim_script argument of compile_model() has been replaced by extension argument, which allows users to provide their custom-designed SLiM snippets for extending the behavior of slendr's SLiM simulation engine. (#d11ac7)

  • The sim_length argument of compile_model() has been removed following a long period of deprecatiaon. (#12da50)

  • When a named list of samples is used as X input to ts_f4ratio(), the name of the element is used in the X column of the resulting data frame. (#0571a6)

  • ts_table() can now extract the "sites" tskit table as ts_table(ts, "sites"). (#e708f2)

  • When applied to slendr tree sequences, ts_recapitate() no longer issues the warning: TimeUnitsMismatchWarning: The initial_state has time_units=ticks but time is measured in generations in msprime. This may lead to significant discrepancies between the timescales. If you wish to suppress this warning, you can use, e.g., warnings.simplefilter('ignore', msprime.TimeUnitsMismatchWarning). For slendr tree sequences, ticks are the same thing as generations anyway. (#43c45083)

  • Running slim(..., method = "gui") was broken due to recent changes to make slendr work on Windows. A path to a generated SLiM script executed in SLiMgui was incorrectly normalized. Non-SLiMgui runs were not affected. (#ccae1df)