Skip to content

A tool for visualizing spatial models generated using the SLiM modeling framework

Notifications You must be signed in to change notification settings

samchamper/slim_vis

Repository files navigation

slim_vis

A simple python matplotlib script for visualizing and saving the output of a SLiM spatial simulation. For information on the SLiM modelling framework, see https://messerlab.org/slim/.

SLiM already has a visualization/GUI for use on Mac computers. However, for visualizing SLiM runs in a linux environment, when doing remote computation, or even just when it is desirable to export a visualization to a video, this tool may be useful.

This repository has a demo showing the kind of videos that this program creates. See: https://raw.githubusercontent.com/samchamper/slim_vis/master/pop_supression_example.mp4

Author:

Sam Champer

Requirements:

  • python3 (https://www.python.org/downloads/; make sure to "add python path" when you install it)
  • ffmpeg (ffmpeg.org; you will need to add ffmpeg to your path if you are on windows. See: https://www.wikihow.com/Install-FFmpeg-on-Windows)
  • pipenv (after installing python, run pip install pipenv)
  • The matplotlib library for python requires Tk for python. In linux with apt-get, install this by sudo apt-get install python3-tk

Installation and Usage:

  1. First, generate a file that this program can read. See: https://github.com/samchamper/slim_vis/blob/master/generating_slim_output.md.

  2. Place the generated movie file in the directory with this program.

  3. Run the following command to install python dependencies:

pipenv install --three

Then you can run the program via:

pipenv run vis
  • Optional command line arguments (don't actually include the "<>" brackets):
  1. -src <filename> to specify the source. Default slim_movie
  2. -fps <number> to specify the fps of the animation. Each frame is a generation, so this is also generations per second. Default 2.
  3. -s individual size. Increases for very small populations, decrease for large ones. Default 5.
  4. -dim The dimensions of the output. Default is 1080, resulting in a 1080*1080 animation.
  • For example:
pipenv run vis -src data_file.txt -fps 8 -s 2 -dim 1536
  • Alternate install flow: dependencies can also be installed using venv, though it's less cool. To do so, run make install and then to run the program, run make run.

Notes:

Adding the code to slim to export data to a file that can be read by this program greatly increases SLiM's runtime - by as much as a factor of 2. File I/O is slow.

Warning: It can take quite a long time to generate a movie for slim runs with many hundreds/thousands of generations!

The data files that the SLiM code outputs can be somewhat large: a SLiM run with 10k population and 100 generations can be close to 20 megabytes.

About

A tool for visualizing spatial models generated using the SLiM modeling framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published