Skip to main content
Top

2019 | Book

Python for the Life Sciences

A Gentle Introduction to Python for Life Scientists

insite
SEARCH

About this book

Treat yourself to a lively, intuitive, and easy-to-follow introduction to computer programming in Python. The book was written specifically for biologists with little or no prior experience of writing code - with the goal of giving them not only a foundation in Python programming, but also the confidence and inspiration to start using Python in their own research.

Virtually all of the examples in the book are drawn from across a wide spectrum of life science research, from simple biochemical calculations and sequence analysis, to modeling the dynamic interactions of genes and proteins in cells, or the drift of genes in an evolving population.

Best of all, Python for the Life Sciences shows you how to implement all of these projects in Python, one of the most popular programming languages for scientific computing. If you are a life scientist interested in learning Python to jump-start your research, this is the book for you.

What You'll Learn

Write Python scripts to automate your lab calculations

Search for important motifs in genome sequences

Use object-oriented programming with Python

Study mining interaction network data for patterns

Review dynamic modeling of biochemical switches

Who This Book Is For

Life scientists with little or no programming experience, including undergraduate and graduate students, postdoctoral researchers in academia and industry, medical professionals, and teachers/lecturers.

“A comprehensive introduction to using Python for computational biology... A lovely book with humor and perspective”

-- John Novembre, Associate Professor of Human Genetics, University of Chicago and MacArthur Fellow

“Fun, entertaining, witty and darn useful. A magical portal to the big data revolution” -- Sandro Santagata, Assistant Professor in Pathology, Harvard Medical School

“Alex and Gordon’s enthusiasm for Python is contagious”

-- Glenys Thomson Professor of Integrative Biology, University of California, Berkeley

Table of Contents

Frontmatter
Chapter 1. Getting Started with Python
Setting Yourself Up to Use Python
Abstract
Getting Python on your computer is obviously the first step for the reader of this book, in order to be able to run your Python code. In this chapter we’ll talk about what tools you might want to use to edit and manage your Python code, after we’ve dealt with the primary issue of actually getting a Python distribution on your computer.
Alexander Lancaster, Gordon Webster
Chapter 2. Python at the Lab Bench
The Fundamentals of the Python Language
Abstract
Python is definitely your friend in the lab, so in this chapter we start off with that simple, daily lab stuff for which you would once have whipped out your electronic calculator with its tiny buttons seemingly designed for the fingers of children too young to even care about arithmetic. These days, it’s more likely to be your smartphone you reach for, but you can put that away as well (that paused game of Clash Of Empires III will still be there at your next coffee break).
Alexander Lancaster, Gordon Webster
Chapter 3. Making Sense of Sequences
Biological Sequences and Python Data Structures
Abstract
Sequences are a key part of biology, and in this chapter, we introduce the Python features that make it a wonderful tool for storing, searching, and analyzing protein and nucleic sequences. If Python’s facility for handling sequences was its only appeal to life scientists, that alone would make it worthy of its place in the biologist’s toolbox.
Alexander Lancaster, Gordon Webster
Chapter 4. A Statistical Interlude
Of Bayes’ Theorem and Biomarkers
Abstract
In this chapter we introduce Bayes' theorem, an important mathematical formalization for weighing scientific evidence in life sciences and beyond, and use it to demonstrate Python's mathematical functions. 
Alexander Lancaster, Gordon Webster
Chapter 5. Opening Doors to Your Data
Reading, Parsing, and Handling Biological Data Files
Abstract
So you’ve been enjoying writing your loops, creating variables and all kinds of other programming delights. But now let’s imagine that you now want to start really crunching a lot of data. This chapter is all about pulling biological data from external files, where most of that data will most likely “live.”
Alexander Lancaster, Gordon Webster
Chapter 6. Finding Needles in Haystacks
Regular Expressions for Genomics and Sequencing
Abstract
In this chapter we introduce regular expressions, one of the most powerful text-handling features of Python and show how we use it to analyze and process genomics and next-generation sequencing data.
Alexander Lancaster, Gordon Webster
Chapter 7. Object Lessons
Biological Sequences as Python Objects
Abstract
In this chapter, we provide a very concise introduction to object-oriented programming (OOP), a programming idiom that you’re probably going to want to learn if you ever need to write more than relatively simple scripts with Python. OOP is a way to organize your code that done right will generally make it cleaner, easier to understand, easier to maintain, and more reusable.
Alexander Lancaster, Gordon Webster
Chapter 8. Slicing and Dicing Genomes
Next-Generation Sequencing Pipelines
Abstract
In this chapter we’ll take you into the world of deep sequencing, sometimes called next-generation sequencing (NGS) or short-read sequencing. Most working biologists have probably heard about this technology, and you may be keen to get your hands on this kind of data to ask your own questions, but you may also be daunted by the intimidating terminology and word salad of tools and acronyms involved – BWA, NGS, VCF – and the equally intimidating list of technologies – Illumina, pyrosequencing, SOLiD, and so on. Never fear, we’re here to help.
Alexander Lancaster, Gordon Webster
Chapter 9. The Wells! The Wells!
Microtiter Plate Assays I: Data Structures
Abstract
What book aimed at the modern life scientist could avoid mention of that trusty workhorse of biology labs everywhere – the 96-well plate? This is the first of two chapters on the humble 96-well plate which demonstrate some of the ways that we can use Python to work with and visualize plate data and also to show how it can be used to create software that can interface with laboratory automation systems.
Alexander Lancaster, Gordon Webster
Chapter 10. Well on the Way
Microtiter Plate Assays II: Automation and Visualization
Abstract
In the previous chapter we looked at handling the plate as a virtual object, in this chapter we look at handling plates as a physical (and visual) object. Laboratory plate assays are a popular target for anyone looking to create a high-throughput pipeline using lab automation and robotics, and there are already a wealth of laboratory instruments and robots that can automatically set up experiments in multi-well plates, monitor them, and read data from them.
Alexander Lancaster, Gordon Webster
Chapter 11. Molecules in 3D
Mathematics and Linear Algebra for Structural Biology
Abstract
One of the great ironies of modern biology is that it has become more and more a study of the “dead stuff” from which biological systems are built. This chapter is all about that “dead stuff.” In this chapter we show you how to work at the atomic level and rotate a molecular bond in three-dimensions.
Alexander Lancaster, Gordon Webster
Chapter 12. Turning Genes On and Off
Visualizing Biochemical Kinetics using Matplotlib
Abstract
In Chapter 11 we explored the world of three-dimensional structural biology using Python. In this chapter we move up the rungs of complexity away from almost pure physics and chemistry toward things that are more recognizably biological. In this chapter we’ll show you how to use some more advanced Python matplotlib functions to help you visualize the relationship between the concentration of a transcription factor protein and its primary biological function in the cell: the initiation of transcription from DNA to messenger RNA, that is, turning the gene on or off.
Alexander Lancaster, Gordon Webster
Chapter 13. Taming the Network Hairball
Using Python Sets to Mine Systems Biology Data
Abstract
In this chapter, we’ll be using skills such as parsing data files, data structures, and regular expressions that we’ve developed in previous chapters to analyze interaction networks using real-world data taken from yeast.
Alexander Lancaster, Gordon Webster
Chapter 14. Genetic Feedback Loops
Modeling Gene Networks with the Gillespie Algorithm
Abstract
 In this chapter we introduce of the most well-used techniques for the stochastic simulation of biochemical networks, the Gillespiealgorithm, and build a model of genetic feedback loops in Python, and use matplotlib to visualize the results.
Alexander Lancaster, Gordon Webster
Chapter 15. Growing a Virtual Garden
Modeling Plant Development with L-Systems
Abstract
Python is an excellent platform to explore the nature of biological development via the generative power of simple rules or behavior. In this chapter we show you how to implement an L-system, an example of this kind of generative model, by using Python turtle graphics to grow a virtual plant.
Alexander Lancaster, Gordon Webster
Chapter 16. How the Leopard Got its Spots
Cellular Automata Models of Turing Patterns
Abstract
The quantitative study of organismal development has a long history. L-systems, which we saw in the previous chapter, date back to the late 1960s, but the history extends much further than that. D’Arcy Thompson wrote his classic On Growth and Form in 1917 well predating the discovery of the double-helix structure of DNA in 1953. . In this chapter we introduce Alan Turing's model of global multicellular patterns, and show you how to implement a cellular automata to simulate the development of animal coat patterns.
Alexander Lancaster, Gordon Webster
Chapter 17. Foxes Guarding Henhouses
Ecological Modeling with Predator-Prey Dynamics
Abstract
The next level “up” from the individual organism is the ecosystem: organisms interacting with each other and their environment. .A staple of ecological models is the “predator-prey” model: a single species of predator and a single species of prey. In this chapter, we show you how to use Python to model and visualize population dynamics with an elegant sufficiency of code.
Alexander Lancaster, Gordon Webster
Chapter 18. A Virtual Flu Epidemic
Exploring Epidemiology with Agent-Based Models
Abstract
In this chapter we will introduce the SIR model, which stands for susceptible–infectious–recovered, a basic conceptual model in the fields of epidemiology, public health, and virology, among others. It will also allow us to introduce the idea of an agent-based model or ABM in which individual entities have their own unique identity within the model. .
Alexander Lancaster, Gordon Webster
Chapter 19. Retracing Life’s Footsteps
Evolutionary Dynamics with the Wright-Fisher Model
Abstract
In this final chapter we move our Python lens from modeling ecological dynamics to modeling evolution. In this chapter we show you how to implement the Wright-Fisher model from population genetics in Python and use it to model evolutionary change.​
Alexander Lancaster, Gordon Webster
Backmatter
Metadata
Title
Python for the Life Sciences
Authors
Alexander Lancaster
Gordon Webster
Copyright Year
2019
Publisher
Apress
Electronic ISBN
978-1-4842-4523-1
Print ISBN
978-1-4842-4522-4
DOI
https://doi.org/10.1007/978-1-4842-4523-1

Premium Partner