Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_data(gene_intron, cid, **_):
- from ..fetch_data import get_intron_events, get_chromossome, get_kinship
- from ..fetch_data import get_positions
- gene, intron = gene_intron.split('_')
- intron = int(intron)
- pos = get_positions()
- pos = pos.query("(gene == '%s') & (intron == %d)" % (gene, intron))
- start_pos, end_pos = pos['start_pos'].values[0], pos['end_pos'].values[0]
- df = get_intron_events()
- df = df.loc[(gene, intron)]
- df['iid'] = df['assay'].apply(lambda x: x.split('_')[0].split('.')[0])
- K = get_kinship()
- ws = 5000
- (bim, fam, G) = get_chromossome(cid)
- query = "(chrom == '%d') & (pos >= %d) & (pos <= %d)" % (cid, start_pos-ws, end_pos+ws)
- bim = bim.query(query).sort_index(level=[1])
- snp_idx = bim['i'].values
- snp_ids = bim['snp'].values
- G = G[:,snp_idx]
- data = dict(ntri=[], nsuc=[], idx=[], snp_id=snp_ids)
- for r in df.iterrows():
- data['nsuc'].append(r[1][1])
- data['ntri'].append(r[1][2])
- q = "iid == '%s'" % r[1][3]
- data['idx'].append(fam.query(q)['i'].values[0])
- G = G[data['idx'],:]
- K = K[data['idx'],:][:,data['idx']]
- data['K'] = K
- data['G'] = G
- data['gene'] = gene
- data['intron'] = intron
- return data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement