Skip to main content
# pySLiM

SLiM can now read, and write tree sequences, which store genealogical data of populations.
SLiM can use a tree sequence produced by the coalescent simulator `msprime` 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.

## Installation

To install `pyslim`, do
```
git clone https://github.com/tskit-dev/pyslim.git
cd pyslim
python setup.py install --user
```
You'll also need an up-to-date [msprime](https://github.com/tskit-dev/msprime) and [SLiM](https://messerlab.org/slim/), of course.

To run the tests to make sure everything is working, do:
```
cd tests/examples
for x in *.slim; do slim $x; done
cd -
python -m nose tests
```

*Note:* if you use `python3` you may need to replace `python` with `python3` above.


## Quickstart: coalescent simulation for SLiM

The `pyslim.annotate()` 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 `.trees` file:
```
import msprime
import pyslim

# simulate a tree sequence of 12 nodes
ts = msprime.simulate(12, mutation_rate=1.0, recombination_rate=1.0)
new_ts = pyslim.annotate_defaults(ts)
new_ts.dump("slim_ts.trees")
```

## Quickstart: reading SLiM metadata

To retrieve the extra information that SLiM stores in a tree sequence, use the `extract_X_metadata()`
functions. For instance, to see the age of each Individual produced by annotation
in the previous example:
```
for ind in extract_mutation_metadata(new_ts.tables):
print(ind.age)
```


## Important notes:

1. `tskit` "nodes" correspond to SLiM "genomes". Individuals are diploid, so each individual has two nodes.

2. The currently alive individuals will be those in the Individual table; all other nodes will *not*
have a corresponding individual.

3. The "remembered nodes" will be the *first* nodes.


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyslim-0.0.51-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file pyslim-0.0.51-py3-none-any.whl.

File metadata

File hashes

Hashes for pyslim-0.0.51-py3-none-any.whl
Algorithm Hash digest
SHA256 0fa790e435822971882a4568456284c4397dd8ef94db8269d1ed5ce593714f9a
MD5 22b69d8bf69365293ba33d358ee76ec3
BLAKE2b-256 408f90f5451f185d7bcf59cb50b5f76090f726888a5c4b39b8a87934780cf7dd

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.1

2 files

1.1.0

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0

2 files

0.700

2 files

0.600

2 files

0.501

2 files

0.500

2 files

0.403

2 files

0.402

2 files

0.401

2 files

0.400

2 files

0.314

2 files

0.312

3 files

0.311

2 files

0.32

3 files

0.31

2 files

0.3

2 files

0.1

3 files

0.0.54

2 files

This release

0.0.51 This release

1 file

0.0.6

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page