From 8bef86e88f80cc2a5af2721aadb6c759b1d0875c Mon Sep 17 00:00:00 2001 From: John SJ Anderson Date: Wed, 20 Nov 2024 16:22:58 -0800 Subject: [PATCH] Add frequencies panel [#2] This is _largely_ copy-pasta-ed from the `measles` repo; the one significant change is I enabled the frequencies on both the whole genome and prM-E builds, and I set the `min_date` param to `2017-01-01`, because virtually all of the post-1927 samples are dated 2017 and later. --- phylogenetic/Snakefile | 1 + .../defaults/auspice_config_genome.json | 6 ++++ .../defaults/auspice_config_prM-E.json | 6 ++++ phylogenetic/defaults/config.yaml | 5 ++++ phylogenetic/rules/export.smk | 30 +++++++++++++++++++ 5 files changed, 48 insertions(+) diff --git a/phylogenetic/Snakefile b/phylogenetic/Snakefile index bd939ce..4e2fcdc 100644 --- a/phylogenetic/Snakefile +++ b/phylogenetic/Snakefile @@ -5,6 +5,7 @@ gene = ["genome", "prM-E"] rule all: input: auspice_json=expand("auspice/yellow-fever-virus_{gene}.json", gene=gene), + tip_frequencies_json=expand("auspice/yellow-fever-virus_{gene}_tip-frequencies.json", gene=gene), include: "rules/prepare_sequences.smk" diff --git a/phylogenetic/defaults/auspice_config_genome.json b/phylogenetic/defaults/auspice_config_genome.json index 67f88f2..3e7221b 100644 --- a/phylogenetic/defaults/auspice_config_genome.json +++ b/phylogenetic/defaults/auspice_config_genome.json @@ -58,6 +58,12 @@ "author", "host" ], + "panels": [ + "tree", + "map", + "entropy", + "frequencies" + ], "metadata_columns": [ "author" ] diff --git a/phylogenetic/defaults/auspice_config_prM-E.json b/phylogenetic/defaults/auspice_config_prM-E.json index 06791f3..575e3e7 100644 --- a/phylogenetic/defaults/auspice_config_prM-E.json +++ b/phylogenetic/defaults/auspice_config_prM-E.json @@ -58,6 +58,12 @@ "author", "host" ], + "panels": [ + "tree", + "map", + "entropy", + "frequencies" + ], "metadata_columns": [ "author" ] diff --git a/phylogenetic/defaults/config.yaml b/phylogenetic/defaults/config.yaml index 8046e41..7082318 100644 --- a/phylogenetic/defaults/config.yaml +++ b/phylogenetic/defaults/config.yaml @@ -33,5 +33,10 @@ ancestral: inference: "joint" traits: columns: "clade region" +tip_frequencies: + min_date: "2017-01-01" + max_date: "6M" + narrow_bandwidth: 0.2 + wide_bandwidth: 0.6 export: metadata_columns: "clade region" diff --git a/phylogenetic/rules/export.smk b/phylogenetic/rules/export.smk index d752260..c2038ad 100644 --- a/phylogenetic/rules/export.smk +++ b/phylogenetic/rules/export.smk @@ -39,3 +39,33 @@ rule export: --description {input.description:q} \ 2> {log:q} """ + + +rule tip_frequencies: + """ + Estimating KDE frequencies for tips + """ + input: + tree = "results/{gene}/tree.nwk", + metadata = "data/metadata.tsv" + output: + tip_freq = "auspice/yellow-fever-virus_{gene}_tip-frequencies.json" + params: + strain_id = config["strain_id_field"], + min_date = config["tip_frequencies"]["min_date"], + max_date = config["tip_frequencies"]["max_date"], + narrow_bandwidth = config["tip_frequencies"]["narrow_bandwidth"], + wide_bandwidth = config["tip_frequencies"]["wide_bandwidth"] + shell: + r""" + augur frequencies \ + --method kde \ + --tree {input.tree} \ + --metadata {input.metadata} \ + --metadata-id-columns {params.strain_id} \ + --min-date {params.min_date} \ + --max-date {params.max_date} \ + --narrow-bandwidth {params.narrow_bandwidth} \ + --wide-bandwidth {params.wide_bandwidth} \ + --output {output.tip_freq} + """