Skip to content

Commit

Permalink
some minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur ZWAENEPOEL committed Sep 4, 2018
1 parent 0716b66 commit fdc7a1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
11 changes: 7 additions & 4 deletions wgd/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def inspect_bic(bic):
]
logging.info("")
logging.info("Delta BIC assessment: ")
logging.info("min(BIC) = {:.2f}".format(bic[im]))
logging.info("min(BIC) = {:.2f} for model {}".format(bic[im], im+1))
for i, bic_i in enumerate(bic):
dbic = bic_i - bic[im]
j = 0
Expand Down Expand Up @@ -322,7 +322,7 @@ def plot_probs(m, ax, l=0.0, u=5, ylab=True):
return ax


def plot_aic_bic(aic, bic, out_file):
def plot_aic_bic(aic, bic, min_n, max_n, out_file):
"""
Plot AIC and BIC curves
Expand All @@ -331,17 +331,20 @@ def plot_aic_bic(aic, bic, out_file):
:param out_file: output file
:return: nada
"""
x_range = list(range(min_n, max_n+1))
fig, axes = plt.subplots(1, 2, figsize=(12, 3))
axes[0].plot(np.arange(1,len(aic)+1), aic, color='k', marker='o')
axes[0].set_xticks(list(range(1,len(aic)+1)))
axes[0].set_xticklabels(x_range)
axes[0].grid(ls=":")
axes[0].set_ylabel("AIC")
axes[0].set_xlabel("model")
axes[0].set_xlabel("# components")
axes[1].plot(np.arange(1, len(bic) + 1), bic, color='k', marker='o')
axes[1].set_xticks(list(range(1, len(bic) + 1)))
axes[1].set_xticklabels(x_range)
axes[1].grid(ls=":")
axes[1].set_ylabel("BIC")
axes[1].set_xlabel("model")
axes[1].set_xlabel("# components")
fig.tight_layout()
fig.savefig(out_file)

Expand Down
25 changes: 10 additions & 15 deletions wgd_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,37 +682,31 @@ def ksd_(

# CO-LINEARITY -----------------------------------------------------------------
@cli.command(context_settings={'help_option_names': ['-h', '--help']})
@click.argument('gff_file', default=None, type=click.Path(exists=True))
@click.argument('gene_families', default=None, type=click.Path(exists=True))
@click.option(
'--gff_file', '-gff', default=None, type=click.Path(exists=True),
help='annotation in gff3 format'
)
@click.option(
'--gene_families', '-gf', default=None, type=click.Path(exists=True),
help='gene families'
'--ks_distribution', '-ks', default=None,
help="paranome ks distribution tsv file (optional, see `wgd ks`)"
)
@click.option(
'--output_dir', '-o', default='./wgd_syn', show_default=True,
help='output directory'
)
@click.option(
'--ks_distribution', '-ks', default=None,
help="paranome ks distribution tsv file (optional, see `wgd ks`)"
)
@click.option(
'--feature', '-f', default='mRNA', show_default=True,
help="keyword for parsing the genes from the GFF file (column 3)"
)
@click.option(
'--gene_attribute', '-ga', default='Parent', show_default=True,
'--gene_attribute', '-a', default='Parent', show_default=True,
help="keyword for parsing the gene IDs from the GFF file (column 9)"
)
@click.option(
'--min_length', '-ml', default=250, show_default=True,
'--min_length', '-l', default=250, show_default=True,
help="minimum length of a genomic element (in numbers of genes) to be "
"included in dotplot."
)
def syn(
gff_file, gene_families, output_dir, ks_distribution, feature,
gff_file, gene_families, ks_distribution, output_dir, feature,
gene_attribute, min_length
):
"""
Expand Down Expand Up @@ -1012,10 +1006,11 @@ def mix_(
inspect_aic(aic)
inspect_bic(bic)
logging.info("Plotting AIC & BIC")
plot_aic_bic(aic, bic, os.path.join(output_dir, "aic_bic.pdf"))
plot_aic_bic(aic, bic, components[0], components[1],
os.path.join(output_dir, "aic_bic.pdf"))
logging.info("Plotting mixtures")
plot_all_models_gmm(models, X, ks_range[0], ks_range[1], bins=bins,
out_file=os.path.join(output_dir, "gmms.pdf"))
out_file=os.path.join(output_dir, "gmms.pdf"))

# BGMM method
else:
Expand Down

0 comments on commit fdc7a1c

Please sign in to comment.