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...

Take a look at the following steps:

  1. Let's load the metadata (we will use a simplified version from the previous recipe) as follows:
from collections import defaultdictf = open('relationships_w_pops_121708.txt')pop_ind = defaultdict(list)f.readline() # headerfor line in f:    toks = line.rstrip().split('\t')    fam_id = toks[0]    ind_id = toks[1]    pop = toks[-1]    pop_ind[pop].append((fam_id, ind_id))f.close()
  1. Let's check for consistency between the PLINK data file and the metadata, as we will need to clean up population mappings to generate a Genepop file, as shown in the following code:
all_inds = []for inds in pop_ind.values():    all_inds.extend(inds)for line in open('hapmap1.ped'): toks = line.rstrip().replace(' ', '\t').split('\t') ...
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