Skip to content

Commit

Permalink
tweak cov/var inter rec plot
Browse files Browse the repository at this point in the history
  • Loading branch information
alxsimon committed Dec 8, 2023
1 parent d18154c commit 0cafbbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'],
),
Expand All @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions workflow/scripts/plot_variable_intervals_rec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'])

0 comments on commit 0cafbbb

Please sign in to comment.