Example #1
0
    def MAF_comparison_boxplot(self):
        long_format_mafs = self._generate_maf_long_df()

        populations_to_plot = {
            "superpopulation": ['AFR', 'EUR', 'AMR'],
            "population": Dataset.used_populations(),
        }
        for population_level, long_df in long_format_mafs.items():
            population_list = populations_to_plot[population_level]
            mask = long_df["population"].isin(population_list)
            long_df = long_df[mask]
            fig_width = 13 if population_level == "population" else 7
            fig = plt.figure(figsize=(fig_width, 4))
            ax = fig.add_subplot(1, 1, 1)

            panel_labels = long_df["panel"].unique()
            colors = [v for k, v in panel_colors().items() if k in panel_labels]

            sns.boxplot(data=long_df, x="population", y="MAF", hue="panel",
                        ax=ax, linewidth=0.3, showcaps=False, showfliers=False,
                        palette=sns.color_palette(colors), width=0.70)

            self._boxplot_aesthetics(ax)

            filename = "MAF_comparison__{}".format(population_level)
            plt.savefig(join(self.PLOTS_DIR, filename), bbox_inches="tight")
            plt.show()
Example #2
0
    def snp_distances_comparison_boxplot(self, panel_labels):
        distances_long_format = self._generate_distances_long_format()
        mask = distances_long_format["panel"].isin(panel_labels)
        distances = distances_long_format[mask]

        fig = plt.figure(figsize=(12, 3))
        ax = fig.add_subplot(1, 1, 1)

        panel_labels = distances["panel"].unique()
        colors = [v for k, v in panel_colors().items() if k in panel_labels]

        sns.boxplot(x="chromosome", y="value", hue="panel", data=distances,
                    ax=ax, linewidth=0.6, showcaps=False, showfliers=False,
                    palette=sns.color_palette(colors))

        self._boxplot_aesthetics(ax)
        plt.show()