def indel_plot(consensus_data, ordered_genomes, indel_plot_tgt):
with indel_plot_tgt.open('w') as outf, PdfPages(outf) as pdf:
tm_df = pd.concat([pd.DataFrame.from_dict(consensus_data[genome]['transMap Indels'], orient='index').T
for genome in ordered_genomes])
tm_df['genome'] = ordered_genomes
tm_df['transcript set'] = ['transMap'] * len(tm_df)
consensus_df = pd.concat([pd.DataFrame.from_dict(consensus_data[genome]['Consensus Indels'], orient='index').T
for genome in ordered_genomes])
consensus_df['genome'] = ordered_genomes
consensus_df['transcript set'] = ['Consensus'] * len(consensus_df)
df = pd.concat([consensus_df, tm_df])
df = pd.melt(df, id_vars=['genome', 'transcript set'],
value_vars=['CodingDeletion', 'CodingInsertion', 'CodingMult3Indel'])
df.columns = ['Genome', 'Transcript set', 'Type', 'Percent of transcripts']
g = sns.factorplot(data=df, x='Genome', y='Percent of transcripts', col='Transcript set',
hue='Type', kind='bar', row_order=ordered_genomes,
col_order=['transMap', 'Consensus'])
g.set_xticklabels(rotation=90)
g.fig.subplots_adjust(top=.8)
g.fig.suptitle('Coding indels')
multipage_close(pdf, tight_layout=False)
###
# shared plotting functions
###
plots.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录