def consensus_support_plot(consensus_data, ordered_genomes, biotypes, modes, title, tgt):
"""grouped violin plots of original intron / intron annotation / exon annotation support"""
def adjust_plot(g, this_title):
g.set_xticklabels(rotation=90)
g.fig.suptitle(this_title)
g.fig.subplots_adjust(top=0.9)
for ax in g.axes.flat:
ax.set_ylabel('Percent supported')
ax.set_ylim(-1, 101)
dfs = []
for i, mode in enumerate(modes):
df = json_to_df_with_biotype(consensus_data, mode)
if i > 0:
df = df[mode]
dfs.append(df)
df = pd.concat(dfs, axis=1)
df = pd.melt(df, value_vars=modes, id_vars=['genome', 'biotype'])
with tgt.open('w') as outf, PdfPages(outf) as pdf:
if len(ordered_genomes) > 1:
g = sns.factorplot(data=df, y='value', x='genome', col='variable', col_wrap=2, kind='violin', sharex=True,
sharey=True, row_order=ordered_genomes, cut=0)
else:
g = sns.factorplot(data=df, y='value', x='variable', kind='violin', sharex=True,
sharey=True, row_order=ordered_genomes, cut=0)
adjust_plot(g, title)
multipage_close(pdf, tight_layout=False)
title += ' for {}'
for biotype in biotypes:
this_title = title.format(biotype)
biotype_df = biotype_filter(df, biotype)
if biotype_df is not None:
if len(ordered_genomes) > 1:
g = sns.factorplot(data=biotype_df, y='value', x='genome', col='variable', col_wrap=2,
kind='violin', sharex=True, sharey=True, row_order=ordered_genomes, cut=0)
else:
g = sns.factorplot(data=df, y='value', x='variable', kind='violin', sharex=True,
sharey=True, row_order=ordered_genomes, cut=0)
adjust_plot(g, this_title)
multipage_close(pdf, tight_layout=False)
plots.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录