Package: pycoalescence
A package for coalescence-based spatially explicit neutral ecology simulationsIntroductionpycoalescence is a Python package for spatially explicit coalescence neutral simulations. pycoalescence provides a
pythonic interface for setting up, running and analysing spatially explicit neutral simulations. Simulations themselves
are performed in C++ usingnecsimfor
excellent performance, whilst the Python interface provides a simple solution for setting up and analysing simulations.For full documentation please seehere.For R users, there is a sister package with (mostly) equivalent functionality, which can be foundhere.InstallationUsage of conda is recommended to aid handling installation of dependencies.Installation is available through pip, conda or a manual installation. For full installation instructions, seehere.Currently, pip is supported on Mac OS X and Linux and conda is supported on Mac OS X, Linux and Windows.Using pip, make sure all the prerequisites are installed and runpip install pycoalescence.If you cannot install via pip, download the tar ball and runpython setup.py install. The package can also be
installed locally, (i.e not to the virtual or system environment) usingpython installer.pyin the module directory.
Either method requires all dependencies have been installed. By default, .o files are compiled to lib/obj and the .so
or .dylib file is compiled to the necsim directory.Make sure compilation is performed under the same Python version simulations will be performed in.RequirementsEssentialPython version 2 >= 2.7.9 or 3 >= 3.6.1 (although earlier versions may work)C++ compiler (such as GNU g++) with C++14 support.The SQLite library availablehere(comes included with Python). Requires
both C++ and Python installations.The Boost library for C++ availablehere.Numerical Python (numpy) package (pip install numpy).The gdal library for both Python and C++ (available here) including development options.
Both the Python package and C++ binaries are required; installation differs between systems, so view the gdal
documentation for more help installing gdal properly.Theproj libraryfor converting between coordinate systems.RecommendedScipy package for generating fragmented landscapes
(pip install scipy).Matplotlib package for plotting fragmented landscapes
(pip install matplotlib).OptionalFor work involving large csv files, the fast-cpp-csv-parser by Ben Strasser, availableherecan be used. This provides much faster csv read and
write capabilities and is probably essential for larger-scale simulations, but not necessary if your simulations are
small or you are intending to use.tiffiles (the recommended method). The folderfast-cpp-csv-parser/should be in the same directory as yournecsimC++ header files (the lib/necsim directory)
and requires manual installation.Notefast-cpp-csv-parser is no longer tested with updated versions of that package, but should still be functional.Basic UsageThe Simulation class contains most of the operations required for
setting up a coalescence simulation. The important set up functions are:set_simulation_parameters()sets a variety of key simulation
variables, including the seed, output directory, dispersal parameters
and speciation rate.set_map()is used to specify a map file to use. More complex map
file set-ups can be provided usingset_map_files()can also be
used to customise parameters, instead of detecting from the provided
tif files.set_speciation_rates()takes a list of speciation rates to apply
at the end of the simulation. This is optional.run()checks and starts the simulation, writing to the output
database upon successful completion. This stage can take an extremely
long time (up to tens of hours) depending on the size of the
simulation and the dispersal variables. Upon completion, an SQL file
will have been created containing the coalescence tree.The CoalescenceTree class also contains some basic analysis abilities,
such as applying additional speciation rates post-simulation, or
calculating species abundances for fragments within the main simulation.The basic procedure for this procedure isset_database()to provide the path to the completed simulation
databaseset_speciation_parameters()which takes as argumentslist of speciation rates to applyT/F of recording full spatial dataeither a csv file containing fragment data, or T/F for whether
fragments should be calculated from squares of continuous habitat.[optional] a sample file to specify certain cells to sample from[optional] a config file containing the temporal sampling points
desired.apply()performs the analysis. This can be extremely RAM and
time-intensive for large simulations. The calculations will be stored
in extra tables within the same SQL file as originally specified.get_species_richness()or other equivalent functions to obtain the
required metrics of biodiversity.ContactsAuthor: Samuel ThompsonContact:samuel.thompson14@imperial.ac.uk-thompsonsed@gmail.comInstitution: Imperial College London and National University of
SingaporeThis project is released under MIT licence. See fileLICENSE.txtor
go toherefor full license
details.