Skip to content

Commit

Permalink
Merge pull request #181 from nextstrain/add-emerging-clades
Browse files Browse the repository at this point in the history
Add emerging subclades to nextflu-private builds
  • Loading branch information
huddlej authored Sep 16, 2024
2 parents bddf3d1 + c23d20d commit 2489228
Show file tree
Hide file tree
Showing 12 changed files with 242 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
39 changes: 39 additions & 0 deletions config/h3n2/ha/auspice_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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
3 changes: 3 additions & 0 deletions nextclade/config/config_dict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ builds:
short-clade:
url: "seasonal_A-H3N2_HA/main/.auto-generated/clades.tsv"
key: "short-clade"
emerging_subclade:
url: "seasonal_A-H3N2_HA/emerging/.auto-generated/subclades.tsv"
key: "emerging_subclade"
refs:
EPI1857216:
filter: "--min-date 2019 --probabilistic-sampling --group-by year region --min-length 1500 --subsample-max-sequences 2000"
Expand Down
1 change: 1 addition & 0 deletions profiles/nextflu-private-forecasts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ array-builds:
tree_exclude_sites: "config/h3n2/{{segment}}/exclude-sites.txt"
clades: "config/h3n2/ha/clades.tsv"
subclades: "config/h3n2/ha/subclades.tsv"
emerging_subclades: "config/h3n2/ha/emerging_subclades.tsv"
auspice_config: "profiles/nextflu-private/h3n2/ha/auspice_config.json"
vaccines: "config/h3n2/vaccine.json"
enable_titer_models: true
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
1 change: 1 addition & 0 deletions profiles/nextstrain-public.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ array-builds:
tree_exclude_sites: "config/{lineage}/{{segment}}/exclude-sites.txt"
clades: "config/{lineage}/ha/clades.tsv"
subclades: "config/{lineage}/{{segment}}/subclades.tsv"
emerging_subclades: "config/h3n2/{{segment}}/emerging_subclades.tsv"
auspice_config: "config/{lineage}/{{segment}}/auspice_config.json"
vaccines: "config/{lineage}/vaccine.json"
enable_glycosylation: true
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
2 changes: 2 additions & 0 deletions workflow/snakemake_rules/fitness.smk
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ rule forecast_tips:
"benchmarks/forecast_tips_{build_name}_{segment}_{model}.txt"
log:
"logs/forecast_tips_{build_name}_{segment}_{model}.txt"
resources:
mem_mb=8000,
shell:
"""
python3 flu-forecasting/src/forecast_model.py \
Expand Down

0 comments on commit 2489228

Please sign in to comment.