How to use the pyani.pyani_graphics.Params function in pyani

To help you get started, we’ve selected a few pyani examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github widdowquinn / pyani / tests / test_graphics.py View on Github external
def draw_format_method(fmt, mth, graphics_inputs, tmp_path):
    """Render graphics format and method output."""
    df = pd.read_csv(graphics_inputs.filename, index_col=0, sep="\t")
    fn = {"mpl": pyani_graphics.mpl.heatmap, "seaborn": pyani_graphics.sns.heatmap}
    params = {"mpl": pyani_config.params_mpl, "seaborn": pyani_config.params_mpl}
    method_params = pyani_graphics.Params(
        params[mth](df)["ANIm_percentage_identity"],
        graphics_inputs.labels,
        graphics_inputs.classes,
    )
    fn[mth](
        df, tmp_path / f"{mth}.{fmt}", title=f"{mth}:{fmt} test", params=method_params
    )
github widdowquinn / pyani / pyani / scripts / subcommands.py View on Github external
# Parse output formats
        outfmts = args.formats.split(',')
        logger.info("Requested output formats: %s", outfmts)

        # Generate filestems
        for matname in ['identity', 'coverage', 'aln_lengths', 'sim_errors',
                        'hadamard']:
            df = getattr(results, matname)           # results matrix
            cmap = pyani_config.get_colormap(df, matname)
            for fmt in outfmts:
                outfname = os.path.join(args.outdir,
                                        "matrix_{0}_{1}.{2}".format(matname,
                                                                    run_id,
                                                                    fmt))
                logger.info("Writing graphics to %s", outfname)
                params = pyani_graphics.Params(cmap, results.labels,
                                               results.classes)
                # Draw figure
                gmethod[args.method](df, outfname,
                                     title="matrix_{0}_{1}".format(matname,
                                                                   run_id),
                                     params=params)
github widdowquinn / pyani / pyani / scripts / average_nucleotide_identity.py View on Github external
"""Draw ANIb/ANIm/TETRA results.

    :param args:  Namespace, command-line arguments
    :param logger: logging object
    :param filestems: - filestems for output files
    :param gformat: - the format for output graphics
    """
    # Draw heatmaps
    for filestem in filestems:
        fullstem = args.outdirname / filestem
        outfilename = fullstem.with_suffix(".%s" % gformat)
        infilename = fullstem.with_suffix(".tab")
        dfm = pd.read_csv(infilename, index_col=0, sep="\t")
        logger.info("Writing heatmap to %s", outfilename)
        print(args.labels, args.classes)
        params = pyani_graphics.Params(
            params_mpl(dfm)[filestem],
            pyani_tools.get_labels(args.labels, logger=logger),
            pyani_tools.get_labels(args.classes, logger=logger),
        )
        if args.gmethod == "mpl":
            pyani_graphics.mpl.heatmap(
                dfm, outfilename=outfilename, title=filestem, params=params
            )
        elif args.gmethod == "seaborn":
            pyani_graphics.sns.heatmap(
                dfm, outfilename=outfilename, title=filestem, params=params
            )
github widdowquinn / pyani / pyani / scripts / subcommands / subcmd_plot.py View on Github external
:param run_id:  int, run_id for this run
    :param matdata:  MatrixData object for this heatmap
    :param result_labels:  dict of result labels
    :param result_classes: dict of result classes
    :param args:  Namespace for command-line arguments
    :param outfmts:  list of output formats for files
    """
    logger = logging.getLogger(__name__)

    logger.info("Writing %s matrix heatmaps", matdata.name)
    cmap = pyani_config.get_colormap(matdata.data, matdata.name)
    for fmt in outfmts:
        outfname = Path(args.outdir) / f"matrix_{matdata.name}_run{run_id}.{fmt}"
        logger.debug("\tWriting graphics to %s", outfname)
        params = pyani_graphics.Params(cmap, result_labels, result_classes)
        # Draw heatmap
        GMETHODS[args.method](
            matdata.data,
            outfname,
            title=f"matrix_{matdata.name}_run{run_id}",
            params=params,
        )

    # Be tidy with matplotlib caches
    plt.close("all")