Update Nextclade workflow to handle new clade Ib outbreak sh2023 lineages#368
Merged
Conversation
Prefix sh2017 lineage definitions and parent references across the Nextclade clade tables so parallel lineage systems can coexist. Update clade renaming to parse outbreak/lineage identifiers, map them to their parent clade, and reject legacy unprefixed lineage names.
…de I tree with constraint tree
There was a problem hiding this comment.
Pull request overview
Updates the Nextclade/Snakemake phylogeny workflow to support outbreak-namespaced lineages (notably a second lineage system under clade Ib outbreak sh2023), along with masking/exclusion and visualization updates.
Changes:
- Introduce and propagate a new
outbreakLineagefield (outbreak/lineage) for filtering, grouping, and coloring. - Make deduplication/known-duplicate filtering respect “include” accession lists to keep required references/recombinants.
- Add/adjust clade definitions, masks, constraints, and excluded accessions to stabilize clade I/Ib trees and handle problematic sequences.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| phylogenetic/rules/construct_phylogeny.smk | Updates phylogenetic tree construction args/logging and rule formatting. |
| phylogenetic/defaults/exclude.txt | Adds additional accessions to exclude from phylogenetic builds. |
| nextclade/Snakefile | Adds outbreakLineage derivation, improves dedup/known-duplicate filtering, switches tree building and adds constraint support, and wires new clade renaming inputs. |
| nextclade/scripts/deduplicate.py | Adds “include” support so certain accessions are never removed during deduplication. |
| nextclade/scripts/clades_renaming.py | Namespaces lineages by outbreak, emits outbreakLineage, and adjusts branch label rewriting. |
| nextclade/scripts/assign-colors.py | Allows color assignment to consider outbreakLineage. |
| nextclade/resources/lineage-b.1/include_recombinants.txt | Ensures recombinants are retained for lineage-b.1 build. |
| nextclade/resources/lineage-b.1/clades.tsv | Namespaces lineage-b.1 clades under sh2017/…. |
| nextclade/resources/known_duplicates.txt | Adds additional known-duplicate accessions. |
| nextclade/resources/exclude_accessions.txt | Adds additional excluded accessions (recombinants + problematic sequences). |
| nextclade/resources/color_ordering.tsv | Adds ordering for outbreakLineage (and related clade/lineage updates). |
| nextclade/resources/clade-iib/include_recombinants.txt | Ensures recombinants are retained for clade IIb build. |
| nextclade/resources/clade-iib/clades.tsv | Namespaces clade IIb lineages under sh2017/…. |
| nextclade/resources/clade-i/mask.bed | Adjusts clade I masking ranges (Ib-focused problematic sites). |
| nextclade/resources/clade-i/include_recombinants.txt | Ensures recombinants are retained for clade I build. |
| nextclade/resources/clade-i/include_accessions.txt | Adds references to ensure key sh2023 lineages are kept. |
| nextclade/resources/clade-i/constraint_tree.nwk | Adds a constraint tree to stabilize clade I/Ib topology. |
| nextclade/resources/clade-i/clades.tsv | Adds sh2023 lineage definitions under clade Ib. |
| nextclade/resources/clade-i/auspice_config_patch.json | Adjusts clade I auspice placement mask patch ranges. |
| nextclade/resources/auspice_config.json | Adds outbreakLineage to auspice coloring and filters. |
| nextclade/resources/all-clades/mask.bed | Adds additional all-clades mask ranges. |
| nextclade/resources/all-clades/include_accessions.txt | Adds sh2023 references to the all-clades include set. |
| nextclade/resources/all-clades/clades.tsv | Adds/updates sh2023 and sh2017 namespaced clade definitions for all-clades build. |
| nextclade/config/config.yaml | Switches filtering/subsampling/grouping to outbreakLineage and adds build-specific settings (outgroup name, constraints). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
43
to
+46
| rule fix_tree: | ||
| """ | ||
| Fixing tree | ||
| """ | ||
| Fixing tree | ||
| """ |
Comment on lines
+33
to
+38
| parser.add_argument("--tree-file", type=str, help="input tree file (not used)") | ||
| args = parser.parse_args() | ||
| # get all node names | ||
| with open (args.tree_file) as fh: | ||
| tree = Phylo.read(fh, "newick") | ||
| all_node_names = {clade.name for clade in tree.find_clades() if clade.name is not None} |
Comment on lines
505
to
+515
| input: | ||
| alignment="results/{build_name}/masked.fasta", | ||
| constraint_tree=lambda w: config[w.build_name].get("constraint_tree", ""), | ||
| output: | ||
| tree="results/{build_name}/masked.fasta.treefile", | ||
| params: | ||
| constraint_option=lambda w: ( | ||
| f"-g {config[w.build_name]['constraint_tree']}" | ||
| if "constraint_tree" in config[w.build_name] | ||
| else "" | ||
| ), |
Comment on lines
+105
to
+120
| def deduplicate( | ||
| input: str, | ||
| output: str, | ||
| include: list[str] = [], | ||
| num_processes: int = 10, | ||
| ): | ||
| """ | ||
| Deduplicate sequences in a file | ||
| Args: | ||
| sequences: path to sequences file | ||
| output: path to output file | ||
| include: paths containing sequence IDs that must not be removed | ||
| num_processes: number of cores to use | ||
| """ | ||
| includes = read_accessions(include) | ||
| dup_list = set() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of proposed changes
Changes necessary to support a second lineage system under clade Ib outbreak sh2023.
See mpxv-lineages/lineage-designation#52 for the lineage designation PR that introduces those lineages.