def plot_all_stats(real_stats, real_dist, real_sfs, real_ld, sim_stats, sim_dist, sim_sfs, sim_ld, output): fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(7, 7)) color = COLORS[PREFIX] ss_helpers.plot_sfs(axes.flatten()[0], real_sfs, sim_sfs, color, SIM_COLOR, pop=PREFIX, single=True) ss_helpers.plot_dist(axes.flatten()[1], real_dist, sim_dist, color, SIM_COLOR, pop=PREFIX, single=True) ss_helpers.plot_ld(axes.flatten()[2], real_ld, sim_ld, color, SIM_COLOR, pop=PREFIX, single=True) for i in range(3): ss_helpers.plot_generic(axes.flatten()[i+3], NAMES[i], real_stats[i], sim_stats[i], color, SIM_COLOR, pop=PREFIX, single=True) plt.tight_layout() if output != None: plt.savefig(output, dpi=300) else: plt.show()
def plot_stats_threepop(real_stats1, real_dist1, real_sfs1, real_ld1, real_stats2, real_dist2, real_sfs2, real_ld2, real_stats3, real_dist3, real_sfs3, real_ld3, sim_stats1, sim_dist1, sim_sfs1, sim_ld1, sim_stats2, sim_dist2, sim_sfs2, sim_ld2, sim_stats3, sim_dist3, sim_sfs3, sim_ld3, real_fst12, real_fst13, real_fst23, sim_fst12, sim_fst13, sim_fst23, output): fig, axes = plt.subplots(nrows=6, ncols=4, figsize=(14, 14)) pop_names = PREFIX.split("_") POP1 = pop_names[0] POP2 = pop_names[1] POP3 = pop_names[2] c1 = COLORS[POP1] c2 = COLORS[POP2] c3 = COLORS[POP3] # pop 1 ss_helpers.plot_sfs(axes[0][0], real_sfs1, sim_sfs1, c1, SIM_COLOR, pop=POP1) ss_helpers.plot_dist(axes[0][1], real_dist1, sim_dist1, c1, SIM_COLOR, pop=POP1) ss_helpers.plot_ld(axes[1][0], real_ld1, sim_ld1, c1, SIM_COLOR, pop=POP1) ss_helpers.plot_generic(axes[1][1], NAMES[0], real_stats1[0], sim_stats1[0], c1, SIM_COLOR, pop=POP1) ss_helpers.plot_generic(axes[2][0], NAMES[1], real_stats1[1], sim_stats1[1], c1, SIM_COLOR, pop=POP1) ss_helpers.plot_generic(axes[2][1], NAMES[2], real_stats1[2], sim_stats1[2], c1, SIM_COLOR, pop=POP1) # pop 2 ss_helpers.plot_sfs(axes[0][2], real_sfs2, sim_sfs2, c2, SIM_COLOR, pop=POP2) ss_helpers.plot_dist(axes[0][3], real_dist2, sim_dist2, c2, SIM_COLOR, pop=POP2) ss_helpers.plot_ld(axes[1][2], real_ld2, sim_ld2, c2, SIM_COLOR, pop=POP2) ss_helpers.plot_generic(axes[1][3], NAMES[0], real_stats2[0], sim_stats2[0], c2, SIM_COLOR, pop=POP2) ss_helpers.plot_generic(axes[2][2], NAMES[1], real_stats2[1], sim_stats2[1], c2, SIM_COLOR, pop=POP2) ss_helpers.plot_generic(axes[2][3], NAMES[2], real_stats2[2], sim_stats2[2], c2, SIM_COLOR, pop=POP2) # pop 3 ss_helpers.plot_sfs(axes[3][2], real_sfs3, sim_sfs3, c3, SIM_COLOR, pop=POP3) ss_helpers.plot_dist(axes[3][3], real_dist3, sim_dist3, c3, SIM_COLOR, pop=POP3) ss_helpers.plot_ld(axes[4][2], real_ld3, sim_ld3, c3, SIM_COLOR, pop=POP3) ss_helpers.plot_generic(axes[4][3], NAMES[0], real_stats3[0], sim_stats3[0], c3, SIM_COLOR, pop=POP3) ss_helpers.plot_generic(axes[5][2], NAMES[1], real_stats3[1], sim_stats3[1], c3, SIM_COLOR, pop=POP3) ss_helpers.plot_generic(axes[5][3], NAMES[2], real_stats3[2], sim_stats3[2], c3, SIM_COLOR, pop=POP3) # fst 4 ss_helpers.plot_fst(axes[3][0], real_fst12, sim_fst12, POP1 + "/" + POP2, "simulated", "purple", SIM_COLOR) ss_helpers.plot_fst(axes[4][0], real_fst13, sim_fst13, POP1 + "/" + POP3, "simulated", "purple", SIM_COLOR) ss_helpers.plot_fst(axes[5][0], real_fst23, sim_fst23, POP2 + "/" + POP3, "simulated", "purple", SIM_COLOR) axes[3][1].axis('off') axes[4][1].axis('off') axes[5][1].axis('off') # overall legend pop1_real = mpatches.Patch(color=c1, label=POP1 + ' real data') pop1_sim = mpatches.Patch(color=SIM_COLOR, label=POP1 + ' sim data') pop2_real = mpatches.Patch(color=c2, label=POP2 + ' real data') pop2_sim = mpatches.Patch(color=SIM_COLOR, label=POP2 + ' sim data') pop3_real = mpatches.Patch(color=c3, label=POP3 + ' real data') pop3_sim = mpatches.Patch(color=SIM_COLOR, label=POP3 + ' sim data') axes[3][1].legend(handles=[pop1_real, pop1_sim], loc=10, prop={'size': 18}) axes[4][1].legend(handles=[pop2_real, pop2_sim], loc=10, prop={'size': 18}) axes[5][1].legend(handles=[pop3_real, pop3_sim], loc=10, prop={'size': 18}) plt.tight_layout() if output != None: plt.savefig(output, dpi=300) else: plt.show()
def plot_stats_twopop(real_stats1, real_dist1, real_sfs1, real_ld1, real_stats2, real_dist2, real_sfs2, real_ld2, real_fst, \ sim_stats1, sim_dist1, sim_sfs1, sim_ld1, sim_stats2, sim_dist2, sim_sfs2, sim_ld2, sim_fst, output, fsc=False): pop_names = PREFIX.split("_") POP1 = pop_names[0] POP2 = pop_names[1] c1 = COLORS[POP1] c2 = COLORS[POP2] pop1_real = mpatches.Patch(color=c1, label=POP1) pop2_real = mpatches.Patch(color=c2, label=POP2) pop2_sim = mpatches.Patch(color=SIM_COLOR, label='simulated data') if not fsc: fig, axes = plt.subplots(nrows=4, ncols=4, figsize=(14, 10)) axes_all = axes.flatten() # TODO don't flatten? # row 1 ss_helpers.plot_sfs(axes_all[0], real_sfs1, sim_sfs1, c1, SIM_COLOR, pop=POP1) ss_helpers.plot_dist(axes_all[1], real_dist1, sim_dist1, c1, SIM_COLOR, pop=POP1) ss_helpers.plot_sfs(axes_all[2], real_sfs2, sim_sfs2, c2, SIM_COLOR, pop=POP2) ss_helpers.plot_dist(axes_all[3], real_dist2, sim_dist2, c2, SIM_COLOR, pop=POP2) # row 2 ss_helpers.plot_ld(axes_all[4], real_ld1, sim_ld1, c1, SIM_COLOR, pop=POP1) ss_helpers.plot_generic(axes_all[5], NAMES[0], real_stats1[0], sim_stats1[0], c1, SIM_COLOR, pop=POP1) ss_helpers.plot_ld(axes_all[6], real_ld2, sim_ld2, c2, SIM_COLOR, pop=POP2) ss_helpers.plot_generic(axes_all[7], NAMES[0], real_stats2[0], sim_stats2[0], c2, SIM_COLOR, pop=POP2) # row 3 ss_helpers.plot_generic(axes_all[8], NAMES[1], real_stats1[1], sim_stats1[1], c1, SIM_COLOR, pop=POP1) ss_helpers.plot_generic(axes_all[9], NAMES[2], real_stats1[2], sim_stats1[2], c1, SIM_COLOR, pop=POP1) ss_helpers.plot_generic(axes_all[10], NAMES[1], real_stats2[1], sim_stats2[1], c2, SIM_COLOR, pop=POP2) ss_helpers.plot_generic(axes_all[11], NAMES[2], real_stats2[2], sim_stats2[2], c2, SIM_COLOR, pop=POP2) # row 4 ss_helpers.plot_fst(axes_all[13], real_fst, sim_fst, POP1 + "/" + POP2, "simulated", "purple", SIM_COLOR) axes_all[12].axis('off') axes_all[14].axis('off') axes_all[15].axis('off') # overall legend pop1_real = mpatches.Patch(color=c1, label=POP1 + ' real data') pop1_sim = mpatches.Patch(color=SIM_COLOR, label=POP1 + ' sim data') pop2_real = mpatches.Patch(color=c2, label=POP2 + ' real data') pop2_sim = mpatches.Patch(color=SIM_COLOR, label=POP2 + ' sim data') axes_all[12].legend(handles=[pop1_real, pop1_sim], loc=10, prop={'size': 18}) axes_all[15].legend(handles=[pop2_real, pop2_sim], loc=10, prop={'size': 18}) # fastsimcoal else: fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(10.5, 2.5)) axes_all = axes.flatten() # TODO don't flatten? # row 1 ss_helpers.plot_sfs(axes_all[0], real_sfs1, sim_sfs1, c1, SIM_COLOR, pop=POP1) ss_helpers.plot_sfs(axes_all[1], real_sfs2, sim_sfs2, c2, SIM_COLOR, pop=POP2) axes_all[2].axis('off') axes_all[2].legend(handles=[pop1_real, pop2_real, pop2_sim], loc=10, prop={'size': 16}) plt.tight_layout() if output != None: plt.savefig(output, dpi=300) else: plt.show()