Skip to Content
Bioinformatics with Python Cookbook - Second Edition
book

Bioinformatics with Python Cookbook - Second Edition

by Tiago Antao
November 2018
Intermediate to advanced
360 pages
9h 36m
English
Packt Publishing
Content preview from Bioinformatics with Python Cookbook - Second Edition

How to do it…

  1. We will need a few imports:
import randomimport matplotlib.pyplot as plt%matplotlib inline
  1. Before we do any empirical analysis, let's try to understand what information we can extract from the case where the mother is AA and the father is AT. Let's answer the question, "If we have 20 offspring, what is the probability of all of them being heterozygous?":
num_sims = 100000num_ofs = 20num_hets_AA_AT = []for sim in range(num_sims):    sim_hets = 0    for ofs in range(20):        sim_hets += 1 if random.choice([0, 1]) == 1 else 0    num_hets_AA_AT.append(sim_hets)    fig, ax = plt.subplots(1,1, figsize=(16,9))ax.hist(num_hets_AA_AT, bins=range(20))print(len([num_hets for num_hets in num_hets_AA_AT if num_hets==20]))

We get the following output: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Bioinformatics with Python Cookbook

Bioinformatics with Python Cookbook

Tiago Antao

Publisher Resources

ISBN: 9781789344691Supplemental Content