Skip to content

Commit

Permalink
Add emerging subclades to nextflu-private builds
Browse files Browse the repository at this point in the history
Adds rules and configs to annotate emerging subclades to nextflu-private
builds, paving the way for any builds that define the
`emerging_subclade` path in their config to use the same clade
definitions. Most of these emerging subclades map directly to the main
branch in the corresponding influenza nomenclature repos. H3N2 HA is an
exception where the definitions come from a branch called `emerging`.
  • Loading branch information
huddlej committed Sep 11, 2024
1 parent 1677cc2 commit 9d4597e
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ subclade_url_by_lineage_and_segment = {
}
}

emerging_subclade_url_by_lineage_and_segment = {
"h1n1pdm": {
"ha": "https://raw.githubusercontent.com/influenza-clade-nomenclature/seasonal_A-H1N1pdm_HA/main/.auto-generated/subclades.tsv",
"na": "https://raw.githubusercontent.com/influenza-clade-nomenclature/seasonal_A-H1N1pdm_NA/main/.auto-generated/subclades.tsv",
},
"h3n2": {
"ha": "https://raw.githubusercontent.com/influenza-clade-nomenclature/seasonal_A-H3N2_HA/emerging/.auto-generated/subclades.tsv",
"na": "https://raw.githubusercontent.com/influenza-clade-nomenclature/seasonal_A-H3N2_NA/main/.auto-generated/subclades.tsv",
},
"vic": {
"ha": "https://raw.githubusercontent.com/influenza-clade-nomenclature/seasonal_B-Vic_HA/main/.auto-generated/subclades.tsv",
"na": "https://raw.githubusercontent.com/influenza-clade-nomenclature/seasonal_B-Vic_NA/main/.auto-generated/subclades.tsv",
}
}

if "data_source" in config and config["data_source"]=='fauna':
include: "workflow/snakemake_rules/download_from_fauna.smk"

Expand Down
3 changes: 3 additions & 0 deletions profiles/nextflu-private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ builds:
tree_exclude_sites: "config/h1n1pdm/{segment}/exclude-sites.txt"
clades: "config/h1n1pdm/ha/clades.tsv"
subclades: "config/h1n1pdm/{segment}/subclades.tsv"
emerging_subclades: "config/h1n1pdm/{segment}/emerging_subclades.tsv"
auspice_config: "profiles/nextflu-private/h1n1pdm/{segment}/auspice_config.json"
min_date: "2Y"
reference_min_date: "6Y"
Expand Down Expand Up @@ -104,6 +105,7 @@ builds:
tree_exclude_sites: "config/h3n2/{segment}/exclude-sites.txt"
clades: "config/h3n2/ha/clades.tsv"
subclades: "config/h3n2/{segment}/subclades.tsv"
emerging_subclades: "config/h3n2/{segment}/emerging_subclades.tsv"
auspice_config: "profiles/nextflu-private/h3n2/{segment}/auspice_config.json"
vaccines: "config/h3n2/vaccine.json"
enable_glycosylation: true
Expand Down Expand Up @@ -149,6 +151,7 @@ builds:
tree_exclude_sites: "config/vic/{segment}/exclude-sites.txt"
clades: "profiles/nextflu-private/vic/ha/clades.tsv"
subclades: "config/vic/{segment}/subclades.tsv"
emerging_subclades: "config/h3n2/{segment}/emerging_subclades.tsv"
auspice_config: "profiles/nextflu-private/vic/{segment}/auspice_config.json"
min_date: "2Y"
reference_min_date: "6Y"
Expand Down
63 changes: 63 additions & 0 deletions profiles/nextflu-private/h1n1pdm/ha/auspice_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,69 @@
]
]
},
{
"key": "emerging_subclade",
"title": "Emerging subclade",
"type": "categorical",
"scale": [
[
"C.1",
"#492AB5"
],
[
"C.1.1",
"#3F4CCB"
],
[
"C.1.2",
"#4271CE"
],
[
"C.1.5",
"#4C8FC0"
],
[
"C.1.7",
"#5AA5A8"
],
[
"C.1.7.1",
"#6DB38A"
],
[
"C.1.7.2",
"#85BA6F"
],
[
"C.1.8",
"#A0BE59"
],
[
"C.1.9",
"#BBBC49"
],
[
"D",
"#D2B340"
],
[
"D.1",
"#E19F3A"
],
[
"D.2",
"#E68033"
],
[
"D.3",
"#E2562B"
],
[
"D.4",
"#DB2823"
]
]
},
{
"key": "haplotype",
"title": "Derived haplotype",
Expand Down
41 changes: 40 additions & 1 deletion profiles/nextflu-private/h3n2/ha/auspice_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,45 @@
]
]
},
{
"key": "emerging_subclade",
"title": "Emerging subclade",
"type": "categorical",
"scale": [
[
"J",
"#4068CF"
],
[
"J.1",
"#5098B9"
],
[
"J.1.1",
"#6CB28C"
],
[
"J.2",
"#94BD62"
],
[
"J.2.1",
"#BFBB47"
],
[
"J.2.2",
"#DFA53B"
],
[
"J.3",
"#E67131"
],
[
"J.4",
"#DB2823"
]
]
},
{
"key": "haplotype",
"title": "Derived haplotype",
Expand Down Expand Up @@ -555,4 +594,4 @@
"entropy",
"frequencies"
]
}
}
35 changes: 35 additions & 0 deletions profiles/nextflu-private/vic/ha/auspice_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,41 @@
]
]
},
{
"key": "emerging_subclade",
"title": "Emerging subclade",
"type": "categorical",
"scale": [
[
"C.2",
"#4272CE"
],
[
"C.3",
"#58A2AC"
],
[
"C.5",
"#7DB877"
],
[
"C.5.1",
"#AEBD50"
],
[
"C.5.4",
"#D8AE3E"
],
[
"C.5.6",
"#E67A32"
],
[
"C.5.7",
"#DB2823"
]
]
},
{
"key": "haplotype",
"title": "Derived haplotype",
Expand Down
37 changes: 37 additions & 0 deletions workflow/snakemake_rules/core.smk
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,43 @@ rule import_clades:
--output {output.node_data} 2>&1 | tee {log}
"""

rule download_emerging_subclades:
output:
subclades="config/{lineage}/{segment}/emerging_subclades.tsv",
conda: "../envs/nextstrain.yaml"
params:
url=lambda wildcards: emerging_subclade_url_by_lineage_and_segment.get(wildcards.lineage, {}).get(wildcards.segment),
shell:
"""
curl -o {output.subclades} "{params.url}"
"""

rule emerging_subclades:
input:
tree = build_dir + "/{build_name}/{segment}/tree.nwk",
muts = build_dir + "/{build_name}/{segment}/muts.json",
clades = lambda wildcards: config["builds"][wildcards.build_name].get("emerging_subclades"),
output:
node_data = build_dir + "/{build_name}/{segment}/emerging_subclades.json",
params:
membership_name = "emerging_subclade",
label_name = "Emerging subclade",
conda: "../envs/nextstrain.yaml"
benchmark:
"benchmarks/emerging_subclades_{build_name}_{segment}.txt"
log:
"logs/emerging_subclades_{build_name}_{segment}.txt"
shell:
"""
augur clades \
--tree {input.tree} \
--mutations {input.muts} \
--clades {input.clades} \
--membership-name {params.membership_name} \
--label-name {params.label_name:q} \
--output {output.node_data} 2>&1 | tee {log}
"""

rule annotate_haplotypes:
input:
tree=build_dir + "/{build_name}/ha/tree.nwk",
Expand Down
3 changes: 3 additions & 0 deletions workflow/snakemake_rules/export.smk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def _get_node_data_by_wildcards(wildcards):
if config["builds"][wildcards.build_name].get('subclades', False):
inputs.append(rules.subclades.output.node_data)

if config["builds"][wildcards.build_name].get('emerging_subclades', False):
inputs.append(rules.emerging_subclades.output.node_data)

if config["builds"][wildcards.build_name].get('enable_titer_models', False) and wildcards.segment == 'ha':
for collection in config["builds"][wildcards.build_name]["titer_collections"]:
inputs.append(rules.titers_sub.output.titers_model.format(titer_collection=collection["name"], **wildcards_dict))
Expand Down

0 comments on commit 9d4597e

Please sign in to comment.