def plot_cm(ecs, output_file=None):
        """
        Simple wrapper for contact map plotting
        """
        with misc.plot_context("Arial"):
            fig = plt.figure(figsize=(8, 8))
            if kwargs["scale_sizes"]:
                ecs = ecs.copy()
                ecs.loc[:, "size"] = ecs.cn.values / ecs.cn.max()

            pairs.plot_contact_map(
                ecs,
                d_intra,
                d_multimer,
                distance_cutoff=kwargs["distance_cutoff"],
                show_secstruct=kwargs["draw_secondary_structure"],
                margin=5,
                boundaries=kwargs["boundaries"])

            plt.suptitle("{} evolutionary couplings".format(len(ecs)),
                         fontsize=14)

            if output_file is not None:
                plt.savefig(output_file, bbox_inches="tight")
                plt.close(fig)
Exemple #2
0
    def plot_cm(ecs, output_file=None):
        """
        Simple wrapper for contact map plotting
        """
        with misc.plot_context("Arial"):
            fig = plt.figure(figsize=(10, 10))
            if kwargs["scale_sizes"]:
                ecs = ecs.copy()
                ecs.loc[:, "size"] = ecs.score.values / ecs.score.max()
                # avoid negative sizes
                ecs.loc[ecs["size"] < 0, "size"] = 0

            # draw PDB structure and alignment/EC coverage information on contact map if selected
            # (for now, not a required parameter, default to True)
            if kwargs.get("draw_coverage", True):
                additional_plot_kwargs = {
                    "show_structure_coverage": True,
                    "margin": 0,
                    "ec_coverage": ec_table,
                }
            else:
                additional_plot_kwargs = {
                    "show_structure_coverage": False,
                    "margin": 5,
                    "ec_coverage": None,
                }

            pairs.plot_contact_map(
                ecs,
                d_intra,
                d_multimer,
                distance_cutoff=kwargs["distance_cutoff"],
                show_secstruct=kwargs["draw_secondary_structure"],
                boundaries=kwargs["boundaries"],
                **additional_plot_kwargs)

            # print PDB information if selected as parameter
            # (for now, not a required parameter, default to True)
            if kwargs.get("print_pdb_information",
                          True) and sifts_map is not None and len(
                              sifts_map.hits) > 0:
                print_pdb_structure_info(
                    sifts_map,
                    ax=plt.gca(),
                    header_text="PDB structures:",
                )

            plt.suptitle("{} evolutionary couplings".format(len(ecs)),
                         fontsize=14)

            if output_file is not None:
                plt.savefig(output_file, bbox_inches="tight")
                plt.close(fig)