def chromosomes_with_SNPs_plot(self, panel, xlabels_on=True): genome = Genome.regions() fig, ax = plt.subplots() chrom_linewidth = 0.75 chrom_color = "Grey" # p arm ends where centromere starts ;) for chrom, centromere_start in genome["centromere_start"].iteritems(): ax.plot([chrom, chrom], [0, centromere_start], color=chrom_color, lw=chrom_linewidth) q_arms = genome[["centromere_end", "chr_length"]] for chrom, (q_start, chrom_end) in q_arms.iterrows(): ax.plot([chrom, chrom], [q_start, chrom_end], color=chrom_color, lw=chrom_linewidth) # SNPs panel.snps.plot(ax=ax, kind="scatter", x="chr", y="position", lw=1, s=120, color="black", marker="_") ax = self._chromosomes_plot_aesthetics(ax, genome) if not xlabels_on: ax.set_xticklabels([]) ax.set_xlabel("") filename = "chromosomes_with_SNPs__{}".format(panel.label) filepath = join(PLOTS_DIR, filename) print(filepath) plt.savefig(filepath, bbox_inches="tight") return ax
def _generate_distances_long_format(self): genome = Genome.regions() panel_analyser = PanelAnalyser() frames = [panel_analyser.snp_distances_per_chromosome(panel, genome) for panel in Panel.all_panels()] distances = pd.concat(frames).T return pd.melt(distances)