Skip to content

Commit

Permalink
more bug fixes and mem/time updates
Browse files Browse the repository at this point in the history
  • Loading branch information
silastittes committed Jun 28, 2024
1 parent bb13f86 commit 720a4c7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 45 deletions.
26 changes: 14 additions & 12 deletions workflows/dfe.snake
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import ts2fs
import plots
import masks

configfile: "workflows/config/snakemake/tiny_config.yaml"
#quick fix for excluding "Constant" with "pop1" and "pop2" from the analysis
def drop_constant_populations(paths):
return [path for path in paths if not ("Constant" in path and ("pop1" in path or "pop2" in path))]


configfile: "workflows/config/snakemake/tiny_config.yaml"

np.random.seed(config["seed"])

Expand Down Expand Up @@ -73,7 +77,6 @@ if "none" in annotation_dict:
del annotation_dict["none"]
annotation_list = list(annotation_dict)


rule all:
input:
expand(output_dir + "/plots/{demog}/{dfes}/{annots}/dfe.inference.benchmark.pdf",
Expand Down Expand Up @@ -163,8 +166,7 @@ rule dadi_infer_dfe:
threads: 8
shell:
"""
dadi-cli InferDFE --fs {input[0]} --cache1d {input[1]} --demo-popt {input[2]} --output-prefix {params.prefix} --pdf1d {params.dfe} --p0 {params.dfe_p0} --ubounds {params.dfe_ubounds} --lbounds {params.dfe_lbounds} --ratio {params.ratio} --optimizations {params.opts} --cpus {threads} --nomisid --force-convergence 0

dadi-cli InferDFE --fs {input[0]} --cache1d {input[1]} --demo-popt {input[2]} --output-prefix {params.prefix} --pdf1d {params.dfe} --p0 {params.dfe_p0} --ubounds {params.dfe_ubounds} --lbounds {params.dfe_lbounds} --ratio {params.ratio} --optimizations {params.opts} --cpus {threads} --nomisid --force-convergence 1
"""

rule get_dadi_dfe_bestfits:
Expand Down Expand Up @@ -384,34 +386,34 @@ rule get_grapes_bestfits:

rule plot_results:
input:
dadi_res = expand(output_dir + "/inference/{demog}/dadi/{dfes}/{annots}/{seeds}/pop{ids}/pop{ids}.dadi.bestfit",
dadi_res = drop_constant_populations(expand(output_dir + "/inference/{demog}/dadi/{dfes}/{annots}/{seeds}/pop{ids}/pop{ids}.dadi.bestfit",
demog=demo_model_id_list,
seeds=seed_list,
dfes=dfe_list,
annots=annotation_list,
ids=pids,
),
polydfe_res = expand(output_dir + "/inference/{demog}/polyDFE/{dfes}/{annots}/{seeds}/pop{ids}/pop{ids}.polyDFE.bestfit",
)),
polydfe_res = drop_constant_populations(expand(output_dir + "/inference/{demog}/polyDFE/{dfes}/{annots}/{seeds}/pop{ids}/pop{ids}.polyDFE.bestfit",
demog=demo_model_id_list,
seeds=seed_list,
dfes=dfe_list,
annots=annotation_list,
ids=pids,
),
dfe_alpha_res = expand(output_dir + "/inference/{demog}/DFE-alpha/{dfes}/{annots}/{seeds}/pop{ids}/pop{ids}.DFE-alpha.bestfit",
)),
dfe_alpha_res = drop_constant_populations(expand(output_dir + "/inference/{demog}/DFE-alpha/{dfes}/{annots}/{seeds}/pop{ids}/pop{ids}.DFE-alpha.bestfit",
demog=demo_model_id_list,
seeds=seed_list,
dfes=dfe_list,
annots=annotation_list,
ids=pids,
),
grapes_res = expand(output_dir + "/inference/{demog}/grapes/{dfes}/{annots}/{seeds}/pop{ids}/pop{ids}.grapes.bestfit",
)),
grapes_res = drop_constant_populations(expand(output_dir + "/inference/{demog}/grapes/{dfes}/{annots}/{seeds}/pop{ids}/pop{ids}.grapes.bestfit",
demog=demo_model_id_list,
seeds=seed_list,
dfes=dfe_list,
annots=annotation_list,
ids=pids,
)
))
output:
output_dir + "/plots/{demog}/{dfes}/{annots}/dfe.inference.benchmark.pdf"
run:
Expand Down
56 changes: 28 additions & 28 deletions workflows/masks/HapmapII_GRCh38.mask.bed
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
chr10 38861078 41705569
chr1 121569984 143276353
chr11 50795892 54555633
chr12 34700914 37463389
chr13 1 18447064
chr14 1 19198131
chr15 1 19809716
chr16 36034945 46428208
chr17 22738887 26950488
chr18 15409995 20934306
chr19 24373307 27244449
chr20 26328611 30187700
chr21 10646501 12968298
chr21 1 10326653
chr22 1 15287921
chr2 90236658 91433610
chr2 92117097 94663732
chr3 90427071 93808853
chr4 49627542 51818712
chr5 46363876 50291681
chr6 58452161 60342543
chr7 57870656 61072218
chr8 43936537 46006821
chr9 38743712 40906821
chr9 41438036 62926704
chr9 66183582 68223187
chrX 1 2785350
chrX 58456814 62611346
chr1 121569983 143276353
chr2 90236657 91433610
chr2 92117096 94663732
chr3 90427070 93808853
chr4 49627541 51818712
chr5 46363875 50291681
chr6 58452160 60342543
chr7 57870655 61072218
chr8 43936536 46006821
chr9 38743711 40906821
chr9 41438035 62926704
chr9 66183581 68223187
chr10 38861077 41705569
chr11 50795891 54555633
chr12 34700913 37463389
chr13 0 18447064
chr14 0 19198131
chr15 0 19809716
chr16 36034944 46428208
chr17 22738886 26950488
chr18 15409994 20934306
chr19 24373306 27244449
chr20 26328610 30187700
chr21 0 10326653
chr21 10646500 12968298
chr22 0 15287921
chrX 0 2785350
chrX 58456813 62611346
8 changes: 5 additions & 3 deletions workflows/n_t.snake
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ rule run_stairwayplot:
chrms=chrm_list)
output:
output_dir + "/inference/{demog}/stairwayplot/{dfes}/{annots}/{seeds}/{pops}/stairwayplot_estimated_Ne.txt"

threads: 20
resources:
mem_mb=120000,
time = 1_000,
mem_mb=120_000,
run:
inputs = expand(
output_dir
Expand Down Expand Up @@ -347,7 +347,9 @@ rule run_msmc:
output_dir + "/inference/{demog}/msmc/{dfes}/{annots}/{seeds}/{pops}/{samps}.trees.multihep.txt.final.txt"
threads: 8
resources:
mem_mb = lambda wildcards, attempt: attempt * 64000
time = lambda wildcards, attempt: attempt * 1_000,
mem_mb = lambda wildcards, attempt: attempt * 200_000

run:
inputs = expand(output_dir + "/inference/{demog}/msmc/{dfes}/{annots}/{seeds}/{pops}/{chrms}.trees.multihep.txt",
demog=wildcards.demog,
Expand Down
4 changes: 2 additions & 2 deletions workflows/simulation.snake
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ rule simulation:
output:
output_dir + "/simulated_data/{demog}/{dfes}/{annots}/{seeds}/sim_{chrms}.trees"
resources:
time = lambda wildcards, attempt: attempt * 3000,
mem_mb = lambda wildcards, attempt: attempt * 50000
time = lambda wildcards, attempt: attempt * 6000,
mem_mb = lambda wildcards, attempt: attempt * 100000
run:
if wildcards.demog == 'Constant':
model = stdpopsim.PiecewiseConstantSize(species.population_size)
Expand Down

0 comments on commit 720a4c7

Please sign in to comment.