{"id":32177614,"url":"https://github.com/tskit-dev/pyslim","last_synced_at":"2026-03-06T23:03:27.259Z","repository":{"id":32664131,"uuid":"138037378","full_name":"tskit-dev/pyslim","owner":"tskit-dev","description":"Tools for dealing with tree sequences coming to and from SLiM.","archived":false,"fork":false,"pushed_at":"2025-12-17T06:52:54.000Z","size":16971,"stargazers_count":28,"open_issues_count":35,"forks_count":23,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-12-20T20:17:15.435Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tskit-dev.png","metadata":{"files":{"readme":"README.html","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-06-20T13:34:56.000Z","updated_at":"2025-12-17T06:52:59.000Z","dependencies_parsed_at":"2022-07-09T13:00:26.948Z","dependency_job_id":"3dd37dad-63a3-4b3a-abd8-d2d56b9d955d","html_url":"https://github.com/tskit-dev/pyslim","commit_stats":{"total_commits":246,"total_committers":15,"mean_commits":16.4,"dds":0.1260162601626016,"last_synced_commit":"76ed4469ed40df205b51026485526df307f5b039"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/tskit-dev/pyslim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tskit-dev%2Fpyslim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tskit-dev%2Fpyslim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tskit-dev%2Fpyslim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tskit-dev%2Fpyslim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tskit-dev","download_url":"https://codeload.github.com/tskit-dev/pyslim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tskit-dev%2Fpyslim/sbom","scorecard":{"id":900871,"data":{"date":"2025-08-11","repo":{"name":"github.com/tskit-dev/pyslim","commit":"0a7979619daa69f592b585c8507d53cb5f1bfe7b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Code-Review","score":2,"reason":"Found 5/23 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":10,"reason":"16 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/docs.yml:1","Warn: no topLevel permission defined: .github/workflows/tests.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/docs.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/docs.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/docs.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/docs.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/docs.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/docs.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/docs.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/docs.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/tests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/tests.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/tests.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/tests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:76: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/tests.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:118: update your workflow using https://app.stepsecurity.io/secureworkflow/tskit-dev/pyslim/tests.yml/main?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   6 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-34 / GHSA-2fc2-6r4j-p65h","Warn: Project is vulnerable to: PYSEC-2021-856 / GHSA-5545-2q6w-2gh6","Warn: Project is vulnerable to: PYSEC-2019-108 / GHSA-9fq2-x9r6-wfmf","Warn: Project is vulnerable to: PYSEC-2018-33 / GHSA-cw6w-4rcx-xphc","Warn: Project is vulnerable to: PYSEC-2021-857 / GHSA-f7c7-j99h-c22f","Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: PYSEC-2017-1 / GHSA-frgw-fgh6-9g52"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T15:31:13.333Z","repository_id":32664131,"created_at":"2025-08-24T15:31:13.333Z","updated_at":"2025-08-24T15:31:13.333Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29738083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T04:51:08.365Z","status":"ssl_error","status_checked_at":"2026-02-23T04:49:15.865Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-21T20:14:49.891Z","updated_at":"2026-02-23T05:02:01.735Z","avatar_url":"https://github.com/tskit-dev.png","language":"Python","readme":"\u003ch1 id=\"pyslim\"\u003epySLiM\u003c/h1\u003e\n\u003cp\u003eSLiM can now read, and write tree sequences, which store genealogical data of populations. SLiM can use a tree sequence produced by the coalescent simulator \u003ccode\u003emsprime\u003c/code\u003e to initialize a simulation, but to do so we need to add the relevant metadata. SLiM can also write out history as a tree sequence, and in so doing it records extra information in metadata. This package makes it easy to add the relevant metadata to a tree sequence so that SLiM can use it, and to read the metadata in a SLiM-produced tree sequence.\u003c/p\u003e\n\u003cp\u003eThe SLiM manual documents how the extra metadata is stored in the tree sequence files, and provides additional examples of how to use this package.\u003c/p\u003e\n\u003ch2 id=\"installation\"\u003eInstallation\u003c/h2\u003e\n\u003cp\u003eTo install \u003ccode\u003epyslim\u003c/code\u003e, do\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003egit clone https://github.com/tskit-dev/pyslim.git\ncd pyslim\npython setup.py install --user\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003eYou should also be able to install it with \u003ccode\u003epip install pyslim\u003c/code\u003e. You’ll also need an up-to-date \u003ca href=\"https://github.com/tskit-dev/msprime\"\u003emsprime\u003c/a\u003e and \u003ca href=\"https://messerlab.org/slim/\"\u003eSLiM\u003c/a\u003e, of course.\u003c/p\u003e\n\u003cp\u003eTo run the tests to make sure everything is working, do:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003ecd tests/examples\nfor x in *.slim; do slim $x; done\ncd -\npython -m nose tests\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003e\u003cem\u003eNote:\u003c/em\u003e if you use \u003ccode\u003epython3\u003c/code\u003e you may need to replace \u003ccode\u003epython\u003c/code\u003e with \u003ccode\u003epython3\u003c/code\u003e above.\u003c/p\u003e\n\u003ch2 id=\"quickstart-coalescent-simulation-for-slim\"\u003eQuickstart: coalescent simulation for SLiM\u003c/h2\u003e\n\u003cp\u003eThe \u003ccode\u003epyslim.annotate()\u003c/code\u003e command will add default information to a tree sequence, allowing it to be read in by SLiM. This will simulate a tree sequence with msprime, add SLiM information, and write it out to a \u003ccode\u003e.trees\u003c/code\u003e file:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eimport msprime\nimport pyslim\n\n# simulate a tree sequence of 12 nodes\nts = msprime.simulate(12, mutation_rate=1.0, recombination_rate=1.0)\nnew_ts = pyslim.annotate_defaults(ts, model_type=\u0026quot;nonWF\u0026quot;, slim_generation=1)\nnew_ts.dump(\u0026quot;slim_ts.trees\u0026quot;)\u003c/code\u003e\u003c/pre\u003e\n\u003ch2 id=\"quickstart-reading-slim-metadata\"\u003eQuickstart: reading SLiM metadata\u003c/h2\u003e\n\u003cp\u003eTo retrieve the extra information that SLiM stores in a tree sequence, use the \u003ccode\u003eextract_X_metadata()\u003c/code\u003e functions, where \u003ccode\u003eX\u003c/code\u003e is one of \u003ccode\u003emutation\u003c/code\u003e, \u003ccode\u003epopulation\u003c/code\u003e, \u003ccode\u003enode\u003c/code\u003e, or \u003ccode\u003eindividual\u003c/code\u003e. For instance, to see the age of each Individual produced by annotation in the previous example:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003efor ind in pyslim.extract_individual_metadata(new_ts.tables):\n    print(ind.age)\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003eIn this example, all the ages are 0 (the default).\u003c/p\u003e\n\u003ch2 id=\"quickstart-modifying-slim-metadata\"\u003eQuickstart: modifying SLiM metadata\u003c/h2\u003e\n\u003cp\u003eTo \u003cem\u003emodify\u003c/em\u003e the metadata that \u003ccode\u003epyslim\u003c/code\u003e has introduced into a coalescent simulation, or the metadata in a SLiM-produced tree sequence, use the \u003ccode\u003eannotate_X_metadata()\u003c/code\u003e functions. For instance, to set the ages of the individuals in the tree sequence to random numbers between 1 and 4, and write out the resulting tree sequence:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eimport random\n\ntables = new_ts.dump_tables()\nind_md = list(pyslim.extract_individual_metadata(tables))\nfor ind in ind_md:\n    ind.age = random.choice([1,2,3,4])\n\npyslim.annotate_individual_metadata(tables, ind_md)\nmod_ts = pyslim.load_tables(tables, slim_format=True)\n\nfor ind in pyslim.extract_individual_metadata(mod_ts.tables):\n    print(ind.age)\n\nmod_ts.dump(\u0026quot;modified_ts.trees\u0026quot;)\u003c/code\u003e\u003c/pre\u003e\n\u003ch1 id=\"documentation\"\u003eDocumentation\u003c/h1\u003e\n\u003cp\u003eHere we describe the technical details. Currently, the python package \u003ccode\u003emsprime\u003c/code\u003e simulates tree sequences and provides tools to work with them. In the future, tools for working with tree sequences will be separated into a package called \u003ccode\u003etskit\u003c/code\u003e. \u003ccode\u003epyslim\u003c/code\u003e provides a thin interface between \u003ccode\u003emsprime/tskit\u003c/code\u003e.\u003c/p\u003e\n\u003ch2 id=\"metadata-entries\"\u003eMetadata entries\u003c/h2\u003e\n\u003cp\u003eSLiM records additional information in the metadata columns of Population, Individual, Node, and Mutation tables. The information is recorded in a binary format, and is extracted and written by \u003ccode\u003epyslim\u003c/code\u003e using the python \u003ccode\u003estruct\u003c/code\u003e module. Nothing besides this binary information can be stored in the metadata of these tables for the tree sequence to be used by SLiM, and so when \u003ccode\u003epyslim\u003c/code\u003e annotates an existing tree sequence, anything in those columns is overwritten. For more detailed documentation on the contents and format of the metadata, see the SLiM manual.\u003c/p\u003e\n\u003ch2 id=\"time-and-slim-tree-sequences\"\u003eTime and SLiM Tree Sequences\u003c/h2\u003e\n\u003cp\u003eThe “time” in a SLiM simulation is the number of generations since the beginning of the simulation. However, since tree sequences naturally deal with history retrospectively, properties related to “time” of tree sequences are measured in generations \u003cem\u003eago\u003c/em\u003e, i.e., generation \u003cem\u003eprior\u003c/em\u003e to a given point. To distinguish these two notions of time, we’ll talk about “SLiM time” and “tskit time”. When SLiM records a tree sequence, it records tskit time in units of generations before the start of the simulation, so all tskit times it records in the tree sequence are \u003cem\u003enegative\u003c/em\u003e (because it measures how long \u003cem\u003ebefore\u003c/em\u003e the start, but happened \u003cem\u003eafter\u003c/em\u003e the start). This is terribly counterintuitive. The fact that there are two notions of time - one moving forwards, the other backwards - is unavoidable, but \u003ccode\u003epyslim\u003c/code\u003e does one thing to make this easier to work with: when \u003ccode\u003epyslim\u003c/code\u003e loads in a tree sequence file, it checks to see what the current SLiM time was at the end of the simulation, and shifts all times in the tree sequence so that tskit time is measured in generations before the \u003cem\u003eend\u003c/em\u003e of the simulation.\u003c/p\u003e\n\u003cp\u003eThe upshot is that:\u003c/p\u003e\n\u003col type=\"1\"\u003e\n\u003cli\u003e\u003cp\u003eThe \u003ccode\u003etime\u003c/code\u003e attribute of tree sequence nodes gives the number of generations before the end of the simulation at which those nodes were born.\u003c/p\u003e\u003c/li\u003e\n\u003cli\u003e\u003cp\u003eThese numbers will \u003cem\u003enot\u003c/em\u003e match the values in the \u003ccode\u003e.trees\u003c/code\u003e file, but you should not need to worry about that, as long as you always \u003ccode\u003eload()\u003c/code\u003e and \u003ccode\u003edump()\u003c/code\u003e using \u003ccode\u003epyslim\u003c/code\u003e.\u003c/p\u003e\u003c/li\u003e\n\u003cli\u003e\u003cp\u003eThe conversion factor, the “SLiM time” that it was when the tree sequence file was written, is stored in an entry in the provenance table of the tree sequence; \u003ccode\u003epyslim\u003c/code\u003e extracts it from there to set the \u003ccode\u003eslim_generation\u003c/code\u003e attribute of a \u003ccode\u003eSlimTreeSequence\u003c/code\u003e.\u003c/p\u003e\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eAn example should help clarify things. Suppose that \u003ccode\u003emy.trees\u003c/code\u003e is a file that was saved by SLiM at the end of a simulation run for 100 generations, and that we want to find the list of nodes in the tree sequence that were born during the first 20 generations of the simulation. Since the birth time of a node is recorded in the \u003ccode\u003e.time\u003c/code\u003e attribute of a node in tskit time, a node that was born in the first 20 generations of the simulation, i.e., more than 80 generations before the end of the simulation, will have a \u003ccode\u003e.time\u003c/code\u003e attribute of at least 80.\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003ets = pyslim.load(\u0026quot;my.trees\u0026quot;, slim_format=True)\nold_nodes = []\nfor n in ts.nodes():\n   if n.time \u0026gt; ts.slim_generation - 20:\n        old_nodes.append(n)\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003eIn the future, we may change this behavior, but if so will provide an upgrade path for old files.\u003c/p\u003e\n\u003ch2 id=\"slim-tree-sequences\"\u003eSLiM Tree Sequences\u003c/h2\u003e\n\u003cp\u003eBecause SLiM adds additional information to tree sequences, \u003ccode\u003epyslim\u003c/code\u003e defines a subclass of \u003ccode\u003emsprime.TreeSequence\u003c/code\u003e to make it easy to access this information, and to make the time shift described above seamless. When you run \u003ccode\u003epyslim.load('my.trees', slim_format=True)\u003c/code\u003e, you get a \u003ccode\u003eSlimTreeSequence\u003c/code\u003e object. This has all the same properties and methods as a plain \u003ccode\u003eTreeSequence\u003c/code\u003e, with the following differences:\u003c/p\u003e\n\u003col type=\"1\"\u003e\n\u003cli\u003eIt has a \u003ccode\u003eslim_generation\u003c/code\u003e attribute.\u003c/li\u003e\n\u003cli\u003eIts \u003ccode\u003e.dump()\u003c/code\u003e method shifts times by \u003ccode\u003eslim_generation\u003c/code\u003e before writing them out, so that \u003ccode\u003epyslim.load(\u0026quot;my.trees\u0026quot;, slim_format=True).dump(\u0026quot;my2.trees\u0026quot;)\u003c/code\u003e writes out a tree sequence identical to the one that was read in (except for floating point error due to adding and subtracting this value from the times).\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"mutation-and-node-times\"\u003eMutation and node times\u003c/h2\u003e\n\u003cp\u003eBoth types of time - “SLiM time” and “tskit time” - appear in a SLiM tree sequence. The birth times of each individual are stored in the \u003ccode\u003e.time\u003c/code\u003e attribute of each of their nodes as tskit times, while the \u003ccode\u003eslim_time\u003c/code\u003e attributes of mutation metadata is in SLiM time.\u003c/p\u003e\n\u003cp\u003eHere is a very small example. Suppose that there are three haploid individuals: node 0 is born in the first generation, node 1 is born from node 0 in the third generation, and node 2 is born from node 1 in the fifth generation. (This is not possible in SLiM for a number of reasons, but ignore this.) Furthermore, suppose that two mutations have appeared: mutation 0 in generation 2 and mutation 1 in generation 3. The simulation is run for 5 generations, then written to a tree sequence. Here is a depiction of this:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eslim time   tskit time    nodes    mutation\n---------   ----------    -----    --------\n   1             4         0\n   2             3                    0\n   3             2         1          1\n   4             1\n   5             0         2\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003eHere “tskit time” refers to the number of generations before the end of the simulation.\u003c/p\u003e\n\u003cp\u003eIn this situation, the \u003ccode\u003etime\u003c/code\u003e attribute associated with each node would be that appearing in the “tskit time” column, while the \u003ccode\u003eslim_time\u003c/code\u003e attribute of mutation metadata would be that appearing in the “slim time” column. We could retrieve this information hypothetically as:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e\u0026gt;\u0026gt;\u0026gt; ts = pyslim.load(\u0026quot;my.trees\u0026quot;, slim_format=True)\n\u0026gt;\u0026gt;\u0026gt; for n in ts.nodes():\n\u0026gt;\u0026gt;\u0026gt;      print(n.time)\n[4, 2, 0]\n\u0026gt;\u0026gt;\u0026gt; for m in ts.mutations():\n\u0026gt;\u0026gt;\u0026gt;      md = pyslim.decode_mutation(m.metadata)\n\u0026gt;\u0026gt;\u0026gt;      print(md.slim_time)\n[2, 3]\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003eWe could then convert the node times to “slim time” as follows:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e\u0026gt;\u0026gt;\u0026gt; [ts.slim_generation - n.time for n in ts.nodes()]\n[1, 3, 5]\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003eAnd, we could convert the mutation times to “tskit time” as follows:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e\u0026gt;\u0026gt;\u0026gt; [ts.slim_generation - m.slim_time for m in pyslim.extract_mutation_metadata(ts.tables)]\n[3, 2]\u003c/code\u003e\u003c/pre\u003e\n\u003ch2 id=\"other-important-notes\"\u003eOther important notes:\u003c/h2\u003e\n\u003col type=\"1\"\u003e\n\u003cli\u003e\u003cp\u003e\u003ccode\u003etskit\u003c/code\u003e “nodes” correspond to SLiM “genomes”. Individuals in SLiM are diploid, so each has two nodes.\u003c/p\u003e\u003c/li\u003e\n\u003cli\u003e\u003cp\u003eThe currently alive individuals will be those in the Individual table; since in SLiM, all individual are diploid, every individual will be associated with two nodes, and all other nodes will \u003cem\u003enot\u003c/em\u003e have a corresponding individual.\u003c/p\u003e\u003c/li\u003e\n\u003cli\u003e\u003cp\u003eThe “remembered nodes” will be the \u003cem\u003efirst\u003c/em\u003e nodes.\u003c/p\u003e\u003c/li\u003e\n\u003c/ol\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftskit-dev%2Fpyslim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftskit-dev%2Fpyslim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftskit-dev%2Fpyslim/lists"}