From aafda783f67fcf1e6a50cf8e079623d56afc3ee8 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Thu, 9 May 2024 11:22:25 -0700 Subject: [PATCH 1/5] phylo: use config params for traits params Allow users to customize the augur traits command through config params. --- phylogenetic/defaults/hmpxv1/config.yaml | 4 ++++ phylogenetic/defaults/hmpxv1_big/config.yaml | 4 ++++ phylogenetic/defaults/mpxv/config.yaml | 4 ++++ phylogenetic/rules/annotate_phylogeny.smk | 4 ++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/phylogenetic/defaults/hmpxv1/config.yaml b/phylogenetic/defaults/hmpxv1/config.yaml index 658b924..db5d4d4 100644 --- a/phylogenetic/defaults/hmpxv1/config.yaml +++ b/phylogenetic/defaults/hmpxv1/config.yaml @@ -74,6 +74,10 @@ clock_rate: 5.7e-5 clock_std_dev: 2e-5 divergence_units: "mutations" +traits: + columns: "country" + sampling_bias_correction: 3 + ## recency recency: true diff --git a/phylogenetic/defaults/hmpxv1_big/config.yaml b/phylogenetic/defaults/hmpxv1_big/config.yaml index e2b63d9..c85d939 100644 --- a/phylogenetic/defaults/hmpxv1_big/config.yaml +++ b/phylogenetic/defaults/hmpxv1_big/config.yaml @@ -50,6 +50,10 @@ clock_rate: 5.7e-5 clock_std_dev: 2e-5 divergence_units: "mutations" +traits: + columns: "country" + sampling_bias_correction: 3 + ## recency recency: true diff --git a/phylogenetic/defaults/mpxv/config.yaml b/phylogenetic/defaults/mpxv/config.yaml index 8d2e39f..b274873 100644 --- a/phylogenetic/defaults/mpxv/config.yaml +++ b/phylogenetic/defaults/mpxv/config.yaml @@ -70,6 +70,10 @@ clock_rate: 3e-6 clock_std_dev: 6e-6 divergence_units: "mutations-per-site" +traits: + columns: "country" + sampling_bias_correction: 3 + ## recency recency: true diff --git a/phylogenetic/rules/annotate_phylogeny.smk b/phylogenetic/rules/annotate_phylogeny.smk index 248ea10..6a15627 100644 --- a/phylogenetic/rules/annotate_phylogeny.smk +++ b/phylogenetic/rules/annotate_phylogeny.smk @@ -72,8 +72,8 @@ rule traits: output: node_data=build_dir + "/{build_name}/traits.json", params: - columns="country", - sampling_bias_correction=3, + columns=config["traits"]["columns"], + sampling_bias_correction=config["traits"]["sampling_bias_correction"], strain_id=config["strain_id_field"], shell: """ From 5d42ca1e4cd057c25834ba7634e3e14e5e482b33 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Thu, 9 May 2024 11:25:54 -0700 Subject: [PATCH 2/5] phylo: conditionalized traits input for rule export If there are no columns defined for `augur traits` then do not include the traits input for the `--node-data` option for `augur export`. --- phylogenetic/rules/export.smk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phylogenetic/rules/export.smk b/phylogenetic/rules/export.smk index 124b07a..c38ff44 100644 --- a/phylogenetic/rules/export.smk +++ b/phylogenetic/rules/export.smk @@ -70,7 +70,11 @@ rule export: if config.get("timetree", False) else "results/{build_name}/branch_lengths_no_time.json" ), - traits=build_dir + "/{build_name}/traits.json", + traits=( + build_dir + "/{build_name}/traits.json" + if config.get("traits", {}).get("columns", False) + else [] + ), nt_muts=build_dir + "/{build_name}/nt_muts.json", aa_muts=build_dir + "/{build_name}/aa_muts.json", clades=build_dir + "/{build_name}/clades.json", @@ -95,7 +99,7 @@ rule export: --tree {input.tree} \ --metadata {input.metadata} \ --metadata-id-columns {params.strain_id} \ - --node-data {input.branch_lengths} {input.nt_muts} {input.aa_muts} {input.mutation_context} {input.clades} {input.recency}\ + --node-data {input.branch_lengths} {input.traits} {input.nt_muts} {input.aa_muts} {input.mutation_context} {input.clades} {input.recency}\ --colors {input.colors} \ --lat-longs {input.lat_longs} \ --description {input.description} \ From 7e95a16c4befcd118e60bb65c886be883ef1c01f Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Thu, 9 May 2024 11:27:36 -0700 Subject: [PATCH 3/5] phylo: restore disabling of geographic reconstruction Restoring behavior from 43fdaf1015a5a55b580612308c2b631bc22e9f74 by providing an empty traits column config param. --- phylogenetic/defaults/hmpxv1/config.yaml | 2 +- phylogenetic/defaults/hmpxv1_big/config.yaml | 2 +- phylogenetic/defaults/mpxv/config.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phylogenetic/defaults/hmpxv1/config.yaml b/phylogenetic/defaults/hmpxv1/config.yaml index db5d4d4..4cd55da 100644 --- a/phylogenetic/defaults/hmpxv1/config.yaml +++ b/phylogenetic/defaults/hmpxv1/config.yaml @@ -75,7 +75,7 @@ clock_std_dev: 2e-5 divergence_units: "mutations" traits: - columns: "country" + columns: "" sampling_bias_correction: 3 ## recency diff --git a/phylogenetic/defaults/hmpxv1_big/config.yaml b/phylogenetic/defaults/hmpxv1_big/config.yaml index c85d939..1c9cf79 100644 --- a/phylogenetic/defaults/hmpxv1_big/config.yaml +++ b/phylogenetic/defaults/hmpxv1_big/config.yaml @@ -51,7 +51,7 @@ clock_std_dev: 2e-5 divergence_units: "mutations" traits: - columns: "country" + columns: "" sampling_bias_correction: 3 ## recency diff --git a/phylogenetic/defaults/mpxv/config.yaml b/phylogenetic/defaults/mpxv/config.yaml index b274873..6bd9678 100644 --- a/phylogenetic/defaults/mpxv/config.yaml +++ b/phylogenetic/defaults/mpxv/config.yaml @@ -71,7 +71,7 @@ clock_std_dev: 6e-6 divergence_units: "mutations-per-site" traits: - columns: "country" + columns: "" sampling_bias_correction: 3 ## recency From 9bc91b8b40caf146e4af6558ac6e404a67cbc460 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Thu, 9 May 2024 12:19:20 -0700 Subject: [PATCH 4/5] phylo: replace hard-coded "results/" paths with `build_dir` --- phylogenetic/rules/export.smk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phylogenetic/rules/export.smk b/phylogenetic/rules/export.smk index c38ff44..1501eb2 100644 --- a/phylogenetic/rules/export.smk +++ b/phylogenetic/rules/export.smk @@ -32,9 +32,9 @@ OUTPUTS: rule remove_time: input: - "results/{build_name}/branch_lengths.json", + build_dir + "/{build_name}/branch_lengths.json", output: - "results/{build_name}/branch_lengths_no_time.json", + build_dir + "/{build_name}/branch_lengths_no_time.json", shell: """ python3 scripts/remove_timeinfo.py --input-node-data {input} --output-node-data {output} @@ -66,9 +66,9 @@ rule export: tree=build_dir + "/{build_name}/tree.nwk", metadata=build_dir + "/{build_name}/metadata.tsv", branch_lengths=( - "results/{build_name}/branch_lengths.json" + build_dir + "/{build_name}/branch_lengths.json" if config.get("timetree", False) - else "results/{build_name}/branch_lengths_no_time.json" + else build_dir + "/{build_name}/branch_lengths_no_time.json" ), traits=( build_dir + "/{build_name}/traits.json" From 8a7eab4860e2018a534c6537609a8190bda82f0e Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Thu, 9 May 2024 13:18:15 -0700 Subject: [PATCH 5/5] phylo: Add traits to CI config --- phylogenetic/build-configs/ci/config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phylogenetic/build-configs/ci/config.yaml b/phylogenetic/build-configs/ci/config.yaml index 6f90bd9..7010b1f 100644 --- a/phylogenetic/build-configs/ci/config.yaml +++ b/phylogenetic/build-configs/ci/config.yaml @@ -77,6 +77,10 @@ clock_rate: 5.7e-5 clock_std_dev: 2e-5 divergence_units: "mutations" +traits: + columns: "" + sampling_bias_correction: 3 + ## recency recency: true