From 0cafbbbb802ff31ecf9348678d3c3437a712b987 Mon Sep 17 00:00:00 2001 From: Alexis Simon Date: Thu, 7 Dec 2023 17:00:03 -0800 Subject: [PATCH] tweak cov/var inter rec plot --- workflow/Snakefile | 4 +++- workflow/scripts/plot_variable_intervals_rec.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/workflow/Snakefile b/workflow/Snakefile index fbe1322..cf8fd75 100644 --- a/workflow/Snakefile +++ b/workflow/Snakefile @@ -113,6 +113,7 @@ rule figure_intervals_rec_gss: prefix = "results/simulations/sim_slim_sel_inter_2A_gradual_t140_s3.0", rec = config['rec'], intervals = config['intervals'], + model = "BGS", conda: "envs/popgensim.yaml" script: @@ -121,7 +122,7 @@ rule figure_intervals_rec_gss: rule figure_intervals_rec_bgs: input: expand( - 'results/simulations/sim_msprime_inter_2A_r{rec}_i{inter}.pickle', + 'results/simulations/sim_slim_bgs_scenario_2A_r{rec}_i{inter}.pickle', rec=config['rec'], inter=config['intervals'], ), @@ -131,6 +132,7 @@ rule figure_intervals_rec_bgs: prefix = "results/simulations/sim_slim_bgs_scenario_2A", rec = config['rec'], intervals = config['intervals'], + model = "BGS", conda: "envs/popgensim.yaml" script: diff --git a/workflow/scripts/plot_variable_intervals_rec.py b/workflow/scripts/plot_variable_intervals_rec.py index de870de..2035bc3 100644 --- a/workflow/scripts/plot_variable_intervals_rec.py +++ b/workflow/scripts/plot_variable_intervals_rec.py @@ -2,6 +2,11 @@ import numpy as np import matplotlib.pyplot as plt import pickle +# sci notation formatter +import matplotlib.ticker as tkr +formatter = tkr.ScalarFormatter(useMathText=True) +formatter.set_scientific(True) +formatter.set_powerlimits((0, 0)) colors_oi = [ '#000000', # black @@ -68,14 +73,20 @@ axs[0].legend(ncols=3) axs[0].set_xlabel("sampling interval (gen)") axs[0].set_ylabel("Sum(Cov)") +axs[0].set_title("A", loc='left', fontdict={'fontweight': 'bold'}) +axs[0].set_title(f"Covariances {snakemake.params['model']}") _ = axs[0].set_ylim(ylim) axs[1].set_xlabel("sampling interval (gen)") axs[1].set_ylabel("Sum(Var)") +axs[1].set_title("B", loc='left', fontdict={'fontweight': 'bold'}) +axs[1].set_title(f"Variances {snakemake.params['model']}") _ = axs[1].set_ylim(ylim) _ = axs[0].set_xticks([int(x) + 0.5 for x in intervals]) _ = axs[0].set_xticklabels(intervals) _ = axs[1].set_xticks([int(x) + 0.5 for x in intervals]) _ = axs[1].set_xticklabels(intervals) +axs[0].yaxis.set_major_formatter(formatter) +axs[1].yaxis.set_major_formatter(formatter) fig.savefig(snakemake.output['fig']) \ No newline at end of file