Add keep_all option for additional_inputs and sequence_source column
Rationale
This is for a use case @CSimonich and I have: we are provided a set of non-public sequences and we want to specify them as additional inputs but keep all of the additional sequences plus subsample Pathoplexus sequences for context.
I made a pull request addressing this in #123
Summary
This PR modifies how additional_inputs work in the RSV build:
-
keep_all: True option: Each entry in additional_inputs can now optionally include keep_all: True to force-include all sequences from that input, bypassing subsampling. Without keep_all (or with keep_all: False), additional inputs are subsampled alongside the default Pathoplexus inputs — preserving the previous default behavior.
-
sequence_source metadata column: When any additional_inputs are defined, a sequence_source column is added to metadata labeling each sequence with its input name or "Pathoplexus". This enables coloring/filtering by origin in Auspice.
Config examples
Default (subsampled)
additional_inputs:
- name: bloom_lab
metadata: "data/custom/{a_or_b}_metadata.tsv"
sequences: "data/custom/{a_or_b}_F.fasta"
Sequences are subsampled normally. A sequence_source column is still added.
Force-include all sequences
additional_inputs:
- name: bloom_lab
metadata: "data/custom/{a_or_b}_metadata.tsv"
sequences: "data/custom/{a_or_b}_F.fasta"
keep_all: True
All sequences bypass subsampling via augur filter --include. Note that keep_all sequences also bypass quality filters (coverage, missing data threshold, etc.), so they don't need Nextclade QC columns.
Mixed
additional_inputs:
- name: priority_seqs
metadata: "data/priority/{a_or_b}_metadata.tsv"
sequences: "data/priority/{a_or_b}_F.fasta"
keep_all: True
- name: other_seqs
metadata: "data/other/{a_or_b}_metadata.tsv"
sequences: "data/other/{a_or_b}_F.fasta"
Implementation details
Files changed
| File |
Change |
workflow/snakemake_rules/merge_inputs.smk |
Allow keep_all key for additional_inputs; validate separately from inputs |
workflow/snakemake_rules/sequence_source.smk |
Only force-include accessions from keep_all: True inputs; add sequence_source for all additional inputs; validate keep_all is boolean |
workflow/snakemake_rules/core.smk |
Rename custom_include → additional_include |
config/auspice_config.json |
sequence_source coloring and filter (from prior commit, unchanged) |
README.md |
Document keep_all option, metadata requirements, sequence_source column |
How it works
merge_inputs.smk merges all inputs (default + additional) into combined metadata/sequences as before
sequence_source.smk reads all additional input FASTAs to build an accession→source mapping, adds sequence_source column to metadata
sequence_source.smk generates additional_include.txt containing only accessions from keep_all: True inputs (empty file otherwise)
core.smk passes additional_include.txt to augur filter --include, which force-includes those accessions during subsampling
Backward compatibility
- Existing configs with
additional_inputs but no keep_all behave identically to before (subsampled)
- The only new behavior for such configs is the addition of the
sequence_source column
- Configs without
additional_inputs are completely unaffected
Note on sequence_source in auspice_config.json
The sequence_source coloring (line 46) and filter (line 127) are always present in config/auspice_config.json, even though the sequence_source metadata column only exists when additional_inputs are defined. This is intentional: Auspice silently ignores colorings and filters that reference columns not present in the metadata. This means:
- With
additional_inputs: the "Sequence source" coloring and filter appear in Auspice as expected.
- Without
additional_inputs: the entries in auspice_config.json are harmlessly ignored; the user sees no difference.
The alternative would be to dynamically generate auspice_config.json based on whether additional_inputs are present, but that adds complexity for no functional benefit. If the Nextstrain team prefers a cleaner config that doesn't reference potentially-absent columns, this could be revisited.
Add
keep_alloption foradditional_inputsandsequence_sourcecolumnRationale
This is for a use case @CSimonich and I have: we are provided a set of non-public sequences and we want to specify them as additional inputs but keep all of the additional sequences plus subsample Pathoplexus sequences for context.
I made a pull request addressing this in #123
Summary
This PR modifies how
additional_inputswork in the RSV build:keep_all: Trueoption: Each entry inadditional_inputscan now optionally includekeep_all: Trueto force-include all sequences from that input, bypassing subsampling. Withoutkeep_all(or withkeep_all: False), additional inputs are subsampled alongside the default Pathoplexus inputs — preserving the previous default behavior.sequence_sourcemetadata column: When anyadditional_inputsare defined, asequence_sourcecolumn is added to metadata labeling each sequence with its input name or "Pathoplexus". This enables coloring/filtering by origin in Auspice.Config examples
Default (subsampled)
Sequences are subsampled normally. A
sequence_sourcecolumn is still added.Force-include all sequences
All sequences bypass subsampling via
augur filter --include. Note thatkeep_allsequences also bypass quality filters (coverage, missing data threshold, etc.), so they don't need Nextclade QC columns.Mixed
Implementation details
Files changed
workflow/snakemake_rules/merge_inputs.smkkeep_allkey foradditional_inputs; validate separately frominputsworkflow/snakemake_rules/sequence_source.smkkeep_all: Trueinputs; addsequence_sourcefor all additional inputs; validatekeep_allis booleanworkflow/snakemake_rules/core.smkcustom_include→additional_includeconfig/auspice_config.jsonsequence_sourcecoloring and filter (from prior commit, unchanged)README.mdkeep_alloption, metadata requirements,sequence_sourcecolumnHow it works
merge_inputs.smkmerges all inputs (default + additional) into combined metadata/sequences as beforesequence_source.smkreads all additional input FASTAs to build an accession→source mapping, addssequence_sourcecolumn to metadatasequence_source.smkgeneratesadditional_include.txtcontaining only accessions fromkeep_all: Trueinputs (empty file otherwise)core.smkpassesadditional_include.txttoaugur filter --include, which force-includes those accessions during subsamplingBackward compatibility
additional_inputsbut nokeep_allbehave identically to before (subsampled)sequence_sourcecolumnadditional_inputsare completely unaffectedNote on
sequence_sourceinauspice_config.jsonThe
sequence_sourcecoloring (line 46) and filter (line 127) are always present inconfig/auspice_config.json, even though thesequence_sourcemetadata column only exists whenadditional_inputsare defined. This is intentional: Auspice silently ignores colorings and filters that reference columns not present in the metadata. This means:additional_inputs: the "Sequence source" coloring and filter appear in Auspice as expected.additional_inputs: the entries inauspice_config.jsonare harmlessly ignored; the user sees no difference.The alternative would be to dynamically generate
auspice_config.jsonbased on whetheradditional_inputsare present, but that adds complexity for no functional benefit. If the Nextstrain team prefers a cleaner config that doesn't reference potentially-absent columns, this could be revisited.