Book Image

Bioinformatics with Python Cookbook

By : Tiago R Antao, Tiago Antao
Book Image

Bioinformatics with Python Cookbook

By: Tiago R Antao, Tiago Antao

Overview of this book

Table of Contents (16 chapters)
Bioinformatics with Python Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Simulating population structure using island and stepping-stone models


We will now simulate population structure. Let's start with an island model and then create a one-dimensional stepping-stone model. We will also study FST and distinguish between deme-level statistics and meta-population level statistics. Strictly speaking, we will simulate fragmentation models by splitting into islands or stepping-stones.

Getting ready

Read the first recipe (Introducing forward-time simulations) as it introduces the basic programming framework. If you are using notebooks, the content is in 04_PopSim/Pop_Structure.ipynb.

How to do it…

Take a look at the following steps:

  1. Let's start with some basic code from the first recipe:

    from __future__ import division
    from collections import defaultdict, OrderedDict
    from copy import deepcopy
    import simuPOP as sp
    from simuPOP import demography
    num_loci = 10
    pop_size = 50
    num_gens = 101
    num_pops = 10
    migs = [0, 0.005, 0.01, 0.02, 0.05, 0.1]
    init_ops = OrderedDict()
    pre_ops...