Population Genomics in Practice 2025
  • Slides
  • Exercises
  • Code recipes
  1. Exercises
  2. Simulation
  3. HOWTO
  • Slides
    • Listing
    • Introduction
      • Population genomics in practice
    • Population genetics foundations
      • Listing
      • Data and definitions
      • Alleles and genealogies
      • Linkage disequilibrium
      • The Wright-Fisher model
      • Genetic diversity
      • Selection
    • Variant calling
      • Listing
      • DNA sequencing data
      • Read mapping
      • Variant calling and genotyping
      • Variant calling workflows
    • Variant filtering
      • Listing
      • Variant filtering
      • Depth filtering
    • Genetic diversity
      • Listing
      • Genetic diversity
    • Population structure
      • Listing
      • Principal component analysis
      • Admixture
    • Demography
      • Listing
    • Selection
      • Listing
    • Simulation
      • Listing
      • Brief introduction to simulation packages and stdpopsim
      • Primer on the coalescent and forward simulation
      • Ancestral recombination graph inference
  • Exercises
    • Listing
    • Data
      • Compute environment
      • Monkeyflowers dataset
    • Variant calling
      • Listing
      • Variant calling introduction
      • Data quality control
      • Read mapping and duplicate removal
      • Variant calling workflow
    • Variant filtering
      • Listing
      • Basic variant filtering
      • Depth filtering on invariant sites
    • Recombination and linkage
      • Listing
      • Linkage disequilibrium decay
    • Genetic diversity
      • Listing
      • Genetic diversity landscapes
    • Population structure
      • Listing
      • Principal component analysis
      • Admixture
      • D-statistics
    • Simulation
      • Listing
      • HOWTO
      • Introduction to stdpopsim
      • Simulating selection with stdpopsim
      • Introduction to simulation with msprime
  • Code recipes
    • Code recipes

On this page

  • About
    • Setup
    • Workbook initialization
    • Notebook contents
  1. Exercises
  2. Simulation
  3. HOWTO

HOWTO

Start here: introduction to notebook setup.
Author

Per Unneberg

Published

18-Sep-2025

About

This document describes the intended use of the Jupyter notebooks (we will also call them workbooks) that we will be using during the exercises. Common to all workbooks is that you will need to initialize them by executing code before proceeding with the actual exercises. Cells are executed by selecting Run->“Run selected cell” or by pressing the triangular “play” button in the menubar. A shortcut for either of these is to press keys <shift>+<return>.

Setup

Provided that you have setup / activated the proper virtual environment, all you need to do is get a copy of the notebook along with the workshop module file and the quiz.yaml file. In some cases you will also be provided with datasets to work on.

Workbook initialization

Common to all workbooks is that you will need to initialize them by executing code before proceeding with the actual exercises. A code block like the following one will be present at the top of a workbook; make sure to execute it with <shift>+<return>. For the cell below, this should print “Your notebook is ready to go!”.

import workshop  # If running locally, make sure that
workbook = workshop.HOWTO()
display(workbook.setup)
✅ Your notebook is ready to go!

Notebook contents

The notebooks consist of cells that are either descriptive text written in markdown format, or code blocks consisting of Python code. Importantly, the code blocks can usually be executed via the keyboard shortcut <shift>+<return>. The Python code blocks can be edited so you can try out different parameter settings, or even modify code. This will be necessary to complete some of the excercises that are scattered throughout the documents and formatted like this:

Exercise 1
Read through this document before proceeding with the notebooks

Some exercises also have associated questions to test your understanding. They consist of code blocks that have to be executed.

There are two types of questions: multiple choice and value input. The options to multiple choice questions are displayed as buttons below the question:

# Execute code block with <shift>+Return to display question; press on
# one of the buttons to answer
workbook.question("distro")

For value input questions, each question is accompanied by a box. Enter a numeric value in the box and press return to check the answer:

# Execute this cell to see the question: enter a value in the box and
# press return to check the answer
workbook.question("day")

2025 NBIS | GPL-3 License

 

Published with Quarto v